framework

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PodListTimeout indicates how long to wait for the pod to be listable
	PodListTimeout = time.Minute
	// PodStartTimeout indicates that initial pod start can be delayed O(minutes) by slow docker pulls
	// TODO: Make this 30 seconds once #4566 is resolved.
	PodStartTimeout = 5 * time.Minute

	// PodStartShortTimeout is same as `PodStartTimeout` to wait for the pod to be started, but shorter.
	// Use it case by case when we are sure pod start will not be delayed
	// minutes by slow docker pulls or something else.
	PodStartShortTimeout = 2 * time.Minute

	// PodDeleteTimeout indicates how long to wait for a pod to be deleted
	PodDeleteTimeout = 5 * time.Minute

	// PodEventTimeout is how much we wait for a pod event to occur.
	PodEventTimeout = 2 * time.Minute

	// NamespaceCleanupTimeout indicates:
	// If there are any orphaned namespaces to clean up, this test is running
	// on a long lived cluster. A long wait here is preferably to spurious test
	// failures caused by leaked resources from a previous test run.
	NamespaceCleanupTimeout = 15 * time.Minute

	// ServiceStartTimeout indicates how long to wait for a service endpoint to be resolvable.
	ServiceStartTimeout = 3 * time.Minute

	// Poll indicates how often to Poll pods, nodes and claims.
	Poll = 2 * time.Second

	// ServiceAccountProvisionTimeout indicates a service account provision timeout.
	// service accounts are provisioned after namespace creation
	// a service account is required to support pod creation in a namespace as part of admission control
	ServiceAccountProvisionTimeout = 2 * time.Minute

	// SingleCallTimeout indicates how long to try single API calls (like 'get' or 'list'). Used to prevent
	// transient failures from failing tests.
	// TODO: client should not apply this timeout to Watch calls. Increased from 30s until that is fixed.
	SingleCallTimeout = 5 * time.Minute

	// NodeReadyInitialTimeout indicates how long nodes have to be "ready" when a test begins. They should already
	// be "ready" before the test starts, so this is small.
	NodeReadyInitialTimeout = 20 * time.Second

	// PodReadyBeforeTimeout indicates how long pods have to be "ready" when a test begins.
	PodReadyBeforeTimeout = 5 * time.Minute

	// ClaimProvisionTimeout indicates how long claims have to become dynamically provisioned
	ClaimProvisionTimeout = 5 * time.Minute

	// ClaimProvisionShortTimeout is same as `ClaimProvisionTimeout` to wait for claim to be dynamically provisioned, but shorter.
	// Use it case by case when we are sure this timeout is enough.
	ClaimProvisionShortTimeout = 1 * time.Minute

	// ClaimBindingTimeout indicates how long claims have to become bound
	ClaimBindingTimeout = 3 * time.Minute

	// PVDeletingTimeout indicates how long PVs have to become deleted
	PVDeletingTimeout = 3 * time.Minute

	// RestartNodeReadyAgainTimeout indicates how long a node is allowed to become "Ready" after it is restarted before
	// the test is considered failed.
	RestartNodeReadyAgainTimeout = 5 * time.Minute

	// RestartPodReadyAgainTimeout indicates how long a pod is allowed to become "running" and "ready" after a node
	// restart before test is considered failed.
	RestartPodReadyAgainTimeout = 5 * time.Minute
)
View Source
const (
	// DefaultNamespaceDeletionTimeout is timeout duration for waiting for a namespace deletion.
	DefaultNamespaceDeletionTimeout = 5 * time.Minute
)

Variables

