Writing controller tests
Testing Kubernetes controller is a big subject, and the boilerplate testing files generated for you by kubebuilder are fairly minimal.
Writing and Running Integration Tests documents steps to consider when writing integration steps for your controllers, and available options for configuring your test control plane using envtest
.
Until more documentation has been written, your best bet to get started is to look at some existing examples, such as:
- Azure Databricks Operator: see their fully fleshed-out
suite_test.go
as well as any*_test.go
file in that directory like this one.
The basic approach is that, in your generated suite_test.go
file, you will
create a local Kubernetes API server, instantiate and run your controllers, and
then write additional *_test.go
files to test it using
Ginko.