test

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2019 License: Apache-2.0 Imports: 27 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

	Client          client.Client
	DiscoveryClient discovery.DiscoveryInterface
	Logger          testutils.Logger
}

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

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) TestCaseFactory

func (t *Case) TestCaseFactory() func(*testing.T)

TestCaseFactory creates a new Go test that runs a set of test 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) 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) 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

	Step   *kudo.TestStep
	Assert *kudo.TestAssert

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

	DiscoveryClient discovery.DiscoveryInterface
	Client          client.Client
	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 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) 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) 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