View Source
var (
	// UnreachableTaintTemplate is the taint for when a node becomes unreachable.
	UnreachableTaintTemplate = &corev1.Taint{
		Key:    corev1.TaintNodeUnreachable,
		Effect: corev1.TaintEffectNoExecute,
	}
	// NotReadyTaintTemplate is the taint for when a node doesn't ready.
	NotReadyTaintTemplate = &corev1.Taint{
		Key:    corev1.TaintNodeNotReady,
		Effect: corev1.TaintEffectNoExecute,
	}
)
View Source
var ErrPodCompleted = fmt.Errorf("pod ran to completion")
View Source
var (
	// NewFrameworkExtensions lists functions that get called by
	// NewFramework after constructing a new framework and after
	// calling ginkgo.BeforeEach for the framework.
	//
	// This can be used by extensions of the core framework to modify
	// settings in the framework instance or to add additional callbacks
	// with gingko.BeforeEach/AfterEach/DeferCleanup.
	//
	// When a test runs, functions will be invoked in this order:
	// - BeforeEaches defined by tests before f.NewDefaultFramework
	//   in the order in which they were defined (first-in-first-out)
	// - f.BeforeEach
	// - BeforeEaches defined by tests after f.NewDefaultFramework
	// - It callback
	// - all AfterEaches in the order in which they were defined
	// - all DeferCleanups with the order reversed (first-in-last-out)
	// - f.AfterEach
	//
	// Because a test might skip test execution in a BeforeEach that runs
	// before f.BeforeEach, AfterEach callbacks that depend on the
	// framework instance must check whether it was initialized. They can
	// do that by checking f.ClientSet for nil. DeferCleanup callbacks
	// don't need to do this because they get defined when the test
	// runs.
	NewFrameworkExtensions []func(f *Framework)
)
View Source
var RunID = uuid.NewUUID()

RunID is a unique identifier of the e2e run

Functions

func AfterReadingAllFlags

func AfterReadingAllFlags(t *TestContextType)

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

func AllNodesReady

func AllNodesReady(c clientset.Interface, timeout time.Duration) error

AllNodesReady checks whether all registered nodes are ready. TODO: we should change the AllNodesReady call in AfterEach to WaitForAllNodesHealthy, and figure out how to do it in a configurable way, as we can't expect all setups to run default test add-ons.

func ConformanceIt

func ConformanceIt(text string, body interface{}, timeout ...float64) bool

ConformanceIt is a wrapper function for ginkgo It. Adds "[Conformance]" tag and makes static analysis easier.

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 is used to dump all namespace info

func DumpDebugInfo

func DumpDebugInfo(c clientset.Interface, ns string)

DumpDebugInfo dumps debug info

func DumpEventsInNamespace

func DumpEventsInNamespace(eventsLister EventsLister, namespace string)

DumpEventsInNamespace dump events in namespace

func ExpectEqual

func ExpectEqual(actual interface{}, extra interface{}, explain ...interface{})

ExpectEqual expects the specified two are the same, otherwise an exception raises

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 Fail

func Fail(message string, callerSkip ...int)

Fail wraps ginkgo.Fail so that it panics with more useful information about the failure. This function will panic with a FailurePanic.

func Failf

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

Failf print fail log

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 FilterNodes

func FilterNodes(nodeList *corev1.NodeList, fn func(node corev1.Node) bool)

FilterNodes filters nodes in NodeList in place, removing nodes that do not satisfy the given condition TODO: consider merging with pkg/client/cache.NodeLister

func GetReadySchedulableNodesOrDie

func GetReadySchedulableNodesOrDie(c clientset.Interface) (nodes *corev1.NodeList)

GetReadySchedulableNodesOrDie addresses the common use case of getting nodes you can do work on. 1) Needs to be schedulable. 2) Needs to be ready. If EITHER 1 or 2 is not true, most tests will want to ignore the node entirely.

func IsNodeConditionSetAsExpected

func IsNodeConditionSetAsExpected(node *corev1.Node, conditionType corev1.NodeConditionType, wantTrue bool) bool

IsNodeConditionSetAsExpected indicate if node is ready

func IsNodeConditionSetAsExpectedSilent

func IsNodeConditionSetAsExpectedSilent(node *corev1.Node, conditionType corev1.NodeConditionType, wantTrue bool) bool

IsNodeConditionSetAsExpectedSilent indicate if node is ready with silent

func IsNodeConditionUnset

func IsNodeConditionUnset(node *corev1.Node, conditionType corev1.NodeConditionType) bool

