Documentation ¶
Index ¶
- func Assert(namespace string, timeout int, assertFiles ...string) error
- func Client(_ bool) (client.Client, error)
- func DiscoveryClient() (discovery.DiscoveryInterface, error)
- func Errors(namespace string, timeout int, errorFiles ...string) error
- func IsMinVersion(ver string) bool
- func ObjectsFromPath(path, dir string) ([]client.Object, error)
- func SetFlags(flags *pflag.FlagSet)
- type Case
- func (t *Case) CollectEvents(namespace string)
- func (t *Case) CollectTestStepFiles() (map[int64][]string, error)
- func (t *Case) CreateNamespace(test *testing.T, cl client.Client, ns *namespace) error
- func (t *Case) DeleteNamespace(cl client.Client, ns *namespace) error
- func (t *Case) LoadTestSteps() error
- func (t *Case) NamespaceExists(namespace string) (bool, error)
- func (t *Case) Run(test *testing.T, ts *report.Testsuite)
- type Harness
- func (h *Harness) Client(forceNew bool) (client.Client, error)
- func (h *Harness) Config() (*rest.Config, error)
- func (h *Harness) DiscoveryClient() (discovery.DiscoveryInterface, error)
- func (h *Harness) DockerClient() (testutils.DockerClient, error)
- func (h *Harness) GetLogger() testutils.Logger
- func (h *Harness) GetTimeout() int
- func (h *Harness) LoadTests(dir string) ([]*Case, error)
- func (h *Harness) Report()
- func (h *Harness) Run()
- func (h *Harness) RunKIND() (*rest.Config, error)
- func (h *Harness) RunTestEnv() (*rest.Config, error)
- func (h *Harness) RunTests()
- func (h *Harness) Setup()
- func (h *Harness) Stop()
- type Step
- func (s *Step) Check(namespace string, timeout int) []error
- func (s *Step) CheckAssertCommands(ctx context.Context, namespace string, commands []harness.TestAssertCommand, ...) []error
- func (s *Step) CheckResource(expected runtime.Object, namespace string) []error
- func (s *Step) CheckResourceAbsent(expected runtime.Object, namespace string) error
- func (s *Step) Clean(namespace string) error
- func (s *Step) Create(test *testing.T, namespace string) []error
- func (s *Step) DeleteExisting(namespace string) error
- func (s *Step) GetTimeout() int
- func (s *Step) LoadYAML(file string) error
- func (s *Step) Run(test *testing.T, namespace string) []error
- func (s *Step) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Assert ¶
Assert checks all provided assert files against a namespace. Upon assert failure, it prints the failures and returns an error
func DiscoveryClient ¶
func DiscoveryClient() (discovery.DiscoveryInterface, error)
func Errors ¶
Errors checks all provided errors files against a namespace. Upon assert failure, it prints the failures and returns an error
func IsMinVersion ¶
IsMinVersion checks if pass ver is the min required kind version
func ObjectsFromPath ¶
ObjectsFromPath returns an array of runtime.Objects for files / urls provided
Types ¶
type Case ¶
type Case struct { Steps []*Step Name string Dir string SkipDelete bool Timeout int PreferredNamespace string RunLabels labels.Set Client func(forceNew bool) (client.Client, error) DiscoveryClient func() (discovery.DiscoveryInterface, error) Logger testutils.Logger // Suppress is used to suppress logs Suppress []string }
Case contains all of the test steps and the Kubernetes client and other global configuration for a test.
func (*Case) CollectEvents ¶
CollectEvents gathers all events from namespace and prints it out to log
func (*Case) CollectTestStepFiles ¶
CollectTestStepFiles collects a map of test steps and their associated files from a directory.
func (*Case) CreateNamespace ¶
CreateNamespace creates a namespace in Kubernetes to use for a test.
func (*Case) DeleteNamespace ¶
DeleteNamespace deletes a namespace in Kubernetes after we are done using it.
func (*Case) LoadTestSteps ¶
LoadTestSteps loads all of the test steps for a test case.
func (*Case) NamespaceExists ¶
NamespaceExists gets namespace and returns true if it exists
type Harness ¶
type Harness struct { TestSuite harness.TestSuite T *testing.T RunLabels labels.Set // contains filtered or unexported fields }
Harness loads and runs tests based on the configuration provided.
func (*Harness) Config ¶
Config returns the current Kubernetes configuration - either from the environment or from the created temporary control plane. As a side effect, on first successful call this method also writes a kubernetes client config file in YAML format to a file called "kubeconfig" in the current directory.
func (*Harness) DiscoveryClient ¶
func (h *Harness) DiscoveryClient() (discovery.DiscoveryInterface, error)
DiscoveryClient returns the current Kubernetes discovery client for the test harness.
func (*Harness) DockerClient ¶
func (h *Harness) DockerClient() (testutils.DockerClient, error)
DockerClient returns the Docker client to use for the test harness.
func (*Harness) GetTimeout ¶
GetTimeout returns the configured timeout for the test suite.
func (*Harness) Report ¶
func (h *Harness) Report()
Report defines the report phase of the kuttl tests. If report format is nil it is skipped. otherwise it will provide a json or xml format report of tests in a junit format.
func (*Harness) Run ¶
func (h *Harness) Run()
Run the test harness - start the control plane and then run the tests.
func (*Harness) RunTestEnv ¶
RunTestEnv starts a Kubernetes API server and etcd server for use in the tests and returns the Kubernetes configuration.
func (*Harness) RunTests ¶
func (h *Harness) RunTests()
RunTests should be called from within a Go test (t) and launches all of the KUTTL integration tests at dir.
type Step ¶
type Step struct { Name string Index int SkipDelete bool Dir string TestRunLabels labels.Set Step *harness.TestStep Assert *harness.TestAssert Asserts []client.Object Apply []client.Object Errors []client.Object Timeout int Kubeconfig string KubeconfigLoading string Context string Client func(forceNew bool) (client.Client, error) DiscoveryClient func() (discovery.DiscoveryInterface, error) Logger testutils.Logger }
A Step contains the name of the test step, its index in the test, and all of the test step's settings (including objects to apply and assert on).
func (*Step) Check ¶
Check checks if the resources defined in Asserts and Errors are in the correct state.
func (*Step) CheckAssertCommands ¶
func (s *Step) CheckAssertCommands(ctx context.Context, namespace string, commands []harness.TestAssertCommand, timeout int) []error
CheckAssertCommands Runs the commands provided in `commands` and check if have been run successfully. the errors returned can be a a failure of executing the command or the failure of the command executed.
func (*Step) CheckResource ¶
CheckResource checks if the expected resource's state in Kubernetes is correct.
func (*Step) CheckResourceAbsent ¶
CheckResourceAbsent checks if the expected resource's state is absent in Kubernetes.
func (*Step) DeleteExisting ¶
DeleteExisting deletes any resources in the TestStep.Delete list prior to running the tests.
func (*Step) GetTimeout ¶
GetTimeout gets the timeout defined for the test step.
func (*Step) LoadYAML ¶
LoadYAML loads the resources from a YAML file for a test step:
- If the YAML file is called "assert", then it contains objects to add to the test step's list of assertions.
- If the YAML file is called "errors", then it contains objects that, if seen, mark a test immediately failed.
- All other YAML files are considered resources to create.