...

Package framework

import "k8s.io/kubernetes/test/e2e/framework"
Overview
Index
Subdirectories

Overview ▾

Package framework contains provider-independent helper code for building and running E2E tests with Ginkgo. The actual Ginkgo test suites gets assembled by combining this framework, the optional provider support code and specific tests via a separate .go file like Kubernetes' test/e2e.go.

Package framework contains provider-independent helper code for building and running E2E tests with Ginkgo. The actual Ginkgo test suites gets assembled by combining this framework, the optional provider support code and specific tests via a separate .go file like Kubernetes' test/e2e.go.

Index ▾

Constants
Variables
func APIAddress() string
func AfterReadingAllFlags(t *TestContextType)
func AnnotatedLocation(annotation string) types.CodeLocation
func AnnotatedLocationWithOffset(annotation string, offset int) types.CodeLocation
func AppendContainerCommandGroupIfNeeded(args []string) []string
func CheckTestingNSDeletedExcept(ctx context.Context, c clientset.Interface, skip string) error
func ConformanceIt(args ...interface{}) bool
func Context(args ...interface{}) bool
func CoreDump(dir string)
func CreateGinkgoConfig() (types.SuiteConfig, types.ReporterConfig)
func CreateTestingNS(ctx context.Context, baseName string, c clientset.Interface, labels map[string]string) (*v1.Namespace, error)
func DeleteNamespaces(ctx context.Context, c clientset.Interface, deleteFilter, skipFilter []string) ([]string, error)
func Describe(args ...interface{}) bool
func EnsureLoadBalancerResourcesDeleted(ctx context.Context, ip, portRange string) error
func ExpectError(err error, explain ...interface{})
func ExpectNoError(err error, explain ...interface{})
func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{})
func Failf(format string, args ...interface{})
func FormatBugs() error
func GetControlPlaneAddresses(ctx context.Context, c clientset.Interface) []string
func GetGroupNodes(group string) ([]string, error)
func GetProviders() []string
func GroupSize(group string) (int, error)
func IgnoreNotFound(in any) any
func It(args ...interface{}) bool
func LoadClientset() (*clientset.Clientset, error)
func LoadConfig() (config *restclient.Config, err error)
func Logf(format string, args ...interface{})
func MakeMatcher[T interface{}](match func(actual T) (failure func() string, err error)) types.GomegaMatcher
func MasterOSDistroIs(supportedMasterOsDistros ...string) bool
func NodeOSArchIs(supportedNodeOsArchs ...string) bool
func NodeOSDistroIs(supportedNodeOsDistros ...string) bool
func PollInterval() time.Duration
func PrettyPrintJSON(metrics interface{}) string
func ProviderIs(providers ...string) bool
func RandomSuffix() string
func RecordBug(bug Bug)
func RegisterClusterFlags(flags *flag.FlagSet)
func RegisterCommonFlags(flags *flag.FlagSet)
func RegisterProvider(name string, factory Factory)
func ResizeGroup(group string, size int32) error
func RunCmd(command string, args ...string) (string, string, error)
func RunCmdEnv(env []string, command string, args ...string) (string, string, error)
func SIGDescribe(sig string) func(...interface{}) bool
func ShouldRetry(err error) (retry bool, retryAfter time.Duration)
func StartCmdAndStreamOutput(cmd *exec.Cmd) (stdout, stderr io.ReadCloser, err error)
func TagsEqual(a, b interface{}) bool
func TryKill(cmd *exec.Cmd)
func WaitForDefaultServiceAccountInNamespace(ctx context.Context, c clientset.Interface, namespace string) error
func WaitForGroupSize(group string, size int32) error
func WaitForKubeRootCAInNamespace(ctx context.Context, c clientset.Interface, namespace string) error
func WaitForNamespacesDeleted(ctx context.Context, c clientset.Interface, namespaces []string, timeout time.Duration) error
func WaitForServiceEndpointsNum(ctx context.Context, c clientset.Interface, namespace, serviceName string, expectNum int, interval, timeout time.Duration) error
func WatchEventSequenceVerifier(ctx context.Context, dc dynamic.Interface, resourceType schema.GroupVersionResource, namespace string, resourceName string, listOptions metav1.ListOptions, expectedWatchEvents []watch.Event, scenario func(*watchtools.RetryWatcher) []watch.Event, retryCleanup func() error)
func WithConformance() interface{}
func WithDisruptive() interface{}
func WithEnvironment(name Environment) interface{}
func WithFeature(name Feature) interface{}
func WithFeatureGate(featureGate featuregate.Feature) interface{}
func WithFlaky() interface{}
func WithLabel(label string) interface{}
func WithNodeConformance() interface{}
func WithNodeFeature(name NodeFeature) interface{}
func WithSerial() interface{}
func WithSlow() interface{}
type APIGetFunc
type APIListFunc
type Assertion
type AsyncAssertion
type Bug
    func NewBug(message string, skip int) Bug
type ClientConfigGetter
type CloudConfig
type ClusterVerification
    func (cl *ClusterVerification) ForEach(ctx context.Context, podFunc func(v1.Pod)) error
    func (cl *ClusterVerification) WaitFor(ctx context.Context, atLeast int, timeout time.Duration) ([]v1.Pod, error)
    func (cl *ClusterVerification) WaitForOrFail(ctx context.Context, atLeast int, timeout time.Duration)
type CreateTestingNSFn
type DumpAllNamespaceInfoAction
type Environment
type Factory
type FailureError
    func (f FailureError) Backtrace() string
    func (f FailureError) Error() string
    func (f FailureError) Is(target error) bool
type Feature
type FlakeReport
    func NewFlakeReport() *FlakeReport
    func (f *FlakeReport) GetFlakeCount() int
    func (f *FlakeReport) PrintHumanReadable() string
    func (f *FlakeReport) PrintJSON() string
    func (f *FlakeReport) RecordFlakeIfError(err error, optionalDescription ...interface{})
    func (f *FlakeReport) SummaryKind() string
type Framework
    func NewDefaultFramework(baseName string) *Framework
    func NewFramework(baseName string, options Options, client clientset.Interface) *Framework
    func NewFrameworkWithCustomTimeouts(baseName string, timeouts *TimeoutContext) *Framework
    func (f *Framework) AddNamespacesToDelete(namespaces ...*v1.Namespace)
    func (f *Framework) AfterEach(ctx context.Context)
    func (f *Framework) BeforeEach(ctx context.Context)
    func (f *Framework) ClientConfig() *rest.Config
    func (f *Framework) Context(args ...interface{}) bool
    func (f *Framework) CreateNamespace(ctx context.Context, baseName string, labels map[string]string) (*v1.Namespace, error)
    func (f *Framework) DeleteNamespace(ctx context.Context, name string)
    func (f *Framework) Describe(args ...interface{}) bool
    func (f *Framework) It(args ...interface{}) bool
    func (f *Framework) NewClusterVerification(namespace *v1.Namespace, filter PodStateVerification) *ClusterVerification
    func (f *Framework) RecordFlakeIfError(err error, optionalDescription ...interface{})
    func (f *Framework) WithConformance() interface{}
    func (f *Framework) WithDisruptive() interface{}
    func (f *Framework) WithEnvironment(name Environment) interface{}
    func (f *Framework) WithFeature(name Feature) interface{}
    func (f *Framework) WithFeatureGate(featureGate featuregate.Feature) interface{}
    func (f *Framework) WithFlaky() interface{}
    func (f *Framework) WithLabel(label string) interface{}
    func (f *Framework) WithNodeConformance() interface{}
    func (f *Framework) WithNodeFeature(name NodeFeature) interface{}
    func (f *Framework) WithSerial() interface{}
    func (f *Framework) WithSlow() interface{}