IsNodeConditionUnset indicate if set condition

func KoribtoDescribe

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

KoribtoDescribe is a wrapper function for ginkgo describe.

func KubectlCmd

func KubectlCmd(args ...string) *exec.Cmd

KubectlCmd runs the kubectl executable through the wrapper script.

func KusionstackDescribe

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

KusionstackDescribe is a wrapper for ginkgo.Describe.

func LoadClientset

func LoadClientset() (*clientset.Clientset, error)

LoadClientset loads config of client set

func LoadConfig

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

LoadConfig loads config

func Logf

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

Logf print info log

func RandStr

func RandStr() string

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.

func RegisterNodeFlags

func RegisterNodeFlags()

RegisterNodeFlags registers flags specific to the node e2e test suite.

func RegisterProvider

func RegisterProvider(name string, factory Factory)

RegisterProvider is expected to be called during application init, typically by an init function in a provider package.

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 loads config

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 RunHostCmd

func RunHostCmd(ns, name, cmd string) (string, error)

RunHostCmd runs the given cmd in the context of the given pod using `kubectl exec` inside of a shell.

func RunHostCmdWithRetries

func RunHostCmdWithRetries(ns, name, cmd string, interval, timeout time.Duration) (string, error)

RunHostCmdWithRetries calls RunHostCmd and retries all errors until it succeeds or the specified timeout expires. This can be used with idempotent commands to deflake transient Node issues.

func RunKubectl

func RunKubectl(args ...string) (string, error)

RunKubectl is a convenience wrapper over KubectlBuilder

func RunKubectlOrDie

func RunKubectlOrDie(args ...string) string

RunKubectlOrDie is a convenience wrapper over KubectlBuilder

func WaitForDefaultServiceAccountInNamespace

func WaitForDefaultServiceAccountInNamespace(c clientset.Interface, namespace string) error

WaitForDefaultServiceAccountInNamespace waits for the default service account to be provisioned the default service account is what is associated with pods when they do not specify a service account as a result, pods are not able to be provisioned in a namespace until the service account is provisioned

func WaitForPodCondition

func WaitForPodCondition(c clientset.Interface, ns, podName, desc string, timeout time.Duration, condition podCondition) error

WaitForPodCondition waits until pod satisfied condition

func WaitForPodNameRunningInNamespace

func WaitForPodNameRunningInNamespace(c clientset.Interface, podName, namespace string) error

WaitForPodNameRunningInNamespace waits default amount of time (PodStartTimeout) for the specified pod to become running. Returns an error if timeout occurs first, or pod goes in to failed state.

func WaitForPodRunningInNamespace

func WaitForPodRunningInNamespace(c clientset.Interface, pod *corev1.Pod) error

WaitForPodRunningInNamespace waits default amount of time (PodStartTimeout) for the specified pod to become running. Returns an error if timeout occurs first, or pod goes in to failed state.

func WaitTimeoutForPodRunningInNamespace

func WaitTimeoutForPodRunningInNamespace(c clientset.Interface, podName, namespace string, timeout time.Duration) error

WaitTimeoutForPodRunningInNamespace waits default amount of time

Types

type CleanupActionHandle

type CleanupActionHandle *int

CleanupActionHandle defines a type for cleanup action handle

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 ClientConfigGetter

type ClientConfigGetter func() (*restclient.Config, error)

ClientConfigGetter gets client config

type CloudConfig

type CloudConfig struct {
	APIEndpoint       string
	ProjectID         string
	Zone              string // for multizone tests, arbitrarily chosen zone
	Region            string
	MultiZone         bool
	MultiMaster       bool
	Cluster           string
	MasterName        string
	NodeInstanceGroup string // comma-delimited list of groups' names
	NumNodes          int
	ClusterIPRange    string
	ClusterTag        string
	Network           string
	ConfigFile        string // for azure and openstack
	NodeTag           string
	MasterTag         string

	Provider ProviderInterface
}

CloudConfig defines some config

type CodeExitError

type CodeExitError struct {
	Err  error
	Code int
}

func (CodeExitError) Error

