Shared or dedicated
Most tests belong on the shared plane, petri.Start(t). A test needs a
dedicated plane, petri.New(ctx), when it does one of these:
| The test… | Why the shared plane cannot do it |
|---|---|
| adds Nodes, runs the scheduler, or places Pods | Nodes would run other tests' Pods; the shared plane refuses them |
| installs CRD conversion webhooks | a CRD's conversion applies to every test |
needs envtest's behaviour (WithoutDefaultControllers) | the shared plane always runs the default controllers |
| asserts on cluster-wide state, such as "no ClusterRole named X exists" | other tests create cluster-wide objects concurrently |
| runs a controller that cannot be limited to one namespace | it would act on other tests' objects |
A dedicated plane takes about two seconds to start and needs its own memory:
around 300 MiB, more with -race. Group the tests that need one, and let their
subtests share it when they can.