Skip to content

Conversation

@JianLi-RH
Copy link
Contributor

@JianLi-RH JianLi-RH commented Oct 22, 2025

In this PR, finished first e2e test case. Related case can be found in: https://polarion.engineering.redhat.com/polarion/#/project/OSE/workitem?id=OCP-42543

Tested it locally:

[jianl@jianl-thinkpadt14gen4 cvo]$ ginkgo --label-filter="42543"
Running Suite: CVO Suite - /home/jianl/1_code/cluster-version-operator/test/cvo
===============================================================================
Random Seed: 1761205561

Will run 1 of 1 specs
•

Ran 1 of 1 Specs in 1.585 seconds
SUCCESS! -- 1 Passed | 0 Failed | 0 Pending | 0 Skipped
PASS

Ginkgo ran 1 suite in 3.310067262s
Test Suite Passed
[jianl@jianl-thinkpadt14gen4 cvo]$ 

Here is the old case in openshift-tests-private: https://github.com/openshift/openshift-tests-private/blob/f1f32ff1e9eeef4cb2cb4ae6549daa9306c6616a/test/extended/ota/cvo/cvo.go#L716-L759

There is a disadvantage here when I use client-go, it seems client-go does not support all Openshift features, for example it could not extract all manifest and it although support methods to get all resource types but it could not use these types to get resources. So in these PR I don't check all manifests but check some special objects.

/cc @wking @DavidHurta @PratikMahajan @hongkailiu @jhou1 @dis016 @jiajliu

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 22, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 22, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: JianLi-RH
Once this PR has been reviewed and has the lgtm label, please assign davidhurta for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@JianLi-RH JianLi-RH force-pushed the implement_client_oc branch 4 times, most recently from a6a8ada to 37caff4 Compare October 23, 2025 07:39
@JianLi-RH JianLi-RH changed the title [WIP] Create packages for connecting to a cluster [WIP] OTA-1605 Create e2e test in CVO repo Oct 23, 2025
@JianLi-RH JianLi-RH force-pushed the implement_client_oc branch 4 times, most recently from a79646a to d944000 Compare October 23, 2025 09:32
@DavidHurta
Copy link
Contributor

Please note that @petr-muller is no longer an active reviewer or approver in the CVO repository. You can refrain from directly pinging him on usual PRs where the expertise of the active folks should be sufficient. He is an "emeritus" approver.

What's an emeritus approver?

GitHub usernames listed under the emeritus_approvers key can no longer approve code (use the /approve command) and will be ignored by prow for assignment. However, it can still be referenced by a person looking at the OWNERS file for a possible second or more informed opinion.

@JianLi-RH JianLi-RH force-pushed the implement_client_oc branch from d944000 to 067cd4b Compare October 24, 2025 07:45
@JianLi-RH JianLi-RH changed the title [WIP] OTA-1605 Create e2e test in CVO repo [WIP] NO-ISSUE: OTA-1605 Create e2e test in CVO repo Oct 24, 2025
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Oct 24, 2025
@openshift-ci-robot
Copy link
Contributor

@JianLi-RH: This pull request explicitly references no jira issue.

In response to this:

In this PR, finished first e2e test case. Related case can be found in: https://polarion.engineering.redhat.com/polarion/#/project/OSE/workitem?id=OCP-42543

Tested it locally:

[jianl@jianl-thinkpadt14gen4 cvo]$ ginkgo --label-filter="42543"
Running Suite: CVO Suite - /home/jianl/1_code/cluster-version-operator/test/cvo
===============================================================================
Random Seed: 1761205561

Will run 1 of 1 specs
•

Ran 1 of 1 Specs in 1.585 seconds
SUCCESS! -- 1 Passed | 0 Failed | 0 Pending | 0 Skipped
PASS

Ginkgo ran 1 suite in 3.310067262s
Test Suite Passed
[jianl@jianl-thinkpadt14gen4 cvo]$ 

