Documentation ¶
Index ¶
- func ExternalCRDDirectoryPaths() []string
- func Run(ctx context.Context, input RunInput) int
- type Environment
- func (e *Environment) Cleanup(ctx context.Context, objs ...client.Object) error
- func (e *Environment) CleanupAndWait(ctx context.Context, objs ...client.Object) error
- func (e *Environment) CreateAndWait(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
- func (e *Environment) CreateKubeconfigSecret(ctx context.Context, cluster *clusterv1.Cluster) error
- func (e *Environment) CreateNamespace(ctx context.Context, generateName string, additionalLabels map[string]string) (*corev1.Namespace, error)
- func (e *Environment) PatchAndWait(ctx context.Context, obj client.Object, opts ...client.PatchOption) error
- type EnvironmentOpt
- type RunInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExternalCRDDirectoryPaths ¶
func ExternalCRDDirectoryPaths() []string
func Run ¶
Run executes the tests of the given testing.M in a test environment. Note: The environment will be created in this func and should not be created before. This func takes a *Environment
because our tests require access to the *Environment. We use this field to make the created Environment available to the consumer.
Note: It's possible to write a kubeconfig for the test environment to a file by setting `TEST_ENV_KUBECONFIG`. Note: It's possible to skip stopping the test env after the tests have been run by setting `TEST_ENV_SKIP_STOP` to a non-empty value.
Types ¶
type Environment ¶
type Environment struct { manager.Manager client.Client Config *rest.Config // contains filtered or unexported fields }
Environment encapsulates a Kubernetes local test environment.
func (*Environment) CleanupAndWait ¶
CleanupAndWait deletes all the given objects and waits for the cache to be updated accordingly.
NOTE: Waiting for the cache to be updated helps in preventing test flakes due to the cache sync delays.
func (*Environment) CreateAndWait ¶
func (e *Environment) CreateAndWait( ctx context.Context, obj client.Object, opts ...client.CreateOption, ) error
CreateAndWait creates the given object and waits for the cache to be updated accordingly.
NOTE: Waiting for the cache to be updated helps in preventing test flakes due to the cache sync delays.
func (*Environment) CreateKubeconfigSecret ¶
func (e *Environment) CreateKubeconfigSecret( ctx context.Context, cluster *clusterv1.Cluster, ) error
CreateKubeconfigSecret generates a new Kubeconfig secret from the envtest config.
func (*Environment) CreateNamespace ¶
func (e *Environment) CreateNamespace( ctx context.Context, generateName string, additionalLabels map[string]string, ) (*corev1.Namespace, error)
CreateNamespace creates a new namespace with a generated name.
func (*Environment) PatchAndWait ¶
func (e *Environment) PatchAndWait( ctx context.Context, obj client.Object, opts ...client.PatchOption, ) error
PatchAndWait creates or updates the given object using server-side apply and waits for the cache to be updated accordingly.
NOTE: Waiting for the cache to be updated helps in preventing test flakes due to the cache sync delays.
type EnvironmentOpt ¶ added in v0.14.1
type EnvironmentOpt func(*environmentOpts)
EnvironmentOption is a functional option for configuring the environment.
func WithPreexistingObjects ¶ added in v0.14.1
func WithPreexistingObjects(objs ...client.Object) EnvironmentOpt
WithPreexistingObjects sets the list of objects that should be created before the test environment is started.
func WithUncachedObjects ¶ added in v0.14.1
func WithUncachedObjects(objs ...client.Object) EnvironmentOpt
WithUncachedObjects sets the list of objects that should not be cached by the controller-runtime client.
type RunInput ¶
type RunInput struct { M *testing.M EnvironmentOpts []EnvironmentOpt SetupReconcilers func(ctx context.Context, mgr ctrl.Manager) SetupEnv func(e *Environment) WebhookInstallOptions envtest.WebhookInstallOptions }
RunInput is the input for Run.