@@ -226,14 +226,51 @@ pre-commit run --all-files
226226KUTTL (KUbernetes Test TooL) tests validate the operator's behavior in a real
227227OpenShift environment.
228228
229- Before running the tests ensure that:
230- - ` oc ` CLI tool is available in your PATH and you can access an OpenShift cluster
231- (e.g., deployed with ` crc ` ) with it
232- - The ` openshift-lightspeed ` namespace is empty or non-existing to prevent collisions
229+ Kuttl tests are run using the ` kuttl-test ` make target, which has some
230+ requirements:
233231
234- Once you are ready you can run the KUTTL tests using:
232+ - ` kubectl-kuttl ` , ` diff ` and ` oc ` binaries exist and are in the ` PATH ` .
233+ - An OpenShift cluster is up and running (e.g., one deployed with ` crc ` ).
234+ - ` oc ` CLI tool can access the OpenShift cluster and is logged in.
235+ - The OpenStack Lightspeed operator to be tested is installed and running in the
236+ OpenShift cluster in the ` openstack-lightspeed ` namespace.
237+
238+ Using the ` kuttl-test ` directly is uncommon, as we have 2 helpful targets:
239+
240+ - ` kuttl-test-run ` : Given a catalog image location deploys OpenStack Lightspeed
241+ on the OpenShift cluster, runs the tests (using ` kuttl-test ` ), and removes
242+ OpenStack Lightspeed.
243+
244+ - ` kuttl-test-ocp ` : Builds the operator, bundle and catalog images, pushes them
245+ to the OpenShift cluster internal registry, and then runs the kuttl tests
246+ (using ` kuttl-test-run ` ).
247+
248+ In both cases it will check that the ` kubectl-kuttl ` binary is present in the
249+ system and download it if it's not (target ` kuttl ` ) and both need the
250+ ` openstack-lightspeed ` namespace to be empty or non-existing to prevent
251+ collisions.
252+
253+ For the ` kuttl-test-run ` target the images need to be available in an image
254+ registry accessible by the OpenShift cluster. We can build these images
255+ ourselves or use images built by others, in any case variable ` CATALOG_IMG `
256+ must point to the catalog image before running ` kuttl-test-run ` .
257+
258+ Using ` kuttl-test-ocp ` is useful to build and test everything, but it's too
259+ wasteful if we are going to run kuttl tests multiple times, where
260+ ` kuttl-test-run ` is better as it doesn't rebuild the images on each run.
261+
262+ A useful option when working on kuttl tests, without changes on the operator
263+ itself, is to use ` kuttl-test-ocp ` the first time:
264+
265+ ``` bash
266+ make kuttl-test-ocp
267+ ```
268+
269+ And then set ` CATALOG_IMG ` and use the ` kuttl-test-run ` target in
270+ consecutive runs:
235271
236272``` bash
273+ export CATALOG_IMG=image-registry.openshift-image-registry.svc:5000/openshift-marketplace/operator-catalog:latest
237274make kuttl-test-run
238275```
239276
0 commit comments