type GetFunc
    func GetObject[T any](get APIGetFunc[T], name string, getOptions metav1.GetOptions) GetFunc[T]
    func HandleRetry[T any](get GetFunc[T]) GetFunc[T]
    func ListObjects[T any](list APIListFunc[T], listOptions metav1.ListOptions) GetFunc[T]
    func RetryNotFound[T any](get GetFunc[T]) GetFunc[T]
type GomegaInstance
    func Gomega() GomegaInstance
type KubeCluster
type KubeConfig
    func (kc *KubeConfig) FindCluster(name string) *KubeCluster
    func (kc *KubeConfig) FindUser(name string) *KubeUser
type KubeUser
type NamedObject
type NamespacedName
    func (n NamespacedName) GetName() string
    func (n NamespacedName) GetNamespace() string
    func (n NamespacedName) String() string
type NodeFeature
type NodeKillerConfig
type NodeTestContextType
type NullProvider
    func (n NullProvider) CleanupServiceResources(ctx context.Context, c clientset.Interface, loadBalancerName, region, zone string)
    func (n NullProvider) CreatePD(zone string) (string, error)
    func (n NullProvider) CreatePVSource(ctx context.Context, zone, diskName string) (*v1.PersistentVolumeSource, error)
    func (n NullProvider) CreateShare() (string, string, string, error)
    func (n NullProvider) DeleteNode(node *v1.Node) error
    func (n NullProvider) DeletePD(pdName string) error
    func (n NullProvider) DeletePVSource(ctx context.Context, pvSource *v1.PersistentVolumeSource) error
    func (n NullProvider) DeleteShare(accountName, shareName string) error
    func (n NullProvider) EnableAndDisableInternalLB() (enable, disable func(svc *v1.Service))
    func (n NullProvider) EnsureLoadBalancerResourcesDeleted(ctx context.Context, ip, portRange string) error
    func (n NullProvider) FrameworkAfterEach(f *Framework)
    func (n NullProvider) FrameworkBeforeEach(f *Framework)
    func (n NullProvider) GetGroupNodes(group string) ([]string, error)
    func (n NullProvider) GroupSize(group string) (int, error)
    func (n NullProvider) LoadBalancerSrcRanges() []string
    func (n NullProvider) ResizeGroup(string, int32) error
type Options
type PodStateVerification
type ProviderInterface
    func SetupProviderConfig(providerName string) (ProviderInterface, error)
type TestContextType
    func (tc TestContextType) ClusterIsIPv6() bool
type TestDataSummary
type TimeoutContext
    func NewTimeoutContext() *TimeoutContext
type Valid
    func (v *Valid[T]) Add(item T) T
    func (v *Valid[T]) Freeze()

Package files

bugs.go expect.go flake_reporting_util.go framework.go get.go ginkgologger.go ginkgowrapper.go log.go namespacedname.go nodes_util.go ports.go provider.go size.go test_context.go timeouts.go util.go

Constants

const (
    // KubeletPort is the default port for the kubelet server on each host machine.
    // May be overridden by a flag at startup.
    KubeletPort = 10250
    // KubeControllerManagerPort is the default port for the controller manager status server.
    // May be overridden by a flag at startup.
    KubeControllerManagerPort = 10257
)

DEPRECATED constants. Use the timeouts in framework.Framework instead.

const (
    // PodListTimeout is how long to wait for the pod to be listable.
    PodListTimeout = time.Minute

    // PodStartTimeout is how long to wait for the pod to be started.
    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 is how long to wait for a pod to be deleted.
    PodDeleteTimeout = 5 * time.Minute

    // PodGetTimeout is how long to wait for a pod to be got.
    PodGetTimeout = 2 * time.Minute

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

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

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

    // PollShortTimeout is the short timeout value in polling.
    PollShortTimeout = 1 * time.Minute

    // ServiceAccountProvisionTimeout is how long to wait for a service account to be provisioned.
    // 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 is how long to try single API calls (like 'get' or 'list'). Used to prevent
    // transient failures from failing tests.
    SingleCallTimeout = 5 * time.Minute

    // NodeReadyInitialTimeout is 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 is how long pods have to be "ready" when a test begins.
    PodReadyBeforeTimeout = 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

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

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

    // RestartPodReadyAgainTimeout is how long a pod is allowed to become "running" and "ready" after a node
    // restart before test is considered failed.
    RestartPodReadyAgainTimeout = 5 * time.Minute

    // SnapshotCreateTimeout is how long for snapshot to create snapshotContent.
    SnapshotCreateTimeout = 5 * time.Minute

    // SnapshotDeleteTimeout is how long for snapshot to delete snapshotContent.
    SnapshotDeleteTimeout = 5 * time.Minute
)
const (
    // DefaultNamespaceDeletionTimeout is timeout duration for waiting for a namespace deletion.
    DefaultNamespaceDeletionTimeout = 5 * time.Minute
)
const (

    // DefaultNumNodes is the number of nodes. If not specified, then number of nodes is auto-detected
    DefaultNumNodes = -1
)

Variables

var (
    TimeNow = time.Now    // Can be stubbed out for testing.
    Pid     = os.Getpid() // Can be stubbed out for testing.
)
var (
    // Output is used for output when not running tests, for example in -list-tests.
    // Test output should go to ginkgo.GinkgoWriter.
    Output io.Writer = os.Stdout

    // Exit is called when the framework detects fatal errors or when
    // it is done with the execution of e.g. -list-tests.
    Exit = os.Exit

    // CheckForBugs determines whether the framework bails out when
    // test initialization found any bugs.
    CheckForBugs = true
)
var (
    // BusyBoxImage is the image URI of BusyBox.
    BusyBoxImage = imageutils.GetE2EImage(imageutils.BusyBox)

    // ProvidersWithSSH are those providers where each node is accessible with SSH
    ProvidersWithSSH = []string{"gce", "gke", "aws", "local", "azure"}

    // ServeHostnameImage is a serve hostname image name.
    ServeHostnameImage = imageutils.GetE2EImage(imageutils.Agnhost)
)

ErrFailure is an empty error that can be wrapped to indicate that an error is a FailureError. It can also be used to test for a FailureError:.

return fmt.Errorf("some problem%w", ErrFailure)
...
err := someOperation()
if errors.Is(err, ErrFailure) {
    ...
}
var ErrFailure error = FailureError{}

Fail is an alias for ginkgo.Fail.

var Fail = ginkgo.Fail
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 ginkgo.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)
)

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.

var RunID = uuid.NewUUID()

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

var TestContext = TestContextType{
    // contains filtered or unexported fields
}

