framework

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2019 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// APIGroup is the group used for CRDs created as part of the test.
	APIGroup = "test.metacontroller.app"
	// APIVersion is the group-version used for CRDs created as part of the test.
	APIVersion = APIGroup + "/v1"
)

Variables

This section is empty.

Functions

func ApiserverConfig

func ApiserverConfig() *rest.Config

ApiserverConfig returns a rest.Config to connect to the test instance.

func ApiserverURL

func ApiserverURL() string

ApiserverURL returns the URL of the kube-apiserver instance started by TestMain.

func TestMain

func TestMain(tests func() int)

TestMain starts etcd, kube-apiserver, and metacontroller before running tests.

func UnstructuredCRD

UnstructuredCRD creates a new Unstructured object for the given CRD.

func UnstructuredJSON

func UnstructuredJSON(apiVersion, kind, name, jsonStr string) *unstructured.Unstructured

UnstructuredJSON creates a new Unstructured object from the given JSON. It panics on a decode error because it's meant for use with hard-coded test data.

Types

type Fixture

type Fixture struct {
	// contains filtered or unexported fields
}

Fixture is a collection of scaffolding for each integration test method.

func NewFixture

func NewFixture(t *testing.T) *Fixture

func (*Fixture) Clientset

func (f *Fixture) Clientset() kubernetes.Interface

Clientset returns the Kubernetes clientset.

func (*Fixture) CreateCRD

CreateCRD generates a quick-and-dirty CRD for use in tests, and installs it in the test environment's API server.

func (*Fixture) CreateCompositeController

func (f *Fixture) CreateCompositeController(name, syncHookURL string, parentRule, childRule *v1alpha1.ResourceRule) *v1alpha1.CompositeController

CreateCompositeController generates a test CompositeController and installs it in the test API server.

func (*Fixture) CreateDecoratorController

func (f *Fixture) CreateDecoratorController(name, syncHookURL string, parentRule, childRule *v1alpha1.ResourceRule) *v1alpha1.DecoratorController

CreateDecoratorController generates a test DecoratorController and installs it in the test API server.

func (*Fixture) CreateNamespace

func (f *Fixture) CreateNamespace(namespace string) *v1.Namespace

CreateNamespace creates a namespace that will be deleted after this test finishes.

func (*Fixture) ServeWebhook

func (f *Fixture) ServeWebhook(handler func(request []byte) (response []byte, err error)) *httptest.Server

ServeWebhook is a helper for quickly creating a webhook server in tests.

func (*Fixture) TearDown

func (f *Fixture) TearDown()

TearDown cleans up resources created through this instance of the test fixture.

func (*Fixture) Wait

func (f *Fixture) Wait(condition func() (bool, error)) error

Wait polls the condition until it's true, with a default interval and timeout. This is meant for use in integration tests, so frequent polling is fine.

The condition function returns a bool indicating whether it is satisfied, as well as an error which should be non-nil if and only if the function was unable to determine whether or not the condition is satisfied (for example if the check involves calling a remote server and the request failed).

If the condition function returns a non-nil error, Wait will log the error and continue retrying until the timeout.

Jump to

Keyboard shortcuts

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