func (e CodeExitError) Error() string

func (CodeExitError) ExitStatus

func (e CodeExitError) ExitStatus() int

ExitStatus is for checking the error code

func (CodeExitError) Exited

func (e CodeExitError) Exited() bool

Exited is to check if the process has finished

func (CodeExitError) String

func (e CodeExitError) String() string

type CollaSetTester

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

func NewCollaSetTester

func NewCollaSetTester(clientSet clientset.Interface, client client.Client, ns string) *CollaSetTester

func (*CollaSetTester) CreateCollaSet

func (t *CollaSetTester) CreateCollaSet(cls *appsv1alpha1.CollaSet) error

func (*CollaSetTester) DeleteCollaSet

func (t *CollaSetTester) DeleteCollaSet(cls *appsv1alpha1.CollaSet) error

func (*CollaSetTester) ExpectedStatusReplicas

func (t *CollaSetTester) ExpectedStatusReplicas(cls *appsv1alpha1.CollaSet, replicas, readyReplicas, availableReplicas, updatedReplicas, totalReplicas int32) error

func (*CollaSetTester) GetCollaSet

func (t *CollaSetTester) GetCollaSet(cls *appsv1alpha1.CollaSet) error

func (*CollaSetTester) ListPVCForCollaSet

func (t *CollaSetTester) ListPVCForCollaSet(cls *appsv1alpha1.CollaSet) (pvcs []*v1.PersistentVolumeClaim, err error)

func (*CollaSetTester) ListPodsForCollaSet

func (t *CollaSetTester) ListPodsForCollaSet(cls *appsv1alpha1.CollaSet) (pods []*v1.Pod, err error)

func (*CollaSetTester) ListResourceContextsForCollaSet

func (t *CollaSetTester) ListResourceContextsForCollaSet(cls *appsv1alpha1.CollaSet) (resourceContexts []*appsv1alpha1.ResourceContext, err error)

func (*CollaSetTester) NewCollaSet

func (t *CollaSetTester) NewCollaSet(name string, replicas int32, updateStrategy appsv1alpha1.UpdateStrategy) *appsv1alpha1.CollaSet

func (*CollaSetTester) UpdateCollaSet

func (t *CollaSetTester) UpdateCollaSet(cls *appsv1alpha1.CollaSet, fn func(cls *appsv1alpha1.CollaSet)) error

func (*CollaSetTester) UpdatePod

func (t *CollaSetTester) UpdatePod(pod *v1.Pod, fn func(pod *v1.Pod)) error

type CreateTestingNSFn

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

CreateTestingNSFn defines a function to create test

type DumpAllNamespaceInfoAction

type DumpAllNamespaceInfoAction func(ctx context.Context, f *Framework, namespace string)

DumpAllNamespaceInfoAction is called after each failed test for namespaces created for the test.

type EventsLister

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

EventsLister defines a event listener

type ExitError

type ExitError interface {
	String() string
	Error() string
	Exited() bool
	ExitStatus() int
}

type Factory

type Factory func() (ProviderInterface, error)

Factory represents the factory pattern

type FailurePanic

type FailurePanic struct {
	Message        string // The failure message passed to Fail
	Filename       string // The filename that is the source of the failure
	Line           int    // The line number of the filename that is the source of the failure
	FullStackTrace string // A full stack trace starting at the source of the failure
}

FailurePanic is the value that will be panicked from Fail.

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

	Client    client.Client
	ClientSet clientset.Interface

	DynamicClient dynamic.Interface

	SkipNamespaceCreation bool              // Whether to skip creating a namespace
	Namespace             *corev1.Namespace // Every test has at least one namespace unless creation is skipped

	NamespaceDeletionTimeout time.Duration
	SkipPrivilegedPSPBinding bool // Whether to skip creating a binding to the privileged PSP in the test namespace

	// configuration for framework's client
	Options Options

	// Place where various additional data is stored during test run to be printed to ReportDir,
	// or stdout if ReportDir is not set once test ends.
	TestSummaries []TestDataSummary

	AfterEachActions []func()
	// 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 makes a new framework and sets up a BeforeEach/AfterEach

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 is used to create namespace

