Documentation ¶
Index ¶
- Constants
- Variables
- func AfterReadingAllFlags(t *TestContextType)
- func AllNodesReady(c clientset.Interface, timeout time.Duration) error
- func ConformanceIt(text string, body interface{}, timeout ...float64) bool
- func CreatePV(c clientset.Interface, pv *v1.PersistentVolume) (*v1.PersistentVolume, error)
- func CreateServiceSpec(serviceName, externalName string, isHeadless bool, selector map[string]string) *v1.Service
- func CreateStatefulSetService(name string, labels map[string]string) *v1.Service
- func CreateTestingNS(baseName string, c clientset.Interface, labels map[string]string) (*v1.Namespace, error)
- func DeleteAllStatefulSets(c clientset.Interface, kc kruiseclientset.Interface, ns string)
- func DumpAllNamespaceInfo(c clientset.Interface, namespace string)
- func DumpDebugInfo(c clientset.Interface, ns string)
- func DumpEventsInNamespace(eventsLister EventsLister, namespace string)
- func ExpectNoError(err error, explain ...interface{})
- func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{})
- func ExpectNoErrorWithRetries(fn func() error, maxRetries int, explain ...interface{})
- func Failf(format string, args ...interface{})
- func FailfWithOffset(offset int, format string, args ...interface{})
- func FilterNodes(nodeList *v1.NodeList, fn func(node v1.Node) bool)
- func GetReadySchedulableNodesOrDie(c clientset.Interface) (nodes *v1.NodeList)
- func HandleFlags()
- func IsNodeConditionSetAsExpected(node *v1.Node, conditionType v1.NodeConditionType, wantTrue bool) bool
- func IsNodeConditionSetAsExpectedSilent(node *v1.Node, conditionType v1.NodeConditionType, wantTrue bool) bool
- func IsNodeConditionUnset(node *v1.Node, conditionType v1.NodeConditionType) bool
- func KruiseDescribe(text string, body func()) bool
- func KubectlCmd(args ...string) *exec.Cmd
- func LoadClientset() (*clientset.Clientset, error)
- func LoadConfig() (*restclient.Config, error)
- func Logf(format string, args ...interface{})
- func NewKubectlCommand(args ...string) *kubectlBuilder
- func NewStatefulSet(name, ns, governingSvcName string, replicas int32, ...) *appsv1alpha1.StatefulSet
- func NewStatefulSetPVC(name string) v1.PersistentVolumeClaim
- func NewStatefulSetScale(ss *appsv1alpha1.StatefulSet) *appsV1beta2.Scale
- func RegisterClusterFlags()
- func RegisterCommonFlags()
- func RegisterNodeFlags()
- func RegisterProvider(name string, factory Factory)
- func RemoveCleanupAction(p CleanupActionHandle)
- func RestclientConfig(kubeContext string) (*clientcmdapi.Config, error)
- func RunCleanupActions()
- func RunHostCmd(ns, name, cmd string) (string, error)
- func RunHostCmdWithRetries(ns, name, cmd string, interval, timeout time.Duration) (string, error)
- func RunKubectl(args ...string) (string, error)
- func RunKubectlOrDie(args ...string) string
- func Skipf(format string, args ...interface{})
- func UpdateStatefulSetWithRetries(kc kruiseclientset.Interface, namespace, name string, ...) (statefulSet *appsv1alpha1.StatefulSet, err error)
- func WaitForDefaultServiceAccountInNamespace(c clientset.Interface, namespace string) error
- func WaitForPodCondition(c clientset.Interface, ns, podName, desc string, timeout time.Duration, ...) error
- func WaitForPodNameRunningInNamespace(c clientset.Interface, podName, namespace string) error
- func WaitForPodRunningInNamespace(c clientset.Interface, pod *v1.Pod) error
- func WaitTimeoutForPodRunningInNamespace(c clientset.Interface, podName, namespace string, timeout time.Duration) error
- type CleanupActionHandle
- type ClientConfigGetter
- type CloudConfig
- type CreateTestingNSFn
- type EventsLister
- type Factory
- type Framework
- func (f *Framework) AddNamespacesToDelete(namespaces ...*v1.Namespace)
- func (f *Framework) AfterEach()
- func (f *Framework) BeforeEach()
- func (f *Framework) CreateNamespace(baseName string, labels map[string]string) (*v1.Namespace, error)
- func (f *Framework) PodClient() *PodClient
- func (f *Framework) WaitForPodRunning(podName string) error
- type FrameworkOptions
- type NodeTestContextType
- type NullProvider
- func (n NullProvider) CleanupServiceResources(c clientset.Interface, loadBalancerName, region, zone string)
- func (n NullProvider) CreatePD(zone string) (string, error)
- func (n NullProvider) CreatePVSource(zone, diskName string) (*v1.PersistentVolumeSource, error)
- func (n NullProvider) DeletePD(pdName string) error
- func (n NullProvider) DeletePVSource(pvSource *v1.PersistentVolumeSource) error
- func (n NullProvider) EnableAndDisableInternalLB() (enable, disable func(svc *v1.Service))
- func (n NullProvider) EnsureLoadBalancerResourcesDeleted(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 PodClient
- type ProviderInterface
- type StatefulSetTester
- func (s *StatefulSetTester) BreakHttpProbe(ss *appsv1alpha1.StatefulSet) error
- func (s *StatefulSetTester) BreakPodHttpProbe(ss *appsv1alpha1.StatefulSet, pod *v1.Pod) error
- func (s *StatefulSetTester) CheckHostname(ss *appsv1alpha1.StatefulSet) error
- func (s *StatefulSetTester) CheckMount(ss *appsv1alpha1.StatefulSet, mountPath string) error
- func (p *StatefulSetTester) CheckServiceName(ss *appsv1alpha1.StatefulSet, expectedServiceName string) error
- func (s *StatefulSetTester) ConfirmStatefulPodCount(count int, ss *appsv1alpha1.StatefulSet, timeout time.Duration, hard bool)
- func (s *StatefulSetTester) CreateStatefulSet(manifestPath, ns string) *appsv1alpha1.StatefulSet
- func (s *StatefulSetTester) DeleteStatefulPodAtIndex(index int, ss *appsv1alpha1.StatefulSet)
- func (s *StatefulSetTester) ExecInStatefulPods(ss *appsv1alpha1.StatefulSet, cmd string) error
- func (s *StatefulSetTester) GetPodList(ss *appsv1alpha1.StatefulSet) *v1.PodList
- func (s *StatefulSetTester) GetStatefulSet(namespace, name string) *appsv1alpha1.StatefulSet
- func (s *StatefulSetTester) PauseNewPods(ss *appsv1alpha1.StatefulSet)
- func (s *StatefulSetTester) Restart(ss *appsv1alpha1.StatefulSet)
- func (s *StatefulSetTester) RestoreHttpProbe(ss *appsv1alpha1.StatefulSet) error
- func (s *StatefulSetTester) RestorePodHttpProbe(ss *appsv1alpha1.StatefulSet, pod *v1.Pod) error
- func (s *StatefulSetTester) ResumeNextPod(ss *appsv1alpha1.StatefulSet)
- func (s *StatefulSetTester) Saturate(ss *appsv1alpha1.StatefulSet)
- func (s *StatefulSetTester) Scale(ss *appsv1alpha1.StatefulSet, count int32) (*appsv1alpha1.StatefulSet, error)
- func (s *StatefulSetTester) SetHttpProbe(ss *appsv1alpha1.StatefulSet)
- func (s *StatefulSetTester) SortStatefulPods(pods *v1.PodList)
- func (s *StatefulSetTester) UpdateReplicas(ss *appsv1alpha1.StatefulSet, count int32)
- func (s *StatefulSetTester) VerifyPodAtIndex(index int, ss *appsv1alpha1.StatefulSet, verify VerifyStatefulPodFunc)
- func (s *StatefulSetTester) WaitForPartitionedRollingUpdate(set *appsv1alpha1.StatefulSet) (*appsv1alpha1.StatefulSet, *v1.PodList)
- func (s *StatefulSetTester) WaitForPodNotReady(set *appsv1alpha1.StatefulSet, podName string) (*appsv1alpha1.StatefulSet, *v1.PodList)
- func (s *StatefulSetTester) WaitForPodReady(set *appsv1alpha1.StatefulSet, podName string) (*appsv1alpha1.StatefulSet, *v1.PodList)
- func (s *StatefulSetTester) WaitForRollingUpdate(set *appsv1alpha1.StatefulSet) (*appsv1alpha1.StatefulSet, *v1.PodList)
- func (s *StatefulSetTester) WaitForRunning(numPodsRunning, numPodsReady int32, ss *appsv1alpha1.StatefulSet)
- func (s *StatefulSetTester) WaitForRunningAndNotReady(numStatefulPods int32, ss *appsv1alpha1.StatefulSet)
- func (s *StatefulSetTester) WaitForRunningAndReady(numStatefulPods int32, ss *appsv1alpha1.StatefulSet)
- func (s *StatefulSetTester) WaitForState(ss *appsv1alpha1.StatefulSet, ...)
- func (s *StatefulSetTester) WaitForStatus(set *appsv1alpha1.StatefulSet) *appsv1alpha1.StatefulSet
- func (s *StatefulSetTester) WaitForStatusReadyReplicas(ss *appsv1alpha1.StatefulSet, expectedReplicas int32)
- func (s *StatefulSetTester) WaitForStatusReplicas(ss *appsv1alpha1.StatefulSet, expectedReplicas int32)
- type TestContextType
- type TestDataSummary
- type VerifyStatefulPodFunc
Constants ¶
const ( // Poll interval for StatefulSet tests StatefulSetPoll = 10 * time.Second // Timeout interval for StatefulSet operations StatefulSetTimeout = 10 * time.Minute // Timeout for stateful pods to change state StatefulPodTimeout = 5 * time.Minute )
const ( // How long to wait for the pod to be listable PodListTimeout = time.Minute // 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 // 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 // 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 // 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 // How long to wait for a service endpoint to be resolvable. ServiceStartTimeout = 3 * time.Minute // How often to Poll pods, nodes and claims. Poll = 2 * time.Second // 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 // 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 // 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 // How long pods have to be "ready" when a test begins. PodReadyBeforeTimeout = 5 * time.Minute ServiceRespondingTimeout = 2 * time.Minute EndpointRegisterTimeout = time.Minute // How long claims have to become dynamically provisioned ClaimProvisionTimeout = 5 * time.Minute // 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 // How long claims have to become bound ClaimBindingTimeout = 3 * time.Minute // How long claims have to become deleted ClaimDeletingTimeout = 3 * time.Minute // How long PVs have to beome reclaimed PVReclaimingTimeout = 3 * time.Minute // How long PVs have to become bound PVBindingTimeout = 3 * time.Minute // How long PVs have to become deleted PVDeletingTimeout = 3 * time.Minute // How long a node is allowed to become "Ready" after it is restarted before // the test is considered failed. RestartNodeReadyAgainTimeout = 5 * time.Minute // How long a pod is allowed to become "running" and "ready" after a node // restart before test is considered failed. RestartPodReadyAgainTimeout = 5 * time.Minute )
const ( // TODO(mikedanese): reset this to 5 minutes once #47135 is resolved. // ref https://github.com/kubernetes/kubernetes/issues/47135 DefaultNamespaceDeletionTimeout = 10 * time.Minute )
Variables ¶
var ( // UnreachableTaintTemplate is the taint for when a node becomes unreachable. UnreachableTaintTemplate = &v1.Taint{ Key: schedulerapi.TaintNodeUnreachable, Effect: v1.TaintEffectNoExecute, } NotReadyTaintTemplate = &v1.Taint{ Key: schedulerapi.TaintNodeNotReady, Effect: v1.TaintEffectNoExecute, } )
var RunId = uuid.NewUUID()
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 ¶
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 ¶
Wrapper function for ginkgo It. Adds "[Conformance]" tag and makes static analysis easier.
func CreatePV ¶
func CreatePV(c clientset.Interface, pv *v1.PersistentVolume) (*v1.PersistentVolume, error)
create the PV resource. Fails test on error.
func CreateServiceSpec ¶
func CreateStatefulSetService ¶
CreateStatefulSetService creates a Headless Service with Name name and Selector set to match labels.
func CreateTestingNS ¶
func CreateTestingNS(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 DeleteAllStatefulSets ¶
func DeleteAllStatefulSets(c clientset.Interface, kc kruiseclientset.Interface, ns string)
DeleteAllStatefulSets deletes all StatefulSet API Objects in Namespace ns.
func DumpAllNamespaceInfo ¶
func DumpDebugInfo ¶
func DumpEventsInNamespace ¶
func DumpEventsInNamespace(eventsLister EventsLister, namespace string)
func ExpectNoError ¶
func ExpectNoError(err error, explain ...interface{})
func ExpectNoErrorWithOffset ¶
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 FailfWithOffset ¶
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 ¶
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 ¶
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 IsNodeConditionUnset ¶
func IsNodeConditionUnset(node *v1.Node, conditionType v1.NodeConditionType) bool
func KruiseDescribe ¶
Wrapper function for ginkgo describe. Adds namespacing.
func KubectlCmd ¶
KubectlCmd runs the kubectl executable through the wrapper script.
func LoadClientset ¶
func LoadConfig ¶
func LoadConfig() (*restclient.Config, error)
func NewKubectlCommand ¶
func NewKubectlCommand(args ...string) *kubectlBuilder
func NewStatefulSet ¶
func NewStatefulSet(name, ns, governingSvcName string, replicas int32, statefulPodMounts []v1.VolumeMount, podMounts []v1.VolumeMount, labels map[string]string) *appsv1alpha1.StatefulSet
NewStatefulSet creates a new NGINX StatefulSet for testing. The StatefulSet is named name, is in namespace ns, statefulPodsMounts are the mounts that will be backed by PVs. podsMounts are the mounts that are mounted directly to the Pod. labels are the labels that will be usd for the StatefulSet selector.
func NewStatefulSetPVC ¶
func NewStatefulSetPVC(name string) v1.PersistentVolumeClaim
NewStatefulSetPVC returns a PersistentVolumeClaim named name, for testing StatefulSets.
func NewStatefulSetScale ¶
func NewStatefulSetScale(ss *appsv1alpha1.StatefulSet) *appsV1beta2.Scale
NewStatefulSetScale creates a new StatefulSet scale subresource and returns it
func RegisterClusterFlags ¶
func RegisterClusterFlags()
Register flags specific to the cluster e2e test suite.
func RegisterNodeFlags ¶
func RegisterNodeFlags()
Register flags specific to the node e2e test suite.
func RegisterProvider ¶
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)
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 ¶
RunHostCmd runs the given cmd in the context of the given pod using `kubectl exec` inside of a shell.
func RunHostCmdWithRetries ¶
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 ¶
RunKubectl is a convenience wrapper over kubectlBuilder
func RunKubectlOrDie ¶
RunKubectlOrDie is a convenience wrapper over kubectlBuilder
func UpdateStatefulSetWithRetries ¶
func UpdateStatefulSetWithRetries(kc kruiseclientset.Interface, namespace, name string, applyUpdate updateStatefulSetFunc) (statefulSet *appsv1alpha1.StatefulSet, err error)
func WaitForDefaultServiceAccountInNamespace ¶
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 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 ¶
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.
Types ¶
type CleanupActionHandle ¶
type CleanupActionHandle *int
func AddCleanupAction ¶
func AddCleanupAction(fn func()) CleanupActionHandle
AddCleanupAction installs a function that will be called in the event of the whole test being terminated. This allows arbitrary pieces of the overall test to hook into SynchronizedAfterSuite().
type ClientConfigGetter ¶
type ClientConfigGetter func() (*restclient.Config, error)
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 }
type CreateTestingNSFn ¶
type EventsLister ¶
type Factory ¶
type Factory func() (ProviderInterface, error)
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 KruiseClientSet kruiseclientset.Interface ClientSet clientset.Interface DynamicClient dynamic.Interface ScalesGetter scaleclient.ScalesGetter SkipNamespaceCreation bool // Whether to skip creating a namespace Namespace *v1.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 FrameworkOptions // 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 // 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 ¶
NewFramework 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 FrameworkOptions, client clientset.Interface) *Framework
func (*Framework) AddNamespacesToDelete ¶
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 (*Framework) PodClient ¶
Convenience method for getting a pod client interface in the framework's namespace, possibly applying test-suite specific transformations to the pod spec, e.g. for node e2e pod scheduling.
func (*Framework) WaitForPodRunning ¶
WaitForPodRunning waits for the pod to run in the namespace.
type FrameworkOptions ¶
type FrameworkOptions struct { ClientQPS float32 ClientBurst int GroupVersion *schema.GroupVersion }
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)
func (NullProvider) CreatePVSource ¶
func (n NullProvider) CreatePVSource(zone, diskName string) (*v1.PersistentVolumeSource, error)
func (NullProvider) DeletePD ¶
func (n NullProvider) DeletePD(pdName string) error
func (NullProvider) DeletePVSource ¶
func (n NullProvider) DeletePVSource(pvSource *v1.PersistentVolumeSource) error
func (NullProvider) EnableAndDisableInternalLB ¶
func (n NullProvider) EnableAndDisableInternalLB() (enable, disable func(svc *v1.Service))
func (NullProvider) EnsureLoadBalancerResourcesDeleted ¶
func (n NullProvider) EnsureLoadBalancerResourcesDeleted(ip, portRange string) error
func (NullProvider) FrameworkAfterEach ¶
func (n NullProvider) FrameworkAfterEach(f *Framework)
func (NullProvider) FrameworkBeforeEach ¶
func (n NullProvider) FrameworkBeforeEach(f *Framework)
func (NullProvider) GetGroupNodes ¶
func (n NullProvider) GetGroupNodes(group string) ([]string, error)
func (NullProvider) LoadBalancerSrcRanges ¶
func (n NullProvider) LoadBalancerSrcRanges() []string
func (NullProvider) ResizeGroup ¶
func (n NullProvider) ResizeGroup(string, int32) error
type PodClient ¶
type PodClient struct { v1core.PodInterface // contains filtered or unexported fields }
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) (*v1.PersistentVolumeSource, error) DeletePVSource(pvSource *v1.PersistentVolumeSource) error CleanupServiceResources(c clientset.Interface, loadBalancerName, region, zone string) EnsureLoadBalancerResourcesDeleted(ip, portRange string) error LoadBalancerSrcRanges() []string EnableAndDisableInternalLB() (enable, disable func(svc *v1.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 StatefulSetTester ¶
type StatefulSetTester struct {
// contains filtered or unexported fields
}
StatefulSetTester is a struct that contains utility methods for testing StatefulSet related functionality. It uses a clientset.Interface to communicate with the API server.
func NewStatefulSetTester ¶
func NewStatefulSetTester(c clientset.Interface, kc kruiseclientset.Interface) *StatefulSetTester
NewStatefulSetTester creates a StatefulSetTester that uses c to interact with the API server.
func (*StatefulSetTester) BreakHttpProbe ¶
func (s *StatefulSetTester) BreakHttpProbe(ss *appsv1alpha1.StatefulSet) error
BreakHttpProbe breaks the readiness probe for Nginx StatefulSet containers in ss.
func (*StatefulSetTester) BreakPodHttpProbe ¶
func (s *StatefulSetTester) BreakPodHttpProbe(ss *appsv1alpha1.StatefulSet, pod *v1.Pod) error
BreakPodHttpProbe breaks the readiness probe for Nginx StatefulSet containers in one pod.
func (*StatefulSetTester) CheckHostname ¶
func (s *StatefulSetTester) CheckHostname(ss *appsv1alpha1.StatefulSet) error
CheckHostname verifies that all Pods in ss have the correct Hostname. If the returned error is not nil than verification failed.
func (*StatefulSetTester) CheckMount ¶
func (s *StatefulSetTester) CheckMount(ss *appsv1alpha1.StatefulSet, mountPath string) error
CheckMount checks that the mount at mountPath is valid for all Pods in ss.
func (*StatefulSetTester) CheckServiceName ¶
func (p *StatefulSetTester) CheckServiceName(ss *appsv1alpha1.StatefulSet, expectedServiceName string) error
CheckServiceName asserts that the ServiceName for ss is equivalent to expectedServiceName.
func (*StatefulSetTester) ConfirmStatefulPodCount ¶
func (s *StatefulSetTester) ConfirmStatefulPodCount(count int, ss *appsv1alpha1.StatefulSet, timeout time.Duration, hard bool)
ConfirmStatefulPodCount asserts that the current number of Pods in ss is count waiting up to timeout for ss to to scale to count.
func (*StatefulSetTester) CreateStatefulSet ¶
func (s *StatefulSetTester) CreateStatefulSet(manifestPath, ns string) *appsv1alpha1.StatefulSet
CreateStatefulSet creates a StatefulSet from the manifest at manifestPath in the Namespace ns using kubectl create.
func (*StatefulSetTester) DeleteStatefulPodAtIndex ¶
func (s *StatefulSetTester) DeleteStatefulPodAtIndex(index int, ss *appsv1alpha1.StatefulSet)
DeleteStatefulPodAtIndex deletes the Pod with ordinal index in ss.
func (*StatefulSetTester) ExecInStatefulPods ¶
func (s *StatefulSetTester) ExecInStatefulPods(ss *appsv1alpha1.StatefulSet, cmd string) error
ExecInStatefulPods executes cmd in all Pods in ss. If a error occurs it is returned and cmd is not execute in any subsequent Pods.
func (*StatefulSetTester) GetPodList ¶
func (s *StatefulSetTester) GetPodList(ss *appsv1alpha1.StatefulSet) *v1.PodList
GetPodList gets the current Pods in ss.
func (*StatefulSetTester) GetStatefulSet ¶
func (s *StatefulSetTester) GetStatefulSet(namespace, name string) *appsv1alpha1.StatefulSet
GetStatefulSet gets the StatefulSet named name in namespace.
func (*StatefulSetTester) PauseNewPods ¶
func (s *StatefulSetTester) PauseNewPods(ss *appsv1alpha1.StatefulSet)
PauseNewPods adds an always-failing ReadinessProbe to the StatefulSet PodTemplate. This causes all newly-created Pods to stay Unready until they are manually resumed with ResumeNextPod(). Note that this cannot be used together with SetHttpProbe().
func (*StatefulSetTester) Restart ¶
func (s *StatefulSetTester) Restart(ss *appsv1alpha1.StatefulSet)
Restart scales ss to 0 and then back to its previous number of replicas.
func (*StatefulSetTester) RestoreHttpProbe ¶
func (s *StatefulSetTester) RestoreHttpProbe(ss *appsv1alpha1.StatefulSet) error
RestoreHttpProbe restores the readiness probe for Nginx StatefulSet containers in ss.
func (*StatefulSetTester) RestorePodHttpProbe ¶
func (s *StatefulSetTester) RestorePodHttpProbe(ss *appsv1alpha1.StatefulSet, pod *v1.Pod) error
RestorePodHttpProbe restores the readiness probe for Nginx StatefulSet containers in pod.
func (*StatefulSetTester) ResumeNextPod ¶
func (s *StatefulSetTester) ResumeNextPod(ss *appsv1alpha1.StatefulSet)
ResumeNextPod allows the next Pod in the StatefulSet to continue by removing the ReadinessProbe added by PauseNewPods(), if it's still there. It fails the test if it finds any pods that are not in phase Running, or if it finds more than one paused Pod existing at the same time. This is a no-op if there are no paused pods.
func (*StatefulSetTester) Saturate ¶
func (s *StatefulSetTester) Saturate(ss *appsv1alpha1.StatefulSet)
Saturate waits for all Pods in ss to become Running and Ready.
func (*StatefulSetTester) Scale ¶
func (s *StatefulSetTester) Scale(ss *appsv1alpha1.StatefulSet, count int32) (*appsv1alpha1.StatefulSet, error)
Scale scales ss to count replicas.
func (*StatefulSetTester) SetHttpProbe ¶
func (s *StatefulSetTester) SetHttpProbe(ss *appsv1alpha1.StatefulSet)
SetHttpProbe sets the pod template's ReadinessProbe for Nginx StatefulSet containers. This probe can then be controlled with BreakHttpProbe() and RestoreHttpProbe(). Note that this cannot be used together with PauseNewPods().
func (*StatefulSetTester) SortStatefulPods ¶
func (s *StatefulSetTester) SortStatefulPods(pods *v1.PodList)
SortStatefulPods sorts pods by their ordinals
func (*StatefulSetTester) UpdateReplicas ¶
func (s *StatefulSetTester) UpdateReplicas(ss *appsv1alpha1.StatefulSet, count int32)
UpdateReplicas updates the replicas of ss to count.
func (*StatefulSetTester) VerifyPodAtIndex ¶
func (s *StatefulSetTester) VerifyPodAtIndex(index int, ss *appsv1alpha1.StatefulSet, verify VerifyStatefulPodFunc)
VerifyPodAtIndex applies a visitor patter to the Pod at index in ss. verify is applied to the Pod to "visit" it.
func (*StatefulSetTester) WaitForPartitionedRollingUpdate ¶
func (s *StatefulSetTester) WaitForPartitionedRollingUpdate(set *appsv1alpha1.StatefulSet) (*appsv1alpha1.StatefulSet, *v1.PodList)
WaitForPartitionedRollingUpdate waits for all Pods in set to exist and have the correct revision. set must have a RollingUpdateStatefulSetStrategyType with a non-nil RollingUpdate and Partition. All Pods with ordinals less than or equal to the Partition are expected to be at set's current revision. All other Pods are expected to be at its update revision.
func (*StatefulSetTester) WaitForPodNotReady ¶
func (s *StatefulSetTester) WaitForPodNotReady(set *appsv1alpha1.StatefulSet, podName string) (*appsv1alpha1.StatefulSet, *v1.PodList)
WaitForPodNotReady waist for the Pod named podName in set to exist and to not have a Ready condition.
func (*StatefulSetTester) WaitForPodReady ¶
func (s *StatefulSetTester) WaitForPodReady(set *appsv1alpha1.StatefulSet, podName string) (*appsv1alpha1.StatefulSet, *v1.PodList)
WaitForPodReady waits for the Pod named podName in set to exist and have a Ready condition.
func (*StatefulSetTester) WaitForRollingUpdate ¶
func (s *StatefulSetTester) WaitForRollingUpdate(set *appsv1alpha1.StatefulSet) (*appsv1alpha1.StatefulSet, *v1.PodList)
WaitForRollingUpdate waits for all Pods in set to exist and have the correct revision and for the RollingUpdate to complete. set must have a RollingUpdateStatefulSetStrategyType.
func (*StatefulSetTester) WaitForRunning ¶
func (s *StatefulSetTester) WaitForRunning(numPodsRunning, numPodsReady int32, ss *appsv1alpha1.StatefulSet)
WaitForRunning waits for numPodsRunning in ss to be Running and for the first numPodsReady ordinals to be Ready.
func (*StatefulSetTester) WaitForRunningAndNotReady ¶
func (s *StatefulSetTester) WaitForRunningAndNotReady(numStatefulPods int32, ss *appsv1alpha1.StatefulSet)
WaitForRunningAndReady waits for numStatefulPods in ss to be Running and not Ready.
func (*StatefulSetTester) WaitForRunningAndReady ¶
func (s *StatefulSetTester) WaitForRunningAndReady(numStatefulPods int32, ss *appsv1alpha1.StatefulSet)
WaitForRunningAndReady waits for numStatefulPods in ss to be Running and Ready.
func (*StatefulSetTester) WaitForState ¶
func (s *StatefulSetTester) WaitForState(ss *appsv1alpha1.StatefulSet, until func(*appsv1alpha1.StatefulSet, *v1.PodList) (bool, error))
WaitForState periodically polls for the ss and its pods until the until function returns either true or an error
func (*StatefulSetTester) WaitForStatus ¶
func (s *StatefulSetTester) WaitForStatus(set *appsv1alpha1.StatefulSet) *appsv1alpha1.StatefulSet
WaitForStatus waits for the StatefulSetStatus's ObservedGeneration to be greater than or equal to set's Generation. The returned StatefulSet contains such a StatefulSetStatus
func (*StatefulSetTester) WaitForStatusReadyReplicas ¶
func (s *StatefulSetTester) WaitForStatusReadyReplicas(ss *appsv1alpha1.StatefulSet, expectedReplicas int32)
WaitForStatusReadyReplicas waits for the ss.Status.ReadyReplicas to be equal to expectedReplicas
func (*StatefulSetTester) WaitForStatusReplicas ¶
func (s *StatefulSetTester) WaitForStatusReplicas(ss *appsv1alpha1.StatefulSet, expectedReplicas int32)
WaitForStatusReplicas waits for the ss.Status.Replicas to be equal to expectedReplicas
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
type TestDataSummary ¶
type VerifyStatefulPodFunc ¶
VerifyStatefulPodFunc is a func that examines a StatefulSetPod.