framework

package
v0.0.0-...-4d19ac6 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2023 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultNamespaceDeletionTimeout is timeout duration for waiting for a namespace deletion.
	DefaultNamespaceDeletionTimeout = 10 * time.Minute
)
View Source
const (
	// Poll is how often to Poll pods, nodes and claims.
	Poll = 2 * time.Second
)

Variables

View Source
var Logf = e2elog.Logf
View Source
var RunID = uuid.NewUUID()

RunID is a unique identifier of the e2e run. Beware that this ID is not the same for all tests in the e2e run, because each Ginkgo node creates it separately.

Functions

func AfterReadingAllFlags

func AfterReadingAllFlags(t *TestContextType)

AfterReadingAllFlags makes changes to the context after all flags have been read.

func CreateTestingNS

func CreateTestingNS(baseName string, c clientset.Interface, labels map[string]string) (*corev1.Namespace, error)

CreateTestingNS should be used by every test, note that we append a common prefix to the provided test name. Please see NewFramework instead of using this directly.

func DumpAllNamespaceInfo

func DumpAllNamespaceInfo(c clientset.Interface, namespace string)

DumpAllNamespaceInfo dumps events, pods and nodes information in the given namespace.

func DumpEventsInNamespace

func DumpEventsInNamespace(eventsLister EventsLister, namespace string)

DumpEventsInNamespace dumps events in the given namespace.

func ExpectNoError

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

ExpectNoError checks if "err" is set

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 ExpectNoErrorWithRetries

func ExpectNoErrorWithRetries(fn func() error, maxRetries int, explain ...interface{})

ExpectNoErrorWithRetries checks if "err" is set with retries

func HandleFlags

func HandleFlags()

HandleFlags sets up all flags and parses the command line.

func LoadConfig

func LoadConfig() (*restclient.Config, error)

LoadConfig returns a config for a rest client.

func RandomSuffix

func RandomSuffix() string

RandomSuffix provides a random string to append to pods,services,rcs.

func RegisterClusterFlags

func RegisterClusterFlags(flags *flag.FlagSet)

RegisterClusterFlags registers flags specific to the cluster e2e test suite.

func RegisterCommonFlags

func RegisterCommonFlags(flags *flag.FlagSet)

RegisterCommonFlags registers flags common to all e2e test suites. The flag set can be flag.CommandLine (if desired) or a custom flag set that then gets passed to viperconfig.ViperizeFlags.

The other Register*Flags methods below can be used to add more test-specific flags. However, those settings then get added regardless whether the test is actually in the test suite.

func RemoveCleanupAction

func RemoveCleanupAction(p CleanupActionHandle)

RemoveCleanupAction removes a function that was installed by AddCleanupAction.

func RestclientConfig

func RestclientConfig(kubeContext string) (*clientcmdapi.Config, error)

RestclientConfig returns a config holds the information needed to build connection to kubernetes clusters.

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 VCDescribe

func VCDescribe(text string, body func()) bool

VCDescribe is wrapper function for ginkgo describe. Adds namespacing.

Types

type CleanupActionHandle

type CleanupActionHandle *int

CleanupActionHandle is an integer pointer type for handling cleanup action

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 EventsLister

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

EventsLister is a func that lists events.

type Framework

type Framework struct {
	BaseName string

	// Set together with creating the ClientSet and the namespace.
	// Guaranteed to be unique in the cluster even when running the same
	// test multiple times in parallel.
	UniqueName string

	ClientSet   clientset.Interface
	VCClientSet vcclient.Interface

	DynamicClient dynamic.Interface

	Namespace *corev1.Namespace // Every test has at least one namespace.

	NamespaceDeletionTimeout time.Duration

	// configuration for framework's client
	Options Options
	// contains filtered or unexported fields
}

Framework supports common operations used by e2e tests; it will keep a client & a namespace for you. Eventual goal is to merge this with integration test framework.

func NewDefaultFramework

func NewDefaultFramework(baseName string) *Framework

NewDefaultFramework makes a new framework and sets up a BeforeEach/AfterEach for you (you can write additional before/after each functions).

func NewFramework

func NewFramework(baseName string, options Options, client clientset.Interface) *Framework

NewFramework creates a test framework.

func (*Framework) AddNamespacesToDelete

func (f *Framework) AddNamespacesToDelete(namespaces ...*corev1.Namespace)

AddNamespacesToDelete adds one or more namespaces to be deleted when the test completes.

func (*Framework) AfterEach

func (f *Framework) AfterEach()

AfterEach deletes the namespace, after reading its events.

func (*Framework) BeforeEach

func (f *Framework) BeforeEach()

BeforeEach gets a client and makes a namespace.

func (*Framework) CreateNamespace

func (f *Framework) CreateNamespace(baseName string, labels map[string]string) (*corev1.Namespace, error)

CreateNamespace creates a namespace for e2e testing.

func (*Framework) VCClient

func (f *Framework) VCClient() *VCClient

VCClient is a convenience method for getting a vc client interface in the framework's namespace, possibly applying test-suite specific transformations to the vc spec.

func (*Framework) WaitForVCNotFound

func (f *Framework) WaitForVCNotFound(vcName string) error

WaitForVCNotFound waits for the vc to be deleted in the namespace.

func (*Framework) WaitForVCRunning

func (f *Framework) WaitForVCRunning(vcName string) error

WaitForVCRunning waits for the vc to run in the namespace.

type Options

type Options struct {
	ClientQPS    float32
	ClientBurst  int
	GroupVersion *schema.GroupVersion
}

Options is a struct for managing test framework options.

type TestContextType

type TestContextType struct {
	KubeConfig  string
	KubeContext string
	Host        string

	ReportDir    string
	ReportPrefix string

	DeleteNamespace          bool
	DeleteNamespaceOnFailure bool

	// If set to true test will dump data about the namespace in which test was running.
	DumpLogsOnFailure bool
}

TestContextType contains test settings and global state.

var TestContext TestContextType

TestContext should be used by all tests to access common context data.

type VCClient

type VCClient struct {
	Interface clientset.Interface
	tenancyv1alpha1.VirtualClusterInterface
	// contains filtered or unexported fields
}

VCClient is a struct for vc client.

func (*VCClient) CreateSync

CreateSync creates a new vc according to the framework specifications, and wait for it to start.

func (*VCClient) DeleteSync

func (c *VCClient) DeleteSync(name string, options *metav1.DeleteOptions)

DeleteSync deletes the vc and wait for the vc to disappear.

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