func APIAddress

func APIAddress() string

APIAddress returns a address of an instance.

func AfterReadingAllFlags

func AfterReadingAllFlags(t *TestContextType)

AfterReadingAllFlags makes changes to the context after all flags have been read and prepares the process for a test run.

func AnnotatedLocation

func AnnotatedLocation(annotation string) types.CodeLocation

AnnotatedLocation can be used to provide more informative source code locations by passing the result as additional parameter to a BeforeEach/AfterEach/DeferCleanup/It/etc.

func AnnotatedLocationWithOffset

func AnnotatedLocationWithOffset(annotation string, offset int) types.CodeLocation

AnnotatedLocationWithOffset skips additional call stack levels. With 0 as offset it is identical to AnnotatedLocation.

func AppendContainerCommandGroupIfNeeded

func AppendContainerCommandGroupIfNeeded(args []string) []string

AppendContainerCommandGroupIfNeeded returns container command group parameter if necessary.

func CheckTestingNSDeletedExcept

func CheckTestingNSDeletedExcept(ctx context.Context, c clientset.Interface, skip string) error

CheckTestingNSDeletedExcept checks whether all e2e based existing namespaces are in the Terminating state and waits until they are finally deleted. It ignores namespace skip.

func ConformanceIt

func ConformanceIt(args ...interface{}) bool

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

func Context

func Context(args ...interface{}) bool

Context is a wrapper around ginkgo.Context which supports framework With* labels as optional arguments in addition to those already supported by ginkgo itself, like ginkgo.Label and ginkgo.Offset.

Text and arguments may be mixed. The final text is a concatenation of the text arguments and special tags from the With functions.

func CoreDump

func CoreDump(dir string)

CoreDump SSHs to the master and all nodes and dumps their logs into dir. It shells out to cluster/log-dump/log-dump.sh to accomplish this.

func CreateGinkgoConfig

func CreateGinkgoConfig() (types.SuiteConfig, types.ReporterConfig)

func CreateTestingNS

func CreateTestingNS(ctx context.Context, baseName string, c clientset.Interface, labels map[string]string) (*v1.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 DeleteNamespaces

func DeleteNamespaces(ctx context.Context, c clientset.Interface, deleteFilter, skipFilter []string) ([]string, error)

DeleteNamespaces deletes all namespaces that match the given delete and skip filters. Filter is by simple strings.Contains; first skip filter, then delete filter. Returns the list of deleted namespaces or an error.

func Describe

func Describe(args ...interface{}) bool

Describe is a wrapper around ginkgo.Describe which supports framework With* labels as optional arguments in addition to those already supported by ginkgo itself, like ginkgo.Label and ginkgo.Offset.

Text and arguments may be mixed. The final text is a concatenation of the text arguments and special tags from the With functions.

func EnsureLoadBalancerResourcesDeleted

func EnsureLoadBalancerResourcesDeleted(ctx context.Context, ip, portRange string) error

EnsureLoadBalancerResourcesDeleted ensures that cloud load balancer resources that were created are actually cleaned up. Currently only implemented for GCE/GKE.

func ExpectError

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

ExpectError expects an error happens, otherwise an exception raises

Deprecated: use gomega.Expect().To(gomega.HaveOccurred()) or (better!) check specifically for the error that is expected with gomega.Expect().To(gomega.MatchError(gomega.ContainSubstring()))

func ExpectNoError

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

ExpectNoError checks if "err" is set, and if so, fails assertion while logging the error.

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{})

Failf logs the fail info, including a stack trace starts with its direct caller (for example, for call chain f -> g -> Failf("foo", ...) error would be logged for "g").

func FormatBugs

func FormatBugs() error

FormatBugs produces a report that includes all bugs recorded earlier via RecordBug. An error is returned with the report if there have been bugs.

func GetControlPlaneAddresses

func GetControlPlaneAddresses(ctx context.Context, c clientset.Interface) []string

