When making changes to Operator Builder, you can test your changes with functional tests that generate the codebase for a new operator. You can also use delve to test changes.
Keep in mind you are testing a source code generator that end-user engineers will use to manage Kubernetes operator projects. Operator Builder is used to generate code for a distinct code repository - so the testing is conducted as such. It stamps out and/or modifies source code for an operator project when a functional or debug test is run.
At this time, manual verification of results is needed. In future, automated integration tests will be added to test the generated operator.
test
: Reserved for unit tests.debug
: Runs operator-builder to generate an operator codebase using the delve debugger.debug-clean
: Use with caution. Deletes the contents ofTEST_WORKLOAD_PATH
where the test operator codebase is generated.func-test
: Runs a functional test of operator-builder. It builds and uses the built binary to runoperator-builder init
andoperator-builder create api
. It generates a new operator codebase inFUNC_TEST_PATH
.func-test-clean
: Use with caution. Deletes the contents ofFUNC_TEST_PATH
.
To run the default application
test in the default FUNC_TEST_PATH
:
make func-test
This will generate the codebase for an operator that uses a standalone
workload in your local /tmp/operator-builder-func-test
directory.
To run the platform
test in a non-default directory:
FUNC_TEST_PATH=/path/to/platform-operator \
TEST_WORKLOAD_PATH=test/platform \
make func-test
This will generate the cdoebase for an operator that uses a workload
collection in the /path/to/platform-operator
directory.
Follow these steps to create a new test case:
- Create a descriptive name for the test by creating a new directory under
the
test/
directory. - Create a
.workloadConfig
directory within your newly created directory. - Add the YAML files for your workload under the newly created
.workloadConfig
directory. - Create a workload configuration in the
.workloadConfig
directory with the nameworkload.yaml
.