func (*Framework) WaitForPodRunning

func (f *Framework) WaitForPodRunning(podName string) error

WaitForPodRunning waits for the pod to run in the namespace.

type KubectlBuilder

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

KubectlBuilder is used to build, customize and execute a kubectl Command. Add more functions to customize the builder as needed.

func NewKubectlCommand

func NewKubectlCommand(args ...string) *KubectlBuilder

NewKubectlCommand return a KubectlBuilder

func (KubectlBuilder) Exec

func (b KubectlBuilder) Exec() (string, error)

Exec executes

func (KubectlBuilder) ExecOrDie

func (b KubectlBuilder) ExecOrDie() string

ExecOrDie indicates execute or die

func (*KubectlBuilder) WithEnv

func (b *KubectlBuilder) WithEnv(env []string) *KubectlBuilder

WithEnv sets env

func (KubectlBuilder) WithStdinData

func (b KubectlBuilder) WithStdinData(data string) *KubectlBuilder

WithStdinData sets stdin data

func (KubectlBuilder) WithStdinReader

func (b KubectlBuilder) WithStdinReader(reader io.Reader) *KubectlBuilder

WithStdinReader sets stdin reader

func (*KubectlBuilder) WithTimeout

func (b *KubectlBuilder) WithTimeout(t <-chan time.Time) *KubectlBuilder

WithTimeout sets timeout

type NodeTestContextType

type NodeTestContextType struct {
	// NodeE2E indicates whether it is running node e2e.
	NodeE2E bool
	// Name of the node to run tests on.
	NodeName string
	// NodeConformance indicates whether the test is running in node conformance mode.
	NodeConformance bool
	// PrepullImages indicates whether node e2e framework should prepull images.
	PrepullImages bool
	// ImageDescription is the description of the image on which the test is running.
	ImageDescription string
	// SystemSpecName is the name of the system spec (e.g., gke) that's used in
	// the node e2e test. If empty, the default one (system.DefaultSpec) is
	// used. The system specs are in test/e2e_node/system/specs/.
	SystemSpecName string
	// ExtraEnvs is a map of environment names to values.
	ExtraEnvs map[string]string
}

NodeTestContextType is part of TestContextType, it is shared by all node e2e test.

type NullProvider

type NullProvider struct{}

NullProvider is the default implementation of the ProviderInterface which doesn't do anything.

func (NullProvider) CleanupServiceResources

func (n NullProvider) CleanupServiceResources(c clientset.Interface, loadBalancerName, region, zone string)

CleanupServiceResources no usages

func (NullProvider) CreatePD

func (n NullProvider) CreatePD(zone string) (string, error)

CreatePD no usages

func (NullProvider) CreatePVSource

func (n NullProvider) CreatePVSource(zone, diskName string) (*corev1.PersistentVolumeSource, error)

CreatePVSource no usages

func (NullProvider) DeletePD

func (n NullProvider) DeletePD(pdName string) error

DeletePD no usages

func (NullProvider) DeletePVSource

func (n NullProvider) DeletePVSource(pvSource *corev1.PersistentVolumeSource) error

DeletePVSource no usages

func (NullProvider) EnableAndDisableInternalLB

func (n NullProvider) EnableAndDisableInternalLB() (enable, disable func(svc *corev1.Service))

EnableAndDisableInternalLB no usages

func (NullProvider) EnsureLoadBalancerResourcesDeleted

func (n NullProvider) EnsureLoadBalancerResourcesDeleted(ip, portRange string) error

EnsureLoadBalancerResourcesDeleted no usages

func (NullProvider) FrameworkAfterEach

func (n NullProvider) FrameworkAfterEach(f *Framework)

FrameworkAfterEach is framework after each

func (NullProvider) FrameworkBeforeEach

func (n NullProvider) FrameworkBeforeEach(f *Framework)

FrameworkBeforeEach is a framework before each

func (NullProvider) GetGroupNodes

