|
| 1 | +# Cluster Kube API Server Operator Tests Extension |
| 2 | +======================== |
| 3 | + |
| 4 | +This repository contains the tests for the Cluster Kube API Server Operator for OpenShift. |
| 5 | +These tests run against OpenShift clusters and are meant to be used in the OpenShift CI/CD pipeline. |
| 6 | +They use the framework: https://github.com/openshift-eng/openshift-tests-extension |
| 7 | + |
| 8 | +## How to Run the Tests Locally |
| 9 | + |
| 10 | +| Command | Description | |
| 11 | +|--------------------------------------------------------------------------------------------|--------------------------------------------------------------------------| |
| 12 | +| `make tests-ext-build` | Builds the test extension binary. | |
| 13 | +| `./cluster-kube-apiserver-operator-tests-ext list` | Lists all available test cases. | |
| 14 | +| `./cluster-kube-apiserver-operator-tests-ext run-suite <suite-name>` | Runs a test suite. e.g., `openshift/cluster-kube-apiserver-operator/conformance/parallel` | |
| 15 | +| `./cluster-kube-apiserver-operator-tests-ext run <test-name>` | Runs one specific test. | |
| 16 | + |
| 17 | + |
| 18 | +## How to Run the Tests Locally |
| 19 | + |
| 20 | +The tests can be run locally using the `cluster-kube-apiserver-operator-tests-ext` binary against an OpenShift cluster. |
| 21 | +Use the environment variable `KUBECONFIG` to point to your cluster configuration file such as: |
| 22 | + |
| 23 | +```shell |
| 24 | +export KUBECONFIG=path/to/kubeconfig |
| 25 | +./cluster-kube-apiserver-operator-tests-ext run <test-name> |
| 26 | +``` |
| 27 | + |
| 28 | +### Local Test using OCP |
| 29 | + |
| 30 | +1. Use the `Cluster Bot` to create an OpenShift cluster. |
| 31 | + |
| 32 | +**Example:** |
| 33 | + |
| 34 | +```shell |
| 35 | +launch 4.20 gcp,techpreview |
| 36 | +``` |
| 37 | + |
| 38 | +2. Set the `KUBECONFIG` environment variable to point to your OpenShift cluster configuration file. |
| 39 | + |
| 40 | +**Example:** |
| 41 | + |
| 42 | +```shell |
| 43 | +mv ~/Downloads/cluster-bot-2025-08-06-082741.kubeconfig ~/.kube/cluster-bot.kubeconfig |
| 44 | +export KUBECONFIG=~/.kube/cluster-bot.kubeconfig |
| 45 | +``` |
| 46 | + |
| 47 | +3. Run the tests using the `cluster-kube-apiserver-operator-tests-ext` binary. |
| 48 | + |
| 49 | +**Example:** |
| 50 | +```shell |
| 51 | +./cluster-kube-apiserver-operator-tests-ext run-suite openshift/cluster-kube-apiserver-operator/all |
| 52 | +``` |
| 53 | + |
| 54 | +## Writing Tests |
| 55 | + |
| 56 | +You can write tests in the `test/extended/` directory. |
| 57 | + |
| 58 | +## Development Workflow |
| 59 | + |
| 60 | +- Add or update tests in: `test/extended/` |
| 61 | +- Run `make build` to build the operator binary and `make tests-ext-build` for the test binary. |
| 62 | +- You can run the full suite or one test using the commands in the table above. |
| 63 | +- Before committing your changes: |
| 64 | + - Run `make tests-ext-update` |
| 65 | + - Run `make verify` to check formatting, linting, and validation |
| 66 | + |
| 67 | +## How to Rename a Test |
| 68 | + |
| 69 | +1. Run `./cluster-kube-apiserver-operator-tests-ext list` to see the current test names |
| 70 | +2. Find the name of the test you want to rename |
| 71 | +3. Add a Ginkgo label with the original name, like this: |
| 72 | + |
| 73 | +```go |
| 74 | +It("should pass a renamed sanity check", |
| 75 | + Label("original-name:[sig-kube-apiserver] My Old Test Name"), |
| 76 | + func(ctx context.Context) { |
| 77 | + Expect(len("test")).To(BeNumerically(">", 0)) |
| 78 | + }) |
| 79 | +``` |
| 80 | + |
| 81 | +4. Run `make tests-ext-update` to update the metadata |
| 82 | + |
| 83 | +**Note:** Only add the label once. Do not update it again after future renames. |
| 84 | + |
| 85 | +## How to Delete a Test |
| 86 | + |
| 87 | +1. Run `./cluster-kube-apiserver-operator-tests-ext list` to find the test name |
| 88 | +2. Add the test name to the `IgnoreObsoleteTests` block in `cmd/cluster-kube-apiserver-operator-tests-ext/main.go`, like this: |
| 89 | + |
| 90 | +```go |
| 91 | +ext.IgnoreObsoleteTests( |
| 92 | + "[sig-kube-apiserver] My removed test name", |
| 93 | +) |
| 94 | +``` |
| 95 | + |
| 96 | +3. Delete the test code from your suite. |
| 97 | +4. Run `make tests-ext-update` to clean the metadata |
| 98 | + |
| 99 | +**WARNING**: Deleting a test may cause issues with Sippy https://sippy.dptools.openshift.org/sippy-ng/ |
| 100 | +or other tools that expected the Unique TestID tracked outside of this repository. [More info](https://github.com/openshift-eng/ci-test-mapping) |
| 101 | +Check the status of https://issues.redhat.com/browse/TRT-2208 before proceeding with test deletions. |
| 102 | + |
| 103 | +## E2E Test Configuration |
| 104 | + |
| 105 | +Tests are configured in the `openshift/release` repository, under `ci-operator/config/openshift/cluster-kube-apiserver-operator`. |
| 106 | + |
| 107 | +Here is a CI job example: |
| 108 | + |
| 109 | +```yaml |
| 110 | +- as: e2e-aws-techpreview-ckas-op-ext |
| 111 | + steps: |
| 112 | + cluster_profile: aws |
| 113 | + env: |
| 114 | + FEATURE_SET: TechPreviewNoUpgrade |
| 115 | + TEST_SUITE: openshift/cluster-kube-apiserver-operator/all |
| 116 | + test: |
| 117 | + - ref: openshift-e2e-test |
| 118 | + workflow: openshift-e2e-aws |
| 119 | +``` |
| 120 | +
|
| 121 | +This uses the `openshift-tests` binary to run cluster-kube-apiserver-operator tests against a test OpenShift release. |
| 122 | + |
| 123 | +It works for pull request testing because of this: |
| 124 | + |
| 125 | +```yaml |
| 126 | +releases: |
| 127 | + latest: |
| 128 | + integration: |
| 129 | + include_built_images: true |
| 130 | +``` |
| 131 | + |
| 132 | +More info: https://docs.ci.openshift.org/docs/architecture/ci-operator/#testing-with-an-ephemeral-openshift-release |
| 133 | + |
| 134 | +## Makefile Commands |
| 135 | + |
| 136 | +| Target | Description | |
| 137 | +|--------------------------|------------------------------------------------------------------------------| |
| 138 | +| `make build` | Builds the operator binary. | |
| 139 | +| `make tests-ext-build` | Builds the test extension binary. | |
| 140 | +| `make tests-ext-update` | Updates the metadata JSON file and cleans machine-specific codeLocations. | |
| 141 | +| `make verify` | Runs formatting, vet, and linter. | |
| 142 | + |
| 143 | +**Note:** Metadata is stored in: `.openshift-tests-extension/openshift_payload_cluster-kube-apiserver-operator.json` |
| 144 | + |
| 145 | +## FAQ |
| 146 | + |
| 147 | +### Why don't we have a Dockerfile for `cluster-kube-apiserver-operator-tests-ext`? |
| 148 | + |
| 149 | +We do not provide a Dockerfile for `cluster-kube-apiserver-operator-tests-ext` because building and shipping a |
| 150 | +standalone image for this test binary would introduce unnecessary complexity. |
| 151 | + |
| 152 | +Technically, it is possible to create a new OpenShift component just for the |
| 153 | +tests and add a corresponding test image to the payload. However, doing so requires |
| 154 | +onboarding a new component, setting up build pipelines, and maintaining image promotion |
| 155 | +and test configuration — all of which adds overhead. |
| 156 | + |
| 157 | +From the OpenShift architecture point of view: |
| 158 | + |
| 159 | +1. Tests for payload components are part of the product. Many users (such as storage vendors, or third-party CNIs) |
| 160 | +rely on these tests to validate that their solutions are compatible and conformant with OpenShift. |
| 161 | + |
| 162 | +2. Adding new images to the payload comes with significant overhead and cost. |
| 163 | +It is generally preferred to include tests in the same image as the component |
| 164 | +being tested whenever possible. |
| 165 | + |
| 166 | +### Why do we need to run `make tests-ext-update`? |
| 167 | + |
| 168 | +Running `make tests-ext-update` ensures that each test gets a unique and stable **TestID** over time. |
| 169 | + |
| 170 | +The TestID is used to identify tests across the OpenShift CI/CD pipeline and reporting tools like Sippy. |
| 171 | +It helps track test results, detect regressions, and ensures the correct tests are |
| 172 | +executed and reported. |
| 173 | + |
| 174 | +This step is important whenever you add, rename, or delete a test. |
| 175 | +More information: |
| 176 | +- https://github.com/openshift/enhancements/blob/master/enhancements/testing/openshift-tests-extension.md#test-id |
| 177 | +- https://github.com/openshift-eng/ci-test-mapping |
| 178 | + |
| 179 | +### How to get help with OTE? |
| 180 | + |
| 181 | +For help with the OpenShift Tests Extension (OTE), you can reach out on the #wg-openshift-tests-extension Slack channel. |
0 commit comments