To setup the tests locally, you need either:
To setup kubebuilder, fetch the latest release from Github and extract
If you don't want to install kubebuilder and other dependencies of KUDO locally, you can build KUDO and run the tests inside a Docker container.
To run tests inside a Docker container, you can just execute:
Running unit tests
Unit tests are written for KUDO using the standard Go testing library. You can run the unit tests:
Running integration tests
Or run all tests:
Most tests written for KUDO use the declarative test harness with the controller-runtime's envtest (which starts
kube-apiserver locally). This means that tests can be written for and run against KUDO without requiring a Kubernetes cluster (or even Docker).
The test suite is configured by
kudo-test.yaml and the tests live in
test/integration/. Prior to running the tests, all KUDO CRDs and manifests in
test/manifests/ are installed into the test cluster.
The test harness also starts KUDO, so it is recommended to use
go run to run the test suite as this will include the latest built changes from your KUDO checkout.
Run all integration tests:
go run ./cmd/kubectl-kudo test
Run a specific integration test (e.g., the
patch test from
go run ./cmd/kubectl-kudo test --test patch
Run tests against a live cluster:
go run ./cmd/kubectl-kudo test --start-control-plane=false
Run tests against a live cluster and do not delete resources after running:
go run ./cmd/kubectl-kudo test --start-control-plane=false --skip-delete