Operator tests

February 9, 2021 ยท View on GitHub

Running tests

One can run test by entering to 'community-operators' project directory and run with following command with these options. '' and '' options are optional

cd <community-operators>
bash <(curl -sL https://cutt.ly/WhkV76k) \
<test-type1,test-type2,...,test-typeN> \
<operator-version-dir-relative-to-community-operators-project> \
[<git repo>] [<git branch>]

Test type

List of tests are shown in following table :

Test typeDescription
kiwiFull operator test
lemonFull test of operator to be deployed from scratch
orangeFull test of operator to be deployed with existing bundles in quay registry
allkiwi,lemon,orange

Logs

Logs can be found in /tmp/op-test/log.out

Testing log files

If operator test fails, one can enter to testing container via follwing command. One can substitue 'docker' with 'podman' when supported

docker exec -it op-test /bin/bash

Examples

Running tests from local direcotry

Following example will run 'all' tests on 'aqua' operator with version '1.0.2' from 'upstream-community-operators (k8s)' directory. 'community-operators' project will be taken from local directory one is running command from ($PWD).

cd <community-operators>
bash <(curl -sL https://cutt.ly/WhkV76k) \
all \
upstream-community-operators/aqua/1.0.2

Running tests from official 'community-operators' repo

Following example will run 'kiwi' and 'lemon' tests on 'aqua' operator with version '1.0.2' from 'community-operators (Openshift)' directory. 'community-operators' project will be taken from git repo 'https://github.com/operator-framework/community-operators' and 'master' branch

cd <community-operators>
bash <(curl -sL https://cutt.ly/WhkV76k) \
kiwi,lemon \
community-operators/aqua/1.0.2 \
https://github.com/operator-framework/community-operators \
master

Running tests from forked 'community-operators' repo ans specific branch

Following example will run 'kiwi' and 'lemon' tests on 'kong' operator with version '0.5.0' from 'upstream-community-operators (k8s)' directory.'community-operators' project will be taken from git repo 'https://github.com/Kong/community-operators' and 'release/v0.5.0' branch ('https://github.com/Kong/community-operators/tree/release/v0.5.0')

cd <community-operators>
bash <(curl -sL https://cutt.ly/WhkV76k) \
kiwi,lemon \
upstream-community-operators/kong/0.5.0 \
https://github.com/Kong/community-operators \
release/v0.5.0

Misc

NameDescriptionDefault
OP_TEST_DEBUGDebug level (0-3)0
OP_TEST_CONTAINER_TOOLContainer tool used on hostdocker
OP_TEST_DRY_RUNWill print commands to be executed0

Testing operators by Ansible

Documentation for testing is located here