Documentation ¶
Index ¶
- Constants
- func ApiserverConfig() *rest.Config
- func ApiserverURL() string
- func CRDResourceRule(crd *apiextensions.CustomResourceDefinition) *v1alpha1.ResourceRule
- func TestMain(tests func() int)
- func UnstructuredCRD(crd *v1beta1.CustomResourceDefinition, name string) *unstructured.Unstructured
- func UnstructuredJSON(apiVersion, kind, name, jsonStr string) *unstructured.Unstructured
- type Fixture
- func (f *Fixture) Clientset() kubernetes.Interface
- func (f *Fixture) CreateCRD(kind string, scope v1beta1.ResourceScope) (*v1beta1.CustomResourceDefinition, *dynamicclientset.ResourceClient)
- func (f *Fixture) CreateCompositeController(name, syncHookURL string, parentRule, childRule *v1alpha1.ResourceRule) *v1alpha1.CompositeController
- func (f *Fixture) CreateDecoratorController(name, syncHookURL string, parentRule, childRule *v1alpha1.ResourceRule) *v1alpha1.DecoratorController
- func (f *Fixture) CreateNamespace(namespace string) *v1.Namespace
- func (f *Fixture) ServeWebhook(handler func(request []byte) (response []byte, err error)) *httptest.Server
- func (f *Fixture) TearDown()
- func (f *Fixture) Wait(condition func() (bool, error)) error
Constants ¶
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 ¶
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 CRDResourceRule ¶
func CRDResourceRule(crd *apiextensions.CustomResourceDefinition) *v1alpha1.ResourceRule
func TestMain ¶
func TestMain(tests func() int)
TestMain starts etcd, kube-apiserver, and metacontroller before running tests.
func UnstructuredCRD ¶
func UnstructuredCRD(crd *v1beta1.CustomResourceDefinition, name string) *unstructured.Unstructured
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 (*Fixture) Clientset ¶
func (f *Fixture) Clientset() kubernetes.Interface
Clientset returns the Kubernetes clientset.
func (*Fixture) CreateCRD ¶
func (f *Fixture) CreateCRD(kind string, scope v1beta1.ResourceScope) (*v1beta1.CustomResourceDefinition, *dynamicclientset.ResourceClient)
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 ¶
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 ¶
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.