Here is the old case in openshift-tests-private: https://github.com/openshift/openshift-tests-private/blob/f1f32ff1e9eeef4cb2cb4ae6549daa9306c6616a/test/extended/ota/cvo/cvo.go#L716-L759

There is a disadvantage here when I use client-go, it seems client-go does not support all Openshift features, for example it could not extract all manifest and it although support methods to get all resource types but it could not use these types to get resources. So in these PR I don't check all manifests but check some special objects.

Another work we need to do is improve the make update command to let it can embed all tests into binary.

/cc @petr-muller @DavidHurta @hongkailiu @wking @jhou1 @dis016 @jiajliu

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@JianLi-RH
Copy link
Contributor Author

Tested on my local machine:

[jianl@jianl-thinkpadt14gen4 cluster-version-operator]$ make update
hack/build-go.sh
Using version from git...
Building binaries into _output/linux/amd64
Building github.com/openshift/cluster-version-operator cluster-version-operator-tests binary (v1.0.0-1482-gd9440005-dirty)
Compressing the cluster-version-operator-tests binary
Building github.com/openshift/cluster-version-operator cluster-version-operator binary (v1.0.0-1482-gd9440005-dirty)
hack/update-test-metadata.sh
Using version from git...
successfully updated metadata
[jianl@jianl-thinkpadt14gen4 cluster-version-operator]$ _output/linux/amd64/cluster-version-operator-tests list
[
  {
    "name": "[Jira:Cluster Version Operator] cluster-version-operator-tests Author:jianl-High-42543-the removed resources are not created in a fresh installed cluster",
    "labels": {
      "42543": {},
      "High": {},
      "cvo": {}
    },
    "resources": {
      "isolation": {}
    },
    "source": "openshift:payload:cluster-version-operator",
    "lifecycle": "blocking",
    "environmentSelector": {}
  }
]
[jianl@jianl-thinkpadt14gen4 cluster-version-operator]$

Run the case:

[jianl@jianl-thinkpadt14gen4 cluster-version-operator]$ _output/linux/amd64/cluster-version-operator-tests list | jq '.[] | select(.name | contains("42543")) | .name' | xargs _output/linux/amd64/cluster-version-operator-tests run-test
  Running Suite:  - /home/jianl/1_code/cluster-version-operator
  =============================================================
  Random Seed: 1761292866 - will randomize all specs

  Will run 1 of 1 specs
  ------------------------------
  [Jira:Cluster Version Operator] cluster-version-operator-tests Author:jianl-High-42543-the removed resources are not created in a fresh installed cluster [cvo, High, 42543]
  /home/jianl/1_code/cluster-version-operator/test/cvo/cvo.go:22
    STEP: Validate resource with 'release.openshift.io/delete: "true"' annotation is not installed @ 10/24/25 16:01:06.862
  • [1.428 seconds]
  ------------------------------

  Ran 1 of 1 Specs in 1.428 seconds
  SUCCESS! -- 1 Passed | 0 Failed | 0 Pending | 0 Skipped
[
  {
    "name": "[Jira:Cluster Version Operator] cluster-version-operator-tests Author:jianl-High-42543-the removed resources are not created in a fresh installed cluster",
    "lifecycle": "blocking",
    "duration": 1428,
    "startTime": "2025-10-24 08:01:06.858981 UTC",
    "endTime": "2025-10-24 08:01:08.287644 UTC",
    "result": "passed",
    "output": "  STEP: Validate resource with 'release.openshift.io/delete: \"true\"' annotation is not installed @ 10/24/25 16:01:06.862\n"
  }
]
[jianl@jianl-thinkpadt14gen4 cluster-version-operator]$ 

@JianLi-RH JianLi-RH changed the title [WIP] NO-ISSUE: OTA-1605 Create e2e test in CVO repo NO-ISSUE: OTA-1605 Create e2e test in CVO repo Oct 24, 2025
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 24, 2025
@JianLi-RH JianLi-RH force-pushed the implement_client_oc branch from 067cd4b to bac7793 Compare October 27, 2025 03:16
@DavidHurta
Copy link
Contributor

