Documentation ¶
Overview ¶
Package kubetest provides functionality to create local Kubernetes test clusters and run tests against them.
Index ¶
- func BuildInlineChart(t *testing.T, name, tmpl, values string) string
- func DeploymentReady(ctx context.Context, c client.Client, namespace, name string) error
- type ClusterConfig
- type Config
- type Environment
- func (e *Environment) Client(cluster string) client.Client
- func (e *Environment) Ctx() context.Context
- func (e *Environment) InstallChartArchive(cluster, name, namespace, path string, args map[string]string)
- func (env *Environment) New(testFn TestFunc) *Fixture
- func (e *Environment) Run(tests ...TestFunc)
- func (e *Environment) Teardown()
- func (e *Environment) Uniq(s string) string
- type Fixture
- func (f *Fixture) ChartAssignmentHasStatus(ca *crcapps.ChartAssignment, expected crcapps.ChartAssignmentPhase) func() error
- func (f *Fixture) Client(cluster string) client.Client
- func (f *Fixture) Ctx() context.Context
- func (f *Fixture) FromYAML(tmpl string, vals, dst interface{})
- func (f *Fixture) ObjectKey(o client.Object) client.ObjectKey
- func (f *Fixture) Uniq(s string) string
- type TestFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildInlineChart ¶
BuildInlineChart creates an inline chart string with the given name, template and values.
Types ¶
type ClusterConfig ¶
type ClusterConfig struct {
Name string
}
type Config ¶
type Config struct { // The clusters that are provisioned for the test environment. Clusters []ClusterConfig // Registration function for additional resource types to a scheme. SchemeFunc func(*k8sruntime.Scheme) error }
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
Environment encapsulates a set of clusters and can run tests against them.
func (*Environment) Client ¶
func (e *Environment) Client(cluster string) client.Client
Client returns a new client for the cluster.
func (*Environment) Ctx ¶
func (e *Environment) Ctx() context.Context
func (*Environment) InstallChartArchive ¶
func (e *Environment) InstallChartArchive(cluster, name, namespace, path string, args map[string]string)
InstallChartArchive installs a Helm chart from a tarball on disk into a cluster. Arguments are provided as a map where the keys are JSON paths.
func (*Environment) New ¶
func (env *Environment) New(testFn TestFunc) *Fixture
New creates a new Fixture for a test function.
func (*Environment) Run ¶
func (e *Environment) Run(tests ...TestFunc)
Run takes a list of TestFuncs and executes them as subtests.
func (*Environment) Teardown ¶
func (e *Environment) Teardown()
Teardown destroys all clusters that were created for the environment.
func (*Environment) Uniq ¶
func (e *Environment) Uniq(s string) string
Uniq takes a string and makes it unique. It should be used to generate collision-free names for namespaces or cluster-wide resources from subtests.
type Fixture ¶
type Fixture struct {
// contains filtered or unexported fields
}
Fixture provides functionality for a single test that is run against an environment.
func (*Fixture) ChartAssignmentHasStatus ¶
func (f *Fixture) ChartAssignmentHasStatus(ca *crcapps.ChartAssignment, expected crcapps.ChartAssignmentPhase) func() error
ChartAssignmentHasStatus returns a condition func that checks if a given ChartAssignment has the expected status. Calls to the condition func update the ChartAssignment in place.
func (*Fixture) FromYAML ¶
FromYAML expands a YAML template with the given vals and unmarshals it into dst. dst is typically of type *unstructured.Unstructured or a fully specified type for a Kubernetes resource.