test

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProjRootFlag          = "root"
	KubeConfigFlag        = "kubeconfig"
	NamespacedManPathFlag = "namespacedMan"
	GlobalManPathFlag     = "globalMan"
	SingleNamespaceFlag   = "singleNamespace"
	TestNamespaceEnv      = "TEST_NAMESPACE"
	LocalOperatorFlag     = "localOperator"
)

Variables

This section is empty.

Functions

func AddToFrameworkScheme

func AddToFrameworkScheme(addToScheme addToSchemeFunc, obj runtime.Object) error

AddToFrameworkScheme allows users to add the scheme for their custom resources to the framework's scheme for use with the dynamic client. The user provides the addToScheme function (located in the register.go file of their operator project) and the List struct for their custom resource. For example, for a memcached operator, the list stuct may look like:

&MemcachedList{
	TypeMeta: metav1.TypeMeta{
		Kind: "Memcached",
		APIVersion: "cache.example.com/v1alpha1",
		},
	}

The List object is needed because the CRD has not always been fully registered by the time this function is called. If the CRD takes more than 5 seconds to become ready, this function throws an error

func MainEntry

func MainEntry(m *testing.M)

Types

type CleanupOptions added in v0.0.7

type CleanupOptions struct {
	TestContext   *TestCtx
	Timeout       time.Duration
	RetryInterval time.Duration
}

type Framework

type Framework struct {
	Client            *frameworkClient
	KubeConfig        *rest.Config
	KubeClient        kubernetes.Interface
	Scheme            *runtime.Scheme
	NamespacedManPath *string
	Namespace         string
	LocalOperator     bool
}
var (
	// Global framework struct
	Global *Framework
)

type FrameworkClient added in v0.0.7

type FrameworkClient interface {
	Get(gCtx goctx.Context, key dynclient.ObjectKey, obj runtime.Object) error
	List(gCtx goctx.Context, opts *dynclient.ListOptions, list runtime.Object) error
	Create(gCtx goctx.Context, obj runtime.Object, cleanupOptions *CleanupOptions) error
	Delete(gCtx goctx.Context, obj runtime.Object, opts ...dynclient.DeleteOptionFunc) error
	Update(gCtx goctx.Context, obj runtime.Object) error
}

type TestCtx

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

func NewTestCtx

func NewTestCtx(t *testing.T) *TestCtx

func (*TestCtx) AddCleanupFn added in v0.0.7

func (ctx *TestCtx) AddCleanupFn(fn cleanupFn)

func (*TestCtx) Cleanup

func (ctx *TestCtx) Cleanup()

func (*TestCtx) CleanupNoT

func (ctx *TestCtx) CleanupNoT()

CleanupNoT is a modified version of Cleanup; does not use t for logging, instead uses log intended for use by MainEntry, which does not have a testing.T

func (*TestCtx) GetID

func (ctx *TestCtx) GetID() string

func (*TestCtx) GetNamespace

func (ctx *TestCtx) GetNamespace() (string, error)

func (*TestCtx) InitializeClusterResources

func (ctx *TestCtx) InitializeClusterResources(cleanupOptions *CleanupOptions) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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