Test harnesses are standalone ginkgo e2e test images run on test pods on test clusters by osde2e framework. There are two types of test harnesses depending on the target component tested. SOPs to create and run both are as described below.
-
Clone operator repo.
-
Add subscription to harness boilerplate. Add
openshift/golang-osd-operator-osde2eline to /boilerplate/update.cfg -
Run
make boilerplate-update. Make a commit with updated bp. This commit must be separate from other code changes, otherwise boilerplate pr-check will fail. -
Run
make e2e-harness-generate. -
Update package names in each test file appropriately for the new directory structure.
-
Add tests under the generated scaffolding in test/e2e/.
-
If you're migrating an existing tests from osde2e repo: Copy test files from osde2e/pkg/e2e/operators/ to the newly generated /test/e2e directory in your operator.
-
Run
make e2e-harness-buildIf you have go mod errors,make e2e-harness-buildtarget won't work as it includes go mod tidy. If your repo uses go versions prior to 1.18, you’d need to manually run the following to build a test filego test ./test/e2e -v -c --tags=osde2e -o harness.test
Any dependency errors must be resolved to create the test binary.
-
Run
make e2e-image-build-pushto push harness docker image. Default operator quay repos are under app-sre quay org. If you wish to push to your dev repo, provide registry and repo to this command:REGISTRY_TOKEN=xx HARNESS_IMAGE_REGISTRY=quay.io HARNESS_IMAGE_REPOSITORY=<dev-repo> make e2e-image-build-push -
Test this image locally with
osde2ebinary. For testing with osde2e, use example harness SOP- For
TEST_HARNESSESenv var, provide url to the quay image pushed in #9 above. - Do not provide
ADDON_IDS.
- For
-
Run unit tests on operator repo to ensure updated code doesn't break existing functionality:
make test -
Create PR against operator repo, watch pr-checks.
-
Automate test harness publishing:
- Configure operator test harness quay repo similar to the
aws-vpce-operator-test-harnessentry here https://gitlab.cee.redhat.com/service/app-interface/-/blob/master/data/services/osd-operators/app.yml - Add
make e2e-image-build-pushtarget in the build pipeline for your operator inapp-interfacerepo similar to this in AVO: https://gitlab.cee.redhat.com/service/app-interface/-/blob/master/data/services/osd-operators/cicd/ci-int/jobs-aws-vpce-operator.yaml#L27
- Configure operator test harness quay repo similar to the
-
Automate e2e test harness testing: To run
latestharness image as a postsubmit job: Add a test step to the following to the prow config file in release repo using the example ofstage-e2e-harnessjob config in AVO.- Run
make ci-operator-config - Run
make jobs - Commit updated job and create a PR against
openshift/releaserepo
- Run
-
To run test harness as a periodic job : (todo https://issues.redhat.com/browse/SDCICD-955)
- This method is recommended when the target component is an openshift addon.
- Follow the example harness SOP here
- Note the addon id environment parameter "ADDON_IDS" mentioned in the SOP. This should be provided to osde2e executable for it to install your addon prior to test run.
-
This method is recommended to be used for any component which does not use openshift operator boilerplate convention. It requires manual creation of test structure in either the target repository or a standalone one.
-
Follow the example test harness structure to create a test harness in your component's repository or a standalone repository.
-
Follow steps 7 onwards under Operator test harness SOP above to publish and run your test harness.