GetControlPlaneAddresses returns all IP addresses on which the kubelet can reach the control plane. It may return internal and external IPs, even if we expect for e.g. internal IPs to be used (issue #56787), so that we can be sure to block the control plane fully during tests.

func GetGroupNodes

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

GetGroupNodes returns a node name for the specified node group

func GetProviders

func GetProviders() []string

GetProviders returns the names of all currently registered providers.

func GroupSize

func GroupSize(group string) (int, error)

GroupSize returns the size of an instance group

func IgnoreNotFound

func IgnoreNotFound(in any) any

IgnoreNotFound can be used to wrap an arbitrary function in a call to ginkgo.DeferCleanup. When the wrapped function returns an error that `apierrors.IsNotFound` considers as "not found", the error is ignored instead of failing the test during cleanup. This is useful for cleanup code that just needs to ensure that some object does not exist anymore.

func It

func It(args ...interface{}) bool

It is a wrapper around ginkgo.It which supports framework With* labels as optional arguments in addition to those already supported by ginkgo itself, like ginkgo.Label and ginkgo.Offset.

Text and arguments may be mixed. The final text is a concatenation of the text arguments and special tags from the With functions.

func LoadClientset

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

LoadClientset returns clientset for connecting to kubernetes clusters.

func LoadConfig

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

LoadConfig returns a config for a rest client with the UserAgent set to include the current test name.

func Logf

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

Logf logs the info.

Use this instead of `klog.Infof` because stack unwinding automatically skips over helper functions which marked themselves as helper by calling ginkgo.GinkgoHelper.

func MakeMatcher

func MakeMatcher[T interface{}](match func(actual T) (failure func() string, err error)) types.GomegaMatcher

MakeMatcher builds a gomega.Matcher based on a single callback function. That function is passed the actual value that is to be checked. There are three possible outcomes of the check:

func MasterOSDistroIs

func MasterOSDistroIs(supportedMasterOsDistros ...string) bool

MasterOSDistroIs returns true if the master OS distro is included in the supportedMasterOsDistros. Otherwise false.

func NodeOSArchIs

func NodeOSArchIs(supportedNodeOsArchs ...string) bool

NodeOSArchIs returns true if the node OS arch is included in the supportedNodeOsArchs. Otherwise false.

func NodeOSDistroIs

func NodeOSDistroIs(supportedNodeOsDistros ...string) bool

NodeOSDistroIs returns true if the node OS distro is included in the supportedNodeOsDistros. Otherwise false.

func PollInterval

func PollInterval() time.Duration

PollInterval defines how long to wait between API server queries while waiting for some condition.

This value is the default for gomega.Eventually and gomega.Consistently.

func PrettyPrintJSON

func PrettyPrintJSON(metrics interface{}) string

PrettyPrintJSON converts metrics to JSON format.

func ProviderIs

func ProviderIs(providers ...string) bool

ProviderIs returns true if the provider is included is the providers. Otherwise false.

func RandomSuffix

func RandomSuffix() string

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

func RecordBug

func RecordBug(bug Bug)

RecordBug stores information about a bug in the E2E suite source code that cannot be reported through ginkgo.Fail because it was found outside of some test, for example during test registration.

This can be used instead of raising a panic. Then all bugs can be reported together instead of failing after the first one.

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.

For tests that have been converted to registering their options themselves, copy flags from test/e2e/framework/config as shown in HandleFlags.

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 ResizeGroup

func ResizeGroup(group string, size int32) error

ResizeGroup resizes an instance group

func RunCmd

func RunCmd(command string, args ...string) (string, string, error)

RunCmd runs cmd using args and returns its stdout and stderr. It also outputs cmd's stdout and stderr to their respective OS streams.

func RunCmdEnv

func RunCmdEnv(env []string, command string, args ...string) (string, string, error)

RunCmdEnv runs cmd with the provided environment and args and returns its stdout and stderr. It also outputs cmd's stdout and stderr to their respective OS streams.

func SIGDescribe

func SIGDescribe(sig string) func(...interface{}) bool

SIGDescribe returns a wrapper function for ginkgo.Describe which injects the SIG name as annotation. The parameter should be lowercase with no spaces and no sig- or SIG- prefix.

func ShouldRetry

func ShouldRetry(err error) (retry bool, retryAfter time.Duration)

ShouldRetry decides whether to retry an API request. Optionally returns a delay to retry after.

func StartCmdAndStreamOutput

func StartCmdAndStreamOutput(cmd *exec.Cmd) (stdout, stderr io.ReadCloser, err error)

StartCmdAndStreamOutput returns stdout and stderr after starting the given cmd.

func TagsEqual

func TagsEqual(a, b interface{}) bool

TagsEqual can be used to check whether two tags are the same. It's safe to compare e.g. the result of WithSlow() against the result of WithSerial(), the result will be false. False is also returned when a parameter is some completely different value.

func TryKill

func TryKill(cmd *exec.Cmd)

TryKill is rough equivalent of ctrl+c for cleaning up processes. Intended to be run in defer.

func WaitForDefaultServiceAccountInNamespace

func WaitForDefaultServiceAccountInNamespace(ctx context.Context, 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 WaitForGroupSize

func WaitForGroupSize(group string, size int32) error

WaitForGroupSize waits for node instance group reached the desired size

func WaitForKubeRootCAInNamespace

func WaitForKubeRootCAInNamespace(ctx context.Context, c clientset.Interface, namespace string) error

WaitForKubeRootCAInNamespace waits for the configmap kube-root-ca.crt containing the service account CA trust bundle to be provisioned in the specified namespace so that pods do not have to retry mounting the config map (which creates noise that hides other issues in the Kubelet).

func WaitForNamespacesDeleted

func WaitForNamespacesDeleted(ctx context.Context, c clientset.Interface, namespaces []string, timeout time.Duration) error

WaitForNamespacesDeleted waits for the namespaces to be deleted.

func WaitForServiceEndpointsNum

func WaitForServiceEndpointsNum(ctx context.Context, c clientset.Interface, namespace, serviceName string, expectNum int, interval, timeout time.Duration) error

WaitForServiceEndpointsNum waits until the amount of endpoints that implement service to expectNum. Some components use EndpointSlices other Endpoints, we must verify that both objects meet the requirements.

func WatchEventSequenceVerifier

func WatchEventSequenceVerifier(ctx context.Context, dc dynamic.Interface, resourceType schema.GroupVersionResource, namespace string, resourceName string, listOptions metav1.ListOptions, expectedWatchEvents []watch.Event, scenario func(*watchtools.RetryWatcher) []watch.Event, retryCleanup func() error)

WatchEventSequenceVerifier ... manages a watch for a given resource, ensures that events take place in a given order, retries the test on failure

ctx                 cancellation signal across API boundaries, e.g: context from Ginkgo
dc                  sets up a client to the API
resourceType        specify the type of resource
namespace           select a namespace
resourceName        the name of the given resource
listOptions         options used to find the resource, recommended to use listOptions.labelSelector
expectedWatchEvents array of events which are expected to occur
scenario            the test itself
retryCleanup        a function to run which ensures that there are no dangling resources upon test failure

this tooling relies on the test to return the events as they occur the entire scenario must be run to ensure that the desired watch events arrive in order (allowing for interweaving of watch events)

if an expected watch event is missing we elect to clean up and run the entire scenario again

we try the scenario three times to allow the sequencing to fail a couple of times

func WithConformance

func WithConformance() interface{}

WithConformace specifies that a certain test or group of tests must pass in all conformant Kubernetes clusters. The return value must be passed as additional argument to framework.It, framework.Describe, framework.Context.

func WithDisruptive

func WithDisruptive() interface{}

WithDisruptive specifies that a certain test or group of tests temporarily affects the functionality of the Kubernetes cluster. The return value must be passed as additional argument to framework.It, framework.Describe, framework.Context.

func WithEnvironment

func WithEnvironment(name Environment) interface{}

WithEnvironment specifies that a certain test or group of tests only works in a certain environment. The return value must be passed as additional argument to framework.It, framework.Describe, framework.Context.

The environment must be listed in ValidEnvironments.

func WithFeature

func WithFeature(name Feature) interface{}

WithEnvironment specifies that a certain test or group of tests only works with a feature available. The return value must be passed as additional argument to framework.It, framework.Describe, framework.Context.

The feature must be listed in ValidFeatures.

func WithFeatureGate

func WithFeatureGate(featureGate featuregate.Feature) interface{}

WithFeatureGate specifies that a certain test or group of tests depends on a feature gate being enabled. The return value must be passed as additional argument to framework.It, framework.Describe, framework.Context.

The feature gate must be listed in k8s.io/apiserver/pkg/util/feature.DefaultMutableFeatureGate. Once a feature gate gets removed from there, the WithFeatureGate calls using it also need to be removed.

func WithFlaky

func WithFlaky() interface{}

WithFlaky specifies that a certain test or group of tests are failing randomly. These tests are usually filtered out and ran separately from other tests.

func WithLabel

func WithLabel(label string) interface{}

WithLabel is a wrapper around ginkgo.Label. Besides adding an arbitrary label to a test, it also injects the label in square brackets into the test name.

func WithNodeConformance

func WithNodeConformance() interface{}

WithNodeConformance specifies that a certain test or group of tests for node functionality that does not depend on runtime or Kubernetes distro specific behavior. The return value must be passed as additional argument to framework.It, framework.Describe, framework.Context.

func WithNodeFeature

func WithNodeFeature(name NodeFeature) interface{}

WithNodeFeature specifies that a certain test or group of tests only works if the node supports a certain feature. The return value must be passed as additional argument to framework.It, framework.Describe, framework.Context.

The environment must be listed in ValidNodeFeatures.

func WithSerial

func WithSerial() interface{}

WithSerial specifies that a certain test or group of tests must not run in parallel with other tests. The return value must be passed as additional argument to framework.It, framework.Describe, framework.Context.

Starting with ginkgo v2, serial and parallel tests can be executed in the same invocation. Ginkgo itself will ensure that the serial tests run sequentially.

func WithSlow

func WithSlow() interface{}

WithSlow specifies that a certain test or group of tests must not run in parallel with other tests. The return value must be passed as additional argument to framework.It, framework.Describe, framework.Context.

type APIGetFunc

APIGetFunc is a get functions as used in client-go.

type APIGetFunc[T any] func(ctx context.Context, name string, getOptions metav1.GetOptions) (T, error)

type APIListFunc

APIListFunc is a list functions as used in client-go.

type APIListFunc[T any] func(ctx context.Context, listOptions metav1.ListOptions) (T, error)

type Assertion

type Assertion interface {
    Should(matcher types.GomegaMatcher) error
    ShouldNot(matcher types.GomegaMatcher) error
    To(matcher types.GomegaMatcher) error
    ToNot(matcher types.GomegaMatcher) error
    NotTo(matcher types.GomegaMatcher) error
}

type AsyncAssertion

type AsyncAssertion interface {
    Should(matcher types.GomegaMatcher) error
    ShouldNot(matcher types.GomegaMatcher) error

    WithTimeout(interval time.Duration) AsyncAssertion
    WithPolling(interval time.Duration) AsyncAssertion
}

type Bug

type Bug struct {
    FileName   string
    LineNumber int
    Message    string
}

func NewBug

func NewBug(message string, skip int) Bug

NewBug creates a new bug with a location that is obtained by skipping a certain number of stack frames. Passing zero will record the source code location of the direct caller of NewBug.

type ClientConfigGetter

ClientConfigGetter is a func that returns getter to return a config.

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

type CloudConfig

CloudConfig holds the cloud configuration for e2e test suites.

type CloudConfig struct {
    APIEndpoint       string
    ProjectID         string
    Zone              string   // for multizone tests, arbitrarily chosen zone
    Zones             []string // for multizone tests, use this set of zones instead of querying the cloud provider. Must include 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
    NodeTag           string
    MasterTag         string

    Provider ProviderInterface
}

type ClusterVerification

ClusterVerification is a struct for a verification of cluster state.

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

func (*ClusterVerification) ForEach

func (cl *ClusterVerification) ForEach(ctx context.Context, podFunc func(v1.Pod)) error

ForEach runs a function against every verifiable pod. Be warned that this doesn't wait for "n" pods to verify, so it may return very quickly if you have strict pod state requirements.

For example, if you require at least 5 pods to be running before your test will pass, its smart to first call "clusterVerification.WaitFor(5)" before you call clusterVerification.ForEach.

func (*ClusterVerification) WaitFor

func (cl *ClusterVerification) WaitFor(ctx context.Context, atLeast int, timeout time.Duration) ([]v1.Pod, error)

WaitFor waits for some minimum number of pods to be verified, according to the PodStateVerification definition.

func (*ClusterVerification) WaitForOrFail

func (cl *ClusterVerification) WaitForOrFail(ctx context.Context, atLeast int, timeout time.Duration)

WaitForOrFail provides a shorthand WaitFor with failure as an option if anything goes wrong.

type CreateTestingNSFn

CreateTestingNSFn is a func that is responsible for creating namespace used for executing e2e tests.

type CreateTestingNSFn func(ctx context.Context, baseName string, c clientset.Interface, labels map[string]string) (*v1.Namespace, error)

type DumpAllNamespaceInfoAction

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

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

type Environment

Environment is the name for the environment in which a test can run, like "Linux" or "Windows".

type Environment string

type Factory

Factory is a func which operates provider specific behavior.

type Factory func() (ProviderInterface, error)

type FailureError

FailureError is an error where the error string is meant to be passed to ginkgo.Fail directly, i.e. adding some prefix like "unexpected error" is not necessary. It is also not necessary to dump the error struct.

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

func (FailureError) Backtrace

func (f FailureError) Backtrace() string

func (FailureError) Error

func (f FailureError) Error() string

func (FailureError) Is

func (f FailureError) Is(target error) bool

type Feature

Feature is the name of a certain feature that the cluster under test must have. Such features are different from feature gates.

type Feature string

type FlakeReport

FlakeReport is a struct for managing the flake report.

type FlakeReport struct {
    Flakes     []string `json:"flakes"`
    FlakeCount int      `json:"flakeCount"`
    // contains filtered or unexported fields
}

func NewFlakeReport

func NewFlakeReport() *FlakeReport

NewFlakeReport returns a new flake report.

func (*FlakeReport) GetFlakeCount

func (f *FlakeReport) GetFlakeCount() int

GetFlakeCount returns the flake count.

func (*FlakeReport) PrintHumanReadable

func (f *FlakeReport) PrintHumanReadable() string

PrintHumanReadable returns string of flake report.

func (*FlakeReport) PrintJSON

func (f *FlakeReport) PrintJSON() string

PrintJSON returns the summary of frake report with JSON format.

func (*FlakeReport) RecordFlakeIfError

func (f *FlakeReport) RecordFlakeIfError(err error, optionalDescription ...interface{})

RecordFlakeIfError records the error (if non-nil) as a flake along with an optional description. This can be used as a replacement of framework.ExpectNoError() for non-critical errors that can be considered as 'flakes' to avoid causing failures in tests.

func (*FlakeReport) SummaryKind

func (f *FlakeReport) SummaryKind() string

SummaryKind returns the summary of flake report.

type Framework

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.

You can configure the pod security level for your test by setting the `NamespacePodSecurityLevel` which will set all three of pod security admission enforce, warn and audit labels on the namespace. The default pod security profile is "restricted". Each of the labels can be overridden by using more specific NamespacePodSecurity* attributes of this struct.

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
    KubemarkExternalClusterClientSet clientset.Interface

    DynamicClient dynamic.Interface

    ScalesGetter scaleclient.ScalesGetter

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

    NamespaceDeletionTimeout         time.Duration
    NamespacePodSecurityEnforceLevel admissionapi.Level // The pod security enforcement level for namespaces to be applied.
    NamespacePodSecurityWarnLevel    admissionapi.Level // The pod security warn (client logging) level for namespaces to be applied.
    NamespacePodSecurityAuditLevel   admissionapi.Level // The pod security audit (server logging) level for namespaces to be applied.
    NamespacePodSecurityLevel        admissionapi.Level // The pod security level to be used for all of enforcement, warn and audit. Can be rewritten by more specific configuration attributes.

    // 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

    // Timeouts contains the custom timeouts used during the test execution.
    Timeouts *TimeoutContext

    // DumpAllNamespaceInfo is invoked by the framework to record
    // information about a namespace after a test failure.
    DumpAllNamespaceInfo DumpAllNamespaceInfoAction
    // contains filtered or unexported fields
}

func NewDefaultFramework

func NewDefaultFramework(baseName string) *Framework

NewDefaultFramework makes a new framework and sets up a BeforeEach which initializes the framework instance. It cleans up with a DeferCleanup, which runs last, so a AfterEach in the test still has a valid framework instance.

func NewFramework

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

NewFramework creates a test framework.

func NewFrameworkWithCustomTimeouts

func NewFrameworkWithCustomTimeouts(baseName string, timeouts *TimeoutContext) *Framework

NewFrameworkWithCustomTimeouts makes a framework with custom timeouts. For timeout values that are zero the normal default value continues to be used.

func (*Framework) AddNamespacesToDelete

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

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

func (*Framework) AfterEach

func (f *Framework) AfterEach(ctx context.Context)

AfterEach deletes the namespace, after reading its events.

func (*Framework) BeforeEach

func (f *Framework) BeforeEach(ctx context.Context)

BeforeEach gets a client and makes a namespace.

func (*Framework) ClientConfig

func (f *Framework) ClientConfig() *rest.Config

ClientConfig an externally accessible method for reading the kube client config.

func (*Framework) Context

func (f *Framework) Context(args ...interface{}) bool

Context is a shorthand for the corresponding package function.

func (*Framework) CreateNamespace

func (f *Framework) CreateNamespace(ctx context.Context, baseName string, labels map[string]string) (*v1.Namespace, error)

CreateNamespace creates a namespace for e2e testing.

func (*Framework) DeleteNamespace

func (f *Framework) DeleteNamespace(ctx context.Context, name string)

DeleteNamespace can be used to delete a namespace. Additionally it can be used to dump namespace information so as it can be used as an alternative of framework deleting the namespace towards the end.

func (*Framework) Describe

func (f *Framework) Describe(args ...interface{}) bool

Describe is a shorthand for the corresponding package function.

func (*Framework) It

func (f *Framework) It(args ...interface{}) bool

It is a shorthand for the corresponding package function.

func (*Framework) NewClusterVerification

func (f *Framework) NewClusterVerification(namespace *v1.Namespace, filter PodStateVerification) *ClusterVerification

NewClusterVerification creates a new cluster verification.

func (*Framework) RecordFlakeIfError

func (f *Framework) RecordFlakeIfError(err error, optionalDescription ...interface{})

RecordFlakeIfError records flakeness info if error happens. NOTE: This function is not used at any places yet, but we are in progress for https://github.com/kubernetes/kubernetes/issues/66239 which requires this. Please don't remove this.

func (*Framework) WithConformance

func (f *Framework) WithConformance() interface{}

WithConformance is a shorthand for the corresponding package function.

func (*Framework) WithDisruptive

func (f *Framework) WithDisruptive() interface{}

WithDisruptive is a shorthand for the corresponding package function.

func (*Framework) WithEnvironment

func (f *Framework) WithEnvironment(name Environment) interface{}

WithEnvironment is a shorthand for the corresponding package function.

func (*Framework) WithFeature

func (f *Framework) WithFeature(name Feature) interface{}

WithFeature is a shorthand for the corresponding package function.

func (*Framework) WithFeatureGate

func (f *Framework) WithFeatureGate(featureGate featuregate.Feature) interface{}

WithFeatureGate is a shorthand for the corresponding package function.

func (*Framework) WithFlaky

func (f *Framework) WithFlaky() interface{}

WithFlaky is a shorthand for the corresponding package function.

func (*Framework) WithLabel

func (f *Framework) WithLabel(label string) interface{}

WithLabel is a shorthand for the corresponding package function.

func (*Framework) WithNodeConformance

func (f *Framework) WithNodeConformance() interface{}

WithNodeConformance is a shorthand for the corresponding package function.

func (*Framework) WithNodeFeature

func (f *Framework) WithNodeFeature(name NodeFeature) interface{}

WithNodeFeature is a shorthand for the corresponding package function.

func (*Framework) WithSerial

func (f *Framework) WithSerial() interface{}

WithSerial is a shorthand for the corresponding package function.

func (*Framework) WithSlow

func (f *Framework) WithSlow() interface{}

WithSlow is a shorthand for the corresponding package function.

type GetFunc

GetFunc is a function which retrieves a certain object.

type GetFunc[T any] func(ctx context.Context) (T, error)

func GetObject

func GetObject[T any](get APIGetFunc[T], name string, getOptions metav1.GetOptions) GetFunc[T]

GetObject takes a get function like clientset.CoreV1().Pods(ns).Get and the parameters for it and returns a function that executes that get operation in a gomega.Eventually or gomega.Consistently.

Delays and retries are handled by HandleRetry. A "not found" error is a fatal error that causes polling to stop immediately. If that is not desired, then wrap the result with IgnoreNotFound.

func HandleRetry

func HandleRetry[T any](get GetFunc[T]) GetFunc[T]

HandleRetry wraps an arbitrary get function. When the wrapped function returns an error, HandleGetError will decide whether the call should be retried and if requested, will sleep before doing so.

This is meant to be used inside gomega.Eventually or gomega.Consistently.

func ListObjects

func ListObjects[T any](list APIListFunc[T], listOptions metav1.ListOptions) GetFunc[T]

ListObjects takes a list function like clientset.CoreV1().Pods(ns).List and the parameters for it and returns a function that executes that list operation in a gomega.Eventually or gomega.Consistently.

Delays and retries are handled by HandleRetry.

func RetryNotFound

func RetryNotFound[T any](get GetFunc[T]) GetFunc[T]

RetryNotFound wraps an arbitrary get function. When the wrapped function encounters a "not found" error, that error is treated as a transient problem and polling continues.

This is meant to be used inside gomega.Eventually or gomega.Consistently.

type GomegaInstance

type GomegaInstance interface {
    Expect(actual interface{}) Assertion
    Eventually(ctx context.Context, args ...interface{}) AsyncAssertion
    Consistently(ctx context.Context, args ...interface{}) AsyncAssertion
}

func Gomega

func Gomega() GomegaInstance

Gomega returns an interface that can be used like gomega to express assertions. The difference is that failed assertions are returned as an error:

if err := Gomega().Expect(pod.Status.Phase).To(gomega.Equal(v1.Running)); err != nil {
    return fmt.Errorf("test pod not running: %w", err)
}

This error can get wrapped to provide additional context for the failure. The test then should use ExpectNoError to turn a non-nil error into a failure.

When using this approach, there is no need for call offsets and extra descriptions for the Expect call because the call stack will be dumped when ExpectNoError is called and the additional description(s) can be added by wrapping the error.

Asynchronous assertions use the framework's Poll interval and PodStart timeout by default.

type KubeCluster

KubeCluster is a struct for managing kubernetes cluster info.

type KubeCluster struct {
    Name    string `yaml:"name"`
    Cluster struct {
        CertificateAuthorityData string `yaml:"certificate-authority-data"`
        Server                   string `yaml:"server"`
    } `yaml:"cluster"`
}

type KubeConfig

KubeConfig is a struct for managing kubernetes config.

type KubeConfig struct {
    Contexts []struct {
        Name    string `yaml:"name"`
        Context struct {
            Cluster string `yaml:"cluster"`
            User    string
        } `yaml:"context"`
    } `yaml:"contexts"`

    Clusters []KubeCluster `yaml:"clusters"`

    Users []KubeUser `yaml:"users"`
}

func (*KubeConfig) FindCluster

func (kc *KubeConfig) FindCluster(name string) *KubeCluster

FindCluster returns cluster info which is the specified cluster name.

func (*KubeConfig) FindUser

func (kc *KubeConfig) FindUser(name string) *KubeUser

FindUser returns user info which is the specified user name.

type KubeUser

KubeUser is a struct for managing kubernetes user info.

type KubeUser struct {
    Name string `yaml:"name"`
    User struct {
        Username string `yaml:"username"`
        Password string `yaml:"password" datapolicy:"password"`
        Token    string `yaml:"token" datapolicy:"token"`
    } `yaml:"user"`
}

type NamedObject

NamedObject is a subset of metav1.Object which provides read-only access to name and namespace of an object.

type NamedObject interface {
    GetNamespace() string
    GetName() string
}

type NamespacedName

NamespacedName comprises a resource name, with a mandatory namespace, rendered as "<namespace>/<name>". It implements NamedObject and thus can be used as function parameter instead of a full API object.

type NamespacedName struct {
    Namespace string
    Name      string
}

func (NamespacedName) GetName

func (n NamespacedName) GetName() string

GetName implements NamedObject.

func (NamespacedName) GetNamespace

func (n NamespacedName) GetNamespace() string

GetNamespace implements NamedObject.

func (NamespacedName) String

func (n NamespacedName) String() string

String returns the general purpose string representation

type NodeFeature

NodeFeature is the name of a feature that a node must support. To be removed, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-testing/3041-node-conformance-and-features#nodefeature.

type NodeFeature string

type NodeKillerConfig

NodeKillerConfig describes configuration of NodeKiller -- a utility to simulate node failures.

TODO: move this and the corresponding command line flags into test/e2e/framework/node.

type NodeKillerConfig struct {
    // Enabled determines whether NodeKill should do anything at all.
    // All other options below are ignored if Enabled = false.
    Enabled bool
    // FailureRatio is a percentage of all nodes that could fail simultinously.
    FailureRatio float64
    // Interval is time between node failures.
    Interval time.Duration
    // JitterFactor is factor used to jitter node failures.
    // Node will be killed between [Interval, Interval + (1.0 + JitterFactor)].
    JitterFactor float64
    // SimulatedDowntime is a duration between node is killed and recreated.
    SimulatedDowntime time.Duration
    // NodeKillerStopCtx is a context that is used to notify NodeKiller to stop killing nodes.
    NodeKillerStopCtx context.Context
    // NodeKillerStop is the cancel function for NodeKillerStopCtx.
    NodeKillerStop func()
}

type NodeTestContextType

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

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
    // RuntimeConfig is a map of API server runtime configuration values.
    RuntimeConfig map[string]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
    // RestartKubelet restarts Kubelet unit when the process is killed.
    RestartKubelet bool
    // ExtraEnvs is a map of environment names to values.
    ExtraEnvs map[string]string
    // StandaloneMode indicates whether the test is running kubelet in a standalone mode.
    StandaloneMode bool
}

