Documentation ¶
Overview ¶
Package envtest contains the test environment to run integration tests.
Index ¶
- 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) (*corev1.Namespace, error)
- func (e *Environment) Start(ctx context.Context) error
- func (e *Environment) Stop() error
- func (e *Environment) WaitForWebhooks()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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 New ¶
func New(uncachedObjs ...client.Object) *Environment
New creates a new environment spinning up a local api-server.
This function should be called only once for each package you're running tests within, usually the environment is initialized in a suite_test.go file within a `BeforeSuite` ginkgo block.
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 ¶
CreateKubeconfigSecret generates a new Kubeconfig secret from the envtest config.
func (*Environment) CreateNamespace ¶
func (e *Environment) CreateNamespace(ctx context.Context, generateName string) (*corev1.Namespace, error)
CreateNamespace creates a new namespace with a generated name.
func (*Environment) Start ¶
func (e *Environment) Start(ctx context.Context) error
Start starts the manager.
func (*Environment) WaitForWebhooks ¶
func (e *Environment) WaitForWebhooks()
WaitForWebhooks waits for the webhook server to be available.