/cc

@openshift-ci openshift-ci bot requested a review from DavidHurta October 27, 2025 11:41
@hongkailiu
Copy link
Member

/cc

@openshift-ci openshift-ci bot requested a review from hongkailiu October 27, 2025 13:04
test/README.md Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have https://github.com/openshift/cluster-version-operator/blob/main/cmd/cluster-version-operator-tests/README.md already.

That folder is the entry of the test extension. I feel it fits better to hold the README.md there.

We could merge the useful part into that file.

test/README.md Outdated
# Cluster Version Operator Tests

We hold all e2e tests and related common methods in this folder.
Test script are using client-go, here is the document: https://pkg.go.dev/k8s.io/client-go
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think we need to mention the dependency of the test, unless there are something special for this particular one: client-go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This description is helpful for new contributors who are unfamiliar with client-go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

test/README.md Outdated
Comment on lines 7 to 8
- Install golang, the version should match it in go.mod. Here is the how-to doc https://go.dev/doc/install
- Have the environment variable `KUBECONFIG` set pointing to your cluster.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • It should be fine if the installed GoLang version > the claimed version in go.mod.
  • How the test loads KUBECONFIG is up to the implementation.

In general, we do not need to document those things. If they are not installed/configured correctly, our test should just error out with the necessary hint.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I followed the README in https://github.com/openshift/openshift-tests-private, I think not all user can debug issues when the environment are not setup.