type NullProvider

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

type NullProvider struct{}

func (NullProvider) CleanupServiceResources

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

CleanupServiceResources is a base implementation which cleans up service resources.

func (NullProvider) CreatePD

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

CreatePD is a base implementation which creates PD.

func (NullProvider) CreatePVSource

func (n NullProvider) CreatePVSource(ctx context.Context, zone, diskName string) (*v1.PersistentVolumeSource, error)

CreatePVSource is a base implementation which creates PV source.

func (NullProvider) CreateShare

func (n NullProvider) CreateShare() (string, string, string, error)

func (NullProvider) DeleteNode

func (n NullProvider) DeleteNode(node *v1.Node) error

DeleteNode is a base implementation which deletes a node.

func (NullProvider) DeletePD

func (n NullProvider) DeletePD(pdName string) error

DeletePD is a base implementation which deletes PD.

func (NullProvider) DeletePVSource

func (n NullProvider) DeletePVSource(ctx context.Context, pvSource *v1.PersistentVolumeSource) error

DeletePVSource is a base implementation which deletes PV source.

func (NullProvider) DeleteShare

func (n NullProvider) DeleteShare(accountName, shareName string) error

func (NullProvider) EnableAndDisableInternalLB

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

EnableAndDisableInternalLB is a base implementation which returns functions for enabling/disabling an internal LB.