func (n NullProvider) GetGroupNodes(group string) ([]string, error)

GetGroupNodes no usages

func (NullProvider) GroupSize

func (n NullProvider) GroupSize(group string) (int, error)

GroupSize no usages

func (NullProvider) LoadBalancerSrcRanges

func (n NullProvider) LoadBalancerSrcRanges() []string

LoadBalancerSrcRanges no usages

func (NullProvider) ResizeGroup

func (n NullProvider) ResizeGroup(string, int32) error

ResizeGroup no usages

type OperationJobTester

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

func NewOperationJobTester

func NewOperationJobTester(clientSet clientset.Interface, client client.Client, ns string) *OperationJobTester

func (*OperationJobTester) CreateOperationJob

func (t *OperationJobTester) CreateOperationJob(oj *appsv1alpha1.OperationJob) error

func (*OperationJobTester) DeleteOperationJob

func (t *OperationJobTester) DeleteOperationJob(oj *appsv1alpha1.OperationJob) error

func (*OperationJobTester) ExpectOperationJobProgress

func (t *OperationJobTester) ExpectOperationJobProgress(oj *appsv1alpha1.OperationJob, progress appsv1alpha1.OperationProgress) error

func (*OperationJobTester) GetOperationJob

func (t *OperationJobTester) GetOperationJob(oj *appsv1alpha1.OperationJob) error

func (*OperationJobTester) ListPodsForOperationJobTester

func (t *OperationJobTester) ListPodsForOperationJobTester(oj *appsv1alpha1.OperationJob) (pods []*v1.Pod, err error)

func (*OperationJobTester) NewOperationJob

func (t *OperationJobTester) NewOperationJob(name string, action string, targets []appsv1alpha1.PodOpsTarget) *appsv1alpha1.OperationJob

func (*OperationJobTester) UpdateOperationJob

func (t *OperationJobTester) UpdateOperationJob(oj *appsv1alpha1.OperationJob, fn func(oj *appsv1alpha1.OperationJob)) error

func (*OperationJobTester) UpdatePod

func (t *OperationJobTester) UpdatePod(pod *v1.Pod, fn func(pod *v1.Pod)) error

type Options

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

Options is a struct for managing test framework options.

type ProviderInterface

type ProviderInterface interface {
	FrameworkBeforeEach(f *Framework)
	FrameworkAfterEach(f *Framework)

	ResizeGroup(group string, size int32) error
	GetGroupNodes(group string) ([]string, error)
	GroupSize(group string) (int, error)

	CreatePD(zone string) (string, error)
	DeletePD(pdName string) error
	CreatePVSource(zone, diskName string) (*corev1.PersistentVolumeSource, error)
	DeletePVSource(pvSource *corev1.PersistentVolumeSource) error

	CleanupServiceResources(c clientset.Interface, loadBalancerName, region, zone string)

	EnsureLoadBalancerResourcesDeleted(ip, portRange string) error
	LoadBalancerSrcRanges() []string
	EnableAndDisableInternalLB() (enable, disable func(svc *corev1.Service))
}

ProviderInterface contains the implementation for certain provider-specific functionality.

func SetupProviderConfig

func SetupProviderConfig(providerName string) (ProviderInterface, error)

SetupProviderConfig validates the chosen provider and creates an interface instance for it.

type TestContextType

