framework

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2022 License: Apache-2.0 Imports: 41 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Using the same interval as integration should be fine given the
	// minimal load that the apiserver is likely to be under.
	PollInterval = 50 * time.Millisecond
	// How long to try single API calls (like 'get' or 'list'). Used to prevent
	// transient failures from failing tests.
	DefaultSingleCallTimeout = 30 * time.Second
)

Variables

View Source
var RunID = uuid.NewUUID()

RunID is unique identifier of the e2e run.

Functions

func CreateNamespace added in v0.3.0

func CreateNamespace(client kubeclientset.Interface, generateName string) (string, error)

func CreateTestNamespace added in v0.3.0

func CreateTestNamespace(client kubeclientset.Interface, baseName string) string

func DeleteNamespace added in v0.3.0

func DeleteNamespace(client kubeclientset.Interface, namespaceName string)

func DumpEventsInNamespace

func DumpEventsInNamespace(eventsLister EventsLister, namespace string)

func Errorf

func Errorf(format string, args ...interface{})

func ExpectNoError

func ExpectNoError(err error, explain ...interface{})

func ExpectNoErrorWithOffset

func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{})

ExpectNoErrorWithOffset checks if "err" is set, and if so, fails assertion while logging the error at "offset" levels above its caller (for example, for call chain f -> g -> ExpectNoErrorWithOffset(1, ...) error would be logged for "f").

func Failf

func Failf(format string, args ...interface{})

func FailfWithOffset

func FailfWithOffset(offset int, format string, args ...interface{})

FailfWithOffset calls "Fail" and logs the error at "offset" levels above its caller (for example, for call chain f -> g -> FailfWithOffset(1, ...) error would be logged for "f").

func ListKubeFedClusters added in v0.3.0

func ListKubeFedClusters(tl common.TestLogger, client genericclient.Client, namespace string) *fedv1b1.KubeFedClusterList

func LoadEnableTypeDirectives added in v0.0.8

func LoadEnableTypeDirectives(tl common.TestLogger) []*kfenable.EnableTypeDirective

func Logf

func Logf(format string, args ...interface{})

func NewE2ELogger

func NewE2ELogger() common.TestLogger

func ParseFlags

func ParseFlags()

func RemoveCleanupAction

func RemoveCleanupAction(p CleanupActionHandle)

RemoveCleanupAction removes a function that was installed by AddCleanupAction.

func RunCleanupActions

func RunCleanupActions()

RunCleanupActions runs all functions installed by AddCleanupAction. It does not remove them (see RemoveCleanupAction) but it does run unlocked, so they may remove themselves.

func SetUpControlPlane added in v0.3.0

func SetUpControlPlane()

func SetUpFeatureGates added in v0.5.0

func SetUpFeatureGates()

func Skipf

func Skipf(format string, args ...interface{})

func StartControllerManager added in v0.3.0

func StartControllerManager(args []string) (*exec.Cmd, io.ReadCloser, error)

func TearDownControlPlane added in v0.3.0

func TearDownControlPlane()

func WaitForClusterReadiness added in v0.0.8

func WaitForClusterReadiness(tl common.TestLogger, client genericclient.Client,
	namespace string, interval, timeout time.Duration)

func WaitForObject added in v0.3.0

func WaitForObject(tl common.TestLogger, namespace, name string, objectGetter func(namespace, name string) (runtimeclient.Object, error), desired runtimeclient.Object, equivalent func(actual, desired runtimeclient.Object) bool)

WaitForObject waits for object to match the desired status.

func WaitForUnmanagedClusterReadiness added in v0.0.2

func WaitForUnmanagedClusterReadiness()

func WaitUntilLogStreamContains added in v0.3.0

func WaitUntilLogStreamContains(tl common.TestLogger, stream io.ReadCloser, substr string) bool

WaitUntilLogStreamContains waits for the given stream to contain the substring until the end of the stream or timeout.

Types

type CleanupActionHandle

type CleanupActionHandle *int

func AddCleanupAction

func AddCleanupAction(fn func()) CleanupActionHandle

AddCleanupAction installs a function that will be called in the event of the whole test being terminated. This allows arbitrary pieces of the overall test to hook into SynchronizedAfterSuite().

type ControllerFixture added in v0.0.8

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

ControllerFixture manages a KubeFed controller for testing.

func NewClusterControllerFixture added in v0.0.8

func NewClusterControllerFixture(tl common.TestLogger, config *util.ControllerConfig) *ControllerFixture

NewClusterControllerFixture initializes a new cluster controller fixture.

func NewFederatedTypeConfigControllerFixture added in v0.0.10

func NewFederatedTypeConfigControllerFixture(tl common.TestLogger, config *util.ControllerConfig) *ControllerFixture

NewFederatedTypeConfigControllerFixure initializes a new federatedtypeconfig controller fixure.

func NewSchedulingManagerFixture added in v0.0.8

func NewSchedulingManagerFixture(tl common.TestLogger, config *util.ControllerConfig) (*ControllerFixture, *schedulingmanager.SchedulingManager)

func NewSyncControllerFixture added in v0.0.8

func NewSyncControllerFixture(tl common.TestLogger, controllerConfig *util.ControllerConfig, typeConfig typeconfig.Interface, namespacePlacement *metav1.APIResource) *ControllerFixture

NewSyncControllerFixture initializes a new sync controller fixture.

func (*ControllerFixture) TearDown added in v0.0.8

func (f *ControllerFixture) TearDown(tl common.TestLogger)

type EventsLister

type EventsLister func(opts metav1.ListOptions, ns string) (*corev1.EventList, error)

type KubeFedFramework added in v0.3.0

