sourcegraph/dev/tools
Craig Furman c961770a9a
appliance: golden/snapshot testing (#62034)
* appliance: golden/snapshot testing

Use envtest (https://book.kubebuilder.io/reference/envtest.html) to
start a real Kubernetes API server, backed by a real etcd instance, in
tests. The only controller running is our appliance controller, so these
tests assert on the changes our controller actually makes to Kubernetes
API objects in response to some input, but don't depend on complex
infrastruture like container runtimes or persistent volume controllers
(since no such controllers are actually running, unlike in a useful
Kubernetes cluster).

This commit adds a test harness to the appliance package:
* It starts the k8s API server only once, not once per test, as this is
  a relatively slow operation.
* Helper functions to run each test in a unique namespace to avoid
  inter-test dependency. This opens the door to parallelism, but note
  that testify/suite doesn't currently support parallel tests.
* Helper functions to load input ConfigMaps from fixture files.
* Passing `-args appliance-update-golden-files` to `go test` will cause
  checked-in golden files to be updated.
2024-04-24 20:03:55 +00:00
..
BUILD.bazel appliance: golden/snapshot testing (#62034) 2024-04-24 20:03:55 +00:00