func (NullProvider) EnsureLoadBalancerResourcesDeleted

func (n NullProvider) EnsureLoadBalancerResourcesDeleted(ctx context.Context, ip, portRange string) error

EnsureLoadBalancerResourcesDeleted is a base implementation which ensures load balancer is deleted.

func (NullProvider) FrameworkAfterEach

func (n NullProvider) FrameworkAfterEach(f *Framework)

FrameworkAfterEach is a base implementation which does AfterEach.

func (NullProvider) FrameworkBeforeEach

func (n NullProvider) FrameworkBeforeEach(f *Framework)

FrameworkBeforeEach is a base implementation which does BeforeEach.

func (NullProvider) GetGroupNodes

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

GetGroupNodes is a base implementation which returns group nodes.

func (NullProvider) GroupSize

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

GroupSize returns the size of an instance group

func (NullProvider) LoadBalancerSrcRanges

func (n NullProvider) LoadBalancerSrcRanges() []string

LoadBalancerSrcRanges is a base implementation which returns the ranges of ips used by load balancers.

func (NullProvider) ResizeGroup

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

ResizeGroup is a base implementation which resizes group.

type Options

Options is a struct for managing test framework options.

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

type PodStateVerification

PodStateVerification represents a verification of pod state. Any time you have a set of pods that you want to operate against or query, this struct can be used to declaratively identify those pods.