type KubeFedFramework interface {
	KubeFedFrameworkImpl

	// Registering a fixture ensures it will be torn down after the
	// current test has executed.
	RegisterFixture(fixture TestFixture)

	// Setup a sync controller if necessary and return the fixture.
	// This is implemented commonly to support running a sync
	// controller for tests that require it.
	SetUpSyncControllerFixture(typeConfig typeconfig.Interface) TestFixture

	// Ensure propagation of the test namespace to member clusters
	EnsureTestNamespacePropagation()

	// Ensure a federated namespace resource for the test namespace
	// exists so that the namespace will be propagated to either all
	// or no member clusters.
	EnsureTestFederatedNamespace(allClusters bool) *unstructured.Unstructured
}

KubeFedFramework provides an interface to a test control plane so that the implementation can vary without affecting tests.

func NewKubeFedFramework added in v0.3.0

func NewKubeFedFramework(baseName string) KubeFedFramework

type KubeFedFrameworkImpl added in v0.3.0

type KubeFedFrameworkImpl interface {
	BeforeEach()
	AfterEach()

	ControllerConfig() *util.ControllerConfig

	Logger() common.TestLogger

	KubeConfig() *restclient.Config

	KubeClient(userAgent string) kubeclientset.Interface
	Client(userAgent string) genericclient.Client

	ClusterConfigs(userAgent string) map[string]common.TestClusterConfig
	HostConfig(userAgent string) *restclient.Config
	ClusterDynamicClients(apiResource *metav1.APIResource, userAgent string) map[string]common.TestCluster
	ClusterKubeClients(userAgent string) map[string]kubeclientset.Interface
	ClusterNames(userAgent string) []string

	KubeFedSystemNamespace() string

	// Name of the namespace for the current test to target
	TestNamespaceName() string
	// contains filtered or unexported methods
}

func NewUnmanagedFramework

func NewUnmanagedFramework(baseName string) KubeFedFrameworkImpl

type TestContextType

type TestContextType struct {
	InMemoryControllers             bool
	KubeConfig                      string
	KubeContext                     string
	KubeFedSystemNamespace          string
	SingleCallTimeout               time.Duration
	LimitedScope                    bool
	LimitedScopeInMemoryControllers bool
	WaitForFinalization             bool
	ScaleTest                       bool
	ScaleClusterCount               int
	SimulateFederation              bool
}
var TestContext *TestContextType = &TestContextType{}

func (*TestContextType) NamespaceScopedControlPlane added in v0.3.0

func (t *TestContextType) NamespaceScopedControlPlane() bool

NamespaceScopedControlPlane indicates that the control plane is effectively namespace-scoped. This may be either because in-memory controllers are running namespace-scoped against a cluster-scoped deployment (a debugging optimization) or if a deployed control plane is running namespace-scoped.

func (*TestContextType) RunControllers added in v0.0.3

func (t *TestContextType) RunControllers() bool

type TestFixture added in v0.0.8

type TestFixture interface {
	TearDown(tl common.TestLogger)
}

SetUp is likely to be fixture-specific, but TearDown needs to be consistent to enable TearDownOnPanic.

type UnmanagedFramework

type UnmanagedFramework struct {
	Config     *restclient.Config
	Kubeconfig *clientcmdapi.Config

	BaseName string
	// contains filtered or unexported fields
}

func (*UnmanagedFramework) AfterEach

func (f *UnmanagedFramework) AfterEach()

AfterEach deletes the namespace, after reading its events.

func (*UnmanagedFramework) BeforeEach

func (f *UnmanagedFramework) BeforeEach()

BeforeEach reads the cluster configuration if it has not yet been read.

func (*UnmanagedFramework) Client added in v0.0.7

func (f *UnmanagedFramework) Client(userAgent string) genericclient.Client

func (*UnmanagedFramework) ClusterConfigs

func (f *UnmanagedFramework) ClusterConfigs(userAgent string) map[string]common.TestClusterConfig

func (*UnmanagedFramework) ClusterDynamicClients

func (f *UnmanagedFramework) ClusterDynamicClients(apiResource *metav1.APIResource, userAgent string) map[string]common.TestCluster

func (*UnmanagedFramework) ClusterKubeClients

func (f *UnmanagedFramework) ClusterKubeClients(userAgent string) map[string]kubeclientset.Interface

func (*UnmanagedFramework) ClusterNames added in v0.0.2

func (f *UnmanagedFramework) ClusterNames(userAgent string) []string

func (*UnmanagedFramework) ControllerConfig added in v0.0.3

func (f *UnmanagedFramework) ControllerConfig() *util.ControllerConfig

func (*UnmanagedFramework) HostConfig added in v0.3.0

func (f *UnmanagedFramework) HostConfig(userAgent string) *restclient.Config

func (*UnmanagedFramework) KubeClient

func (f *UnmanagedFramework) KubeClient(userAgent string) kubeclientset.Interface

func (*UnmanagedFramework) KubeConfig

func (f *UnmanagedFramework) KubeConfig() *restclient.Config

func (*UnmanagedFramework) KubeFedSystemNamespace added in v0.3.0

func (f *UnmanagedFramework) KubeFedSystemNamespace() string

func (*UnmanagedFramework) Logger added in v0.0.3

func (f *UnmanagedFramework) Logger() common.TestLogger

func (*UnmanagedFramework) TestNamespaceName

func (f *UnmanagedFramework) TestNamespaceName() string

Directories

Path Synopsis
Package ginkgowrapper wraps Ginkgo Fail and Skip functions to panic with structured data instead of a constant string.
Package ginkgowrapper wraps Ginkgo Fail and Skip functions to panic with structured data instead of a constant string.

Jump to

Keyboard shortcuts

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