type TestContextType struct {
	KubeConfig         string
	KubeContext        string
	KubeAPIContentType string
	KubeVolumeDir      string
	CertDir            string
	Host               string
	// TODO: Deprecating this over time... instead just use gobindata_util.go , see #23987.
	RepoRoot                string
	DockershimCheckpointDir string

	// Provider identifies the infrastructure provider (gce, gke, aws)
	Provider string

	// Tooling is the tooling in use (e.g. kops, gke).  Provider is the cloud provider and might not uniquely identify the tooling.
	Tooling string

	CloudConfig    CloudConfig
	KubectlPath    string
	OutputDir      string
	ReportDir      string
	ReportPrefix   string
	Prefix         string
	MinStartupPods int
	// Timeout for waiting for system pods to be running
	SystemPodsStartupTimeout    time.Duration
	EtcdUpgradeStorage          string
	EtcdUpgradeVersion          string
	IngressUpgradeImage         string
	GCEUpgradeScript            string
	ContainerRuntime            string
	ContainerRuntimeEndpoint    string
	ContainerRuntimeProcessName string
	ContainerRuntimePidFile     string
	// SystemdServices are comma separated list of systemd services the test framework
	// will dump logs for.
	SystemdServices          string
	ImageServiceEndpoint     string
	MasterOSDistro           string
	NodeOSDistro             string
	VerifyServiceAccount     bool
	DeleteNamespace          bool
	DeleteNamespaceOnFailure bool
	AllowedNotReadyNodes     int
	CleanStart               bool
	// If set to 'true' or 'all' framework will start a goroutine monitoring resource usage of system add-ons.
	// It will read the data every 30 seconds from all Nodes and print summary during afterEach. If set to 'master'
	// only master Node will be monitored.
	GatherKubeSystemResourceUsageData string
	GatherLogsSizes                   bool
	GatherMetricsAfterTest            string
	GatherSuiteMetricsAfterTest       bool
	AllowGatheringProfiles            bool
	// If set to 'true' framework will gather ClusterAutoscaler metrics when gathering them for other components.
	IncludeClusterAutoscalerMetrics bool
	// Currently supported values are 'hr' for human-readable and 'json'. It's a comma separated list.
	OutputPrintType string
	// NodeSchedulableTimeout is the timeout for waiting for all nodes to be schedulable.
	NodeSchedulableTimeout time.Duration
	// SystemDaemonsetStartupTimeout is the timeout for waiting for all system daemonsets to be ready.
	SystemDaemonsetStartupTimeout time.Duration
	// CreateTestingNS is responsible for creating namespace used for executing e2e tests.
	// It accepts namespace base name, which will be prepended with e2e prefix, kube client
	// and labels to be applied to a namespace.
	CreateTestingNS CreateTestingNSFn
	// If set to true test will dump data about the namespace in which test was running.
	DumpLogsOnFailure bool
	// Disables dumping cluster log from master and nodes after all tests.
	DisableLogDump bool
	// Path to the GCS artifacts directory to dump logs from nodes. Logexporter gets enabled if this is non-empty.
	LogexporterGCSPath string
	// featureGates is a map of feature names to bools that enable or disable alpha/experimental features.
	FeatureGates map[string]bool
	// Node e2e specific test context
	NodeTestContextType
	// Monitoring solution that is used in current cluster.
	ClusterMonitoringMode string
	// Separate Prometheus monitoring deployed in cluster
	EnablePrometheusMonitoring bool

	// Indicates what path the kubernetes-anywhere is installed on
	KubernetesAnywherePath string

	// The DNS Domain of the cluster.
	ClusterDNSDomain string
}

TestContextType contains test settings and global state. Due to historic reasons, it is a mixture of items managed by the test framework itself, cloud providers and individual tests. The goal is to move anything not required by the framework into the code which uses the settings.

The recommendation for those settings is:

  • They are stored in their own context structure or local variables.
  • The standard `flag` package is used to register them. The flag name should follow the pattern <part1>.<part2>....<partn> where the prefix is unlikely to conflict with other tests or standard packages and each part is in lower camel case. For example, test/e2e/storage/csi/context.go could define storage.csi.numIterations.
  • framework/config can be used to simplify the registration of multiple options with a single function call: var storageCSI { NumIterations `default:"1" usage:"number of iterations"` } _ config.AddOptions(&storageCSI, "storage.csi")
  • The direct use Viper in tests is possible, but discouraged because it only works in test suites which use Viper (which is not required) and the supported options cannot be discovered by a test suite user.

Test suite authors can use framework/viper to make all command line parameters also configurable via a configuration file.

var TestContext TestContextType

TestContext defines a context include test settings and global state

type TestDataSummary

type TestDataSummary interface {
	SummaryKind() string
	PrintHumanReadable() string
	PrintJSON() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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