type PodStateVerification struct {
    // Optional: only pods that have k=v labels will pass this filter.
    Selectors map[string]string

    // Required: The phases which are valid for your pod.
    ValidPhases []v1.PodPhase

    // Optional: only pods passing this function will pass the filter
    // Verify a pod.
    // As an optimization, in addition to specifying filter (boolean),
    // this function allows specifying an error as well.
    // The error indicates that the polling of the pod spectrum should stop.
    Verify func(v1.Pod) (bool, error)

    // Optional: only pods with this name will pass the filter.
    PodName string
}

type ProviderInterface

ProviderInterface contains the implementation for certain provider-specific functionality.

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)

    DeleteNode(node *v1.Node) error

    CreatePD(zone string) (string, error)
    DeletePD(pdName string) error
    CreateShare() (string, string, string, error)
    DeleteShare(accountName, shareName string) error

    CreatePVSource(ctx context.Context, zone, diskName string) (*v1.PersistentVolumeSource, error)
    DeletePVSource(ctx context.Context, pvSource *v1.PersistentVolumeSource) error

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

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

func SetupProviderConfig

func SetupProviderConfig(providerName string) (ProviderInterface, error)

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

type TestContextType

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:

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

type TestContextType struct {
    KubeConfig             string
    KubeContext            string
    KubeAPIContentType     string
    KubeletRootDir         string
    KubeletConfigDropinDir string
    CertDir                string
    Host                   string
    BearerToken            string `datapolicy:"token"`
    // TODO: Deprecating this over time... instead just use gobindata_util.go , see #23987.
    RepoRoot string
    // ListImages will list off all images that are used then quit
    ListImages bool

    // ListConformanceTests will list off all conformance tests that are available then quit
    ListConformanceTests bool

    // 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
    ReportCompleteGinkgo        bool
    ReportCompleteJUnit         bool
    Prefix                      string
    MinStartupPods              int
    EtcdUpgradeStorage          string
    EtcdUpgradeVersion          string
    GCEUpgradeScript            string
    ContainerRuntimeEndpoint    string
    ContainerRuntimeProcessName string
    ContainerRuntimePidFile     string
    // SystemdServices are comma separated list of systemd services the test framework
    // will dump logs for.
    SystemdServices string
    // DumpSystemdJournal controls whether to dump the full systemd journal.
    DumpSystemdJournal       bool
    ImageServiceEndpoint     string
    MasterOSDistro           string
    NodeOSDistro             string
    NodeOSArch               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
    MaxNodesToGather                  int
    // 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
    // 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
    // Node e2e specific test context
    NodeTestContextType

    // The DNS Domain of the cluster.
    ClusterDNSDomain string

    // The configuration of NodeKiller.
    NodeKiller NodeKillerConfig

    // The Default IP Family of the cluster ("ipv4" or "ipv6")
    IPFamily string

    // NonblockingTaints is the comma-delimeted string given by the user to specify taints which should not stop the test framework from running tests.
    NonblockingTaints string

    // ProgressReportURL is the URL which progress updates will be posted to as tests complete. If empty, no updates are sent.
    ProgressReportURL string

    // SriovdpConfigMapFile is the path to the ConfigMap to configure the SRIOV device plugin on this host.
    SriovdpConfigMapFile string

    // SpecSummaryOutput is the file to write ginkgo.SpecSummary objects to as tests complete. Useful for debugging and test introspection.
    SpecSummaryOutput string

    // DockerConfigFile is a file that contains credentials which can be used to pull images from certain private registries, needed for a test.
    DockerConfigFile string

    // E2EDockerConfigFile is a docker credentials configuration file used which contains authorization token that can be used to pull images from certain private registries provided by the users.
    // For more details refer https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#log-in-to-docker-hub
    E2EDockerConfigFile string

    // KubeTestRepoConfigFile is a yaml file used for overriding registries for test images.
    KubeTestRepoList string

    // SnapshotControllerPodName is the name used for identifying the snapshot controller pod.
    SnapshotControllerPodName string

    // SnapshotControllerHTTPPort the port used for communicating with the snapshot controller HTTP endpoint.
    SnapshotControllerHTTPPort int

    // RequireDevices makes mandatory on the environment on which tests are run 1+ devices exposed through device plugins.
    // With this enabled The e2e tests requiring devices for their operation can assume that if devices aren't reported, the test can fail
    RequireDevices bool

    // Enable volume drivers which are disabled by default. See test/e2e/storage/in_tree_volumes.go for details.
    EnabledVolumeDrivers []string
    // contains filtered or unexported fields
}