test/README.md Outdated
## Compile the executable binary
In root folder, run below command to build executable binary:
```
$ make update
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build target sounds fitting better.

Suggested change
$ make update
$ make build

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I see make update do more work than make build, and sometimes it will cause issues when there is no .openshift-tests-extension/openshift_payload_cluster-version-operator.json

update: build
	hack/update-test-metadata.sh
.PHONY: update

I will replace then command.

test/README.md Outdated
- Install golang, the version should match it in go.mod. Here is the how-to doc https://go.dev/doc/install
- Have the environment variable `KUBECONFIG` set pointing to your cluster.

## Compile the executable binary
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Compile the executable binary
## Build the executable binary


_, err = oc.RbacV1().ClusterRoleBindings().Get(context.TODO(), "default-account-openshift-machine-config-operator", metav1.GetOptions{})
o.Expect(err).To(o.HaveOccurred(), "ClusterRoleBinding default-account-openshift-machine-config-operator was accidentally installed")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add another g.By() here.

test/cvo/cvo.go Outdated
g.By("Validate resource with 'release.openshift.io/delete: \"true\"' annotation is not installed")

_, err := oc.CoreV1().Services("openshift-cloud-credential-operator").Get(context.TODO(), "controller-manager-service", metav1.GetOptions{})
o.Expect(err).To(o.HaveOccurred(), "Service controller-manager-service was accidentally installed")
Copy link
Member

@hongkailiu hongkailiu Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to check if the error is notFound, something like

o.Expect(kerrors.IsNotFound(err)).To(o.BeTrue(), "The NotFound error should occur")

with

kerrors "k8s.io/apimachinery/pkg/api/errors"

bin/
.DS_Store
_output
.openshift-tests-extension
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering why the file showed up.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this line otherwise we need to update the file every time when we add/remove tests

Copy link
Contributor

@DavidHurta DavidHurta Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The verify-update job was failing with:

Missing Tests:
  * [Jira:Cluster Version Operator] cluster-version-operator-tests should support passing tests

Error: missing tests, if you've renamed tests you must add their names to OriginalName, or mark them obsolete

An updated readme/docs is to be expected for onboarding folks, and this was a nice reminder for me to do that; however, please do not disregard such errors by "bypassing" them. If so, please create a distinct commit with the "what" and "why" for reviewers and future reference.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it deleted?

From cfab71d i feel it needs an update tho.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be created automatically when we run make update, I don't see any reason that we need to keep this file in repo.
cc @DavidHurta WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not doing a thorough review at the moment, I have noticed my ping.

The file is required.

On the file:

Update - Metadata Validation

Component owners will be responsible for implementing the extension interface. To prevent common mistakes and ensure conformance with the evolution of their implementation, make (or similar build system) must run update [--component product:type:component] [--basedir ] after the extension binary is built.

The update verb will create or update files under hack/.openshift-tests-exension/product/type/component/*, by default (basedir defaults to hack/.openshift-tests-extension). If an incompatible change is introduced from the prior invocation of update (e.g. changing a test name without preserving the original), update will raise an error which the component owner must correct before committing their change in git.

The content of the files stored under .openshift-tests-extension is subject to change and wholly defined by the github.com/openshift-eng/openshift-tests-extension module. Individual component owners should not modify files under this path except through invocations of update.

However, this was a nice exercise. I will improve the make update job to explicitly expect the file (in this PR, this was bypassed by modifying the gitignore file). I will also reference this in a respective docs/readme file.

test/cvo/cvo.go Outdated
var _ = Describe("[Jira:Cluster Version Operator] cluster-version-operator-tests", func() {
It("should support passing tests", func() {
Expect(true).To(BeTrue())
var _ = g.Describe("[Jira:Cluster Version Operator] cluster-version-operator-tests", g.Ordered, g.Label("cvo"), func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var _ = g.Describe("[Jira:Cluster Version Operator] cluster-version-operator-tests", g.Ordered, g.Label("cvo"), func() {
var _ = g.Describe("[Jira:Cluster Version Operator] The cluster version operator", g.Ordered, g.Label("cvo"), func() {

Usually the specs on the nodes can make a sentence.
https://onsi.github.io/ginkgo/#writing-specs

@JianLi-RH JianLi-RH force-pushed the implement_client_oc branch from bac7793 to 51facb3 Compare October 29, 2025 04:06
@JianLi-RH
Copy link
Contributor Author

After modification, the case is still valid:

[jianl@jianl-thinkpadt14gen4 cluster-version-operator]$ _output/linux/amd64/cluster-version-operator-tests run-test "[Jira:Cluster Version Operator] The cluster version operator the removed resources are not created in a fresh installed cluster"
  Running Suite:  - /home/jianl/1_code/cluster-version-operator
  =============================================================
  Random Seed: 1761710868 - will randomize all specs

  Will run 1 of 1 specs
  ------------------------------
  [Jira:Cluster Version Operator] The cluster version operator the removed resources are not created in a fresh installed cluster [cvo, High, 42543]
  /home/jianl/1_code/cluster-version-operator/test/cvo/cvo.go:24
    STEP: Service controller-manager-service should not be installed @ 10/29/25 12:07:48.862
    STEP: ClusterRoleBindings default-account-openshift-machine-config-operator should not be installed @ 10/29/25 12:07:49.759
    STEP: CronJobs machine-config-nodes-crd-cleanup should not be installed @ 10/29/25 12:07:50.024
  • [1.428 seconds]
  ------------------------------

  Ran 1 of 1 Specs in 1.429 seconds
  SUCCESS! -- 1 Passed | 0 Failed | 0 Pending | 0 Skipped
[
  {
    "name": "[Jira:Cluster Version Operator] The cluster version operator the removed resources are not created in a fresh installed cluster",
    "lifecycle": "blocking",
    "duration": 1429,
    "startTime": "2025-10-29 04:07:48.858522 UTC",
    "endTime": "2025-10-29 04:07:50.287978 UTC",
    "result": "passed",
    "output": "  STEP: Service controller-manager-service should not be installed @ 10/29/25 12:07:48.862\n  STEP: ClusterRoleBindings default-account-openshift-machine-config-operator should not be installed @ 10/29/25 12:07:49.759\n  STEP: CronJobs machine-config-nodes-crd-cleanup should not be installed @ 10/29/25 12:07:50.024\n"
  }
]
[jianl@jianl-thinkpadt14gen4 cluster-version-operator]$ 

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 29, 2025

@JianLi-RH: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-hypershift 51facb3 link true /test e2e-hypershift

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants