Documentation ¶
Index ¶
- type Case
- 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) LoadTests(dir string) ([]*Case, error)
- func (h *Harness) Run()
- func (h *Harness) RunKUDO() error
- func (h *Harness) RunTestEnv() (*rest.Config, error)
- func (h *Harness) RunTests()
- func (h *Harness) Stop()
- type Step
- func (s *Step) Check(namespace string) []error
- func (s *Step) CheckResource(expected runtime.Object, namespace string) []error
- func (s *Step) Clean(namespace string) error
- func (s *Step) Create(namespace string) []error
- func (s *Step) GetTimeout() int
- func (s *Step) LoadYAML(file string) error
- func (s *Step) Run(namespace string) []error
- func (s *Step) String() string
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 ¶
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) TestCaseFactory ¶
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) Config ¶
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) 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) RunTestEnv ¶
RunTestEnv starts a Kubernetes API server and etcd server for use in the tests and returns the Kubernetes configuration.
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) CheckResource ¶
CheckResource checks if the expected resource's state in Kubernetes is correct.
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.