func (TestContextType) ClusterIsIPv6

func (tc TestContextType) ClusterIsIPv6() bool

ClusterIsIPv6 returns true if the cluster is IPv6

type TestDataSummary

TestDataSummary is an interface for managing test data.

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

type TimeoutContext

TimeoutContext contains timeout settings for several actions.

type TimeoutContext struct {
    // Poll is how long to wait between API calls when waiting for some condition.
    Poll time.Duration

    // PodStart is how long to wait for the pod to be started.
    // This value is the default for gomega.Eventually.
    PodStart time.Duration

    // PodStartShort is same as `PodStart`, but shorter.
    // Use it in a case-by-case basis, mostly when you are sure pod start will not be delayed.
    // This value is the default for gomega.Consistently.
    PodStartShort time.Duration

    // PodStartSlow is same as `PodStart`, but longer.
    // Use it in a case-by-case basis, mostly when you are sure pod start will take longer than usual.
    PodStartSlow time.Duration

    // PodDelete is how long to wait for the pod to be deleted.
    PodDelete time.Duration

    // ClaimProvision is how long claims have to become dynamically provisioned.
    ClaimProvision time.Duration

    // DataSourceProvision is how long claims have to become dynamically provisioned from source claim.
    DataSourceProvision time.Duration

    // ClaimProvisionShort is the same as `ClaimProvision`, but shorter.
    ClaimProvisionShort time.Duration

    // ClaimBound is how long claims have to become bound.
    ClaimBound time.Duration

    // PVReclaim is how long PVs have to become reclaimed.
    PVReclaim time.Duration

    // PVBound is how long PVs have to become bound.
    PVBound time.Duration

    // PVCreate is how long PVs have to be created.
    PVCreate time.Duration

    // PVDelete is how long PVs have to become deleted.
    PVDelete time.Duration

    // PVDeleteSlow is the same as PVDelete, but slower.
    PVDeleteSlow time.Duration

    // SnapshotCreate is how long for snapshot to create snapshotContent.
    SnapshotCreate time.Duration

    // SnapshotDelete is how long for snapshot to delete snapshotContent.
    SnapshotDelete time.Duration

    // SnapshotControllerMetrics is how long to wait for snapshot controller metrics.
    SnapshotControllerMetrics time.Duration

    // SystemPodsStartup is how long to wait for system pods to be running.
    SystemPodsStartup time.Duration

    // NodeSchedulable is how long to wait for all nodes to be schedulable.
    NodeSchedulable time.Duration

    // SystemDaemonsetStartup is how long to wait for all system daemonsets to be ready.
    SystemDaemonsetStartup time.Duration

    // NodeNotReady is how long to wait for a node to be not ready.
    NodeNotReady time.Duration
}

func NewTimeoutContext

func NewTimeoutContext() *TimeoutContext

NewTimeoutContext returns a TimeoutContext with all values set either to hard-coded defaults or a value that was configured when running the E2E suite. Should be called after command line parsing.

type Valid

type Valid[T comparable] struct {
    // contains filtered or unexported fields
}

These variables contain the parameters that WithFeature, WithEnvironment and [WithNodeFeatures] accept. The framework itself has no pre-defined constants. Test suites and tests may define their own and then add them here before calling these With functions.

var (
    ValidFeatures     Valid[Feature]
    ValidEnvironments Valid[Environment]
    ValidNodeFeatures Valid[NodeFeature]
)

func (*Valid[T]) Add

func (v *Valid[T]) Add(item T) T

Add registers a new valid item name. The expected usage is

var SomeFeature = framework.ValidFeatures.Add("Some")

during the init phase of an E2E suite. Individual tests should not register their own, to avoid uncontrolled proliferation of new items. E2E suites can, but don't have to, enforce that by freezing the set of valid names.

func (*Valid[T]) Freeze

func (v *Valid[T]) Freeze()

Subdirectories

Name Synopsis
..
auth
autoscaling
config Package config simplifies the declaration of configuration options.
daemonset
debug
init Package init sets debug.DumpAllNamespaceInfo as implementation in the framework and enables log size verification and resource gathering.
deployment
endpoints
endpointslice
events
gpu
ingress
job
kubectl
kubelet
kubesystem
manifest
metrics
init Package init installs GrabBeforeEach and GrabAfterEach as callbacks for gathering data before and after a test.
network
node
init Package init registers node.AllNodesReady.
runtimeclass
perf
pod
output
providers
aws
azure
gce
kubemark
openstack
vsphere
pv
rc
replicaset
resource
security
service
skipper
ssh
statefulset
testfiles Package testfiles provides a wrapper around various optional ways of retrieving additional files needed during a test run: - builtin bindata - filesystem access
timer
volume
websocket