test

package
v0.8.0-pre.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2019 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Case

type Case struct {
	Steps      []*Step
	Name       string
	Dir        string
	SkipDelete bool
	Timeout    int

	Client          func(forceNew bool) (client.Client, error)
	DiscoveryClient func() (discovery.DiscoveryInterface, error)

	Logger testutils.Logger
}

Case contains all of the test steps and the Kubernetes client and other global configuration for a test.

func (*Case) CollectEvents added in v0.7.0

func (t *Case) CollectEvents(namespace string)

CollectEvents gathers all events from namespace and prints it out to log

func (*Case) CollectTestStepFiles

func (t *Case) CollectTestStepFiles() (map[int64][]string, error)

CollectTestStepFiles collects a map of test steps and their associated files from a directory.

func (*Case) CreateNamespace

func (t *Case) CreateNamespace(namespace string) error

CreateNamespace creates a namespace in Kubernetes to use for a test.

func (*Case) DeleteNamespace

func (t *Case) DeleteNamespace(namespace string) error

DeleteNamespace deletes a namespace in Kubernetes after we are done using it.

func (*Case) LoadTestSteps

func (t *Case) LoadTestSteps() error

LoadTestSteps loads all of the test steps for a test case.

func (*Case) Run added in v0.5.0

func (t *Case) Run(test *testing.T)

Run runs a test case including all of its steps.

type Harness

type Harness struct {
	TestSuite kudo.TestSuite
	T         *testing.T
	// contains filtered or unexported fields
}

Harness loads and runs tests based on the configuration provided.

func (*Harness) Client

func (h *Harness) Client(forceNew bool) (client.Client, error)

Client returns the current Kubernetes client for the test harness.

func (*Harness) Config

func (h *Harness) Config() (*rest.Config, error)

Config returns the current Kubernetes configuration - either from the environment or from the created temporary control plane.

func (*Harness) DiscoveryClient

func (h *Harness) DiscoveryClient() (discovery.DiscoveryInterface, error)

DiscoveryClient returns the current Kubernetes discovery client for the test harness.

func (*Harness) DockerClient added in v0.7.0

func (h *Harness) DockerClient() (testutils.DockerClient, error)

DockerClient returns the Docker client to use for the test harness.

func (*Harness) GetLogger added in v0.5.0

func (h *Harness) GetLogger() testutils.Logger

GetLogger returns an initialized test logger.

func (*Harness) GetTimeout added in v0.4.0

func (h *Harness) GetTimeout() int

GetTimeout returns the configured timeout for the test suite.

func (*Harness) LoadTests

func (h *Harness) LoadTests(dir string) ([]*Case, error)

LoadTests loads all of the tests in a given directory.

func (*Harness) Run

func (h *Harness) Run()

Run the test harness - start KUDO and the control plane and install the operators, if necessary and then run the tests.

func (*Harness) RunKIND added in v0.4.0

func (h *Harness) RunKIND() (*rest.Config, error)

RunKIND starts a KIND cluster.

func (*Harness) RunKUDO

func (h *Harness) RunKUDO() error

RunKUDO starts the KUDO controllers and installs the required CRDs.

func (*Harness) RunTestEnv

func (h *Harness) RunTestEnv() (*rest.Config, error)

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 KUDO integration tests at dir.

func (*Harness) Stop

func (h *Harness) Stop()

Stop the test environment and KUDO, clean up the harness.

type Step

type Step struct {
	Name  string
	Index int

	Dir string

	Step   *kudo.TestStep
	Assert *kudo.TestAssert

	Asserts []runtime.Object
	Apply   []runtime.Object
	Errors  []runtime.Object

	Timeout int

	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

func (s *Step) Check(namespace string) []error

Check checks if the resources defined in Asserts and Errors are in the correct state.

func (*Step) CheckResource

func (s *Step) CheckResource(expected runtime.Object, namespace string) []error

CheckResource checks if the expected resource's state in Kubernetes is correct.

func (*Step) CheckResourceAbsent added in v0.7.0

func (s *Step) CheckResourceAbsent(expected runtime.Object, namespace string) error

CheckResourceAbsent checks if the expected resource's state is absent in Kubernetes.

func (*Step) Clean

func (s *Step) Clean(namespace string) error

Clean deletes all resources defined in the Apply list.

func (*Step) Create

func (s *Step) Create(namespace string) []error

Create applies all resources defined in the Apply list.

func (*Step) DeleteExisting added in v0.4.0

func (s *Step) DeleteExisting(namespace string) error

DeleteExisting deletes any resources in the TestStep.Delete list prior to running the tests.

func (*Step) GetTimeout

func (s *Step) GetTimeout() int

GetTimeout gets the timeout defined for the test step.

func (*Step) LoadYAML

func (s *Step) LoadYAML(file string) error

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.

func (*Step) Run

func (s *Step) Run(namespace string) []error

Run runs a KUDO test step: 1. Apply all desired objects to Kubernetes. 2. Wait for all of the states defined in the test step's asserts to be true.'

func (*Step) String

func (s *Step) String() string

String implements the string interface, returning the name of the test step.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL