Documentation ¶
Index ¶
- Constants
- Variables
- func APIAddress() string
- func AfterReadingAllFlags(t *TestContextType)
- func AllNodesReady(c clientset.Interface, timeout time.Duration) error
- func CheckTestingNSDeletedExcept(c clientset.Interface, skip string) error
- func ConformanceIt(text string, body interface{}, timeout ...float64) bool
- func CoreDump(dir string)
- func CreateTestingNS(baseName string, c clientset.Interface, labels map[string]string) (*v1.Namespace, error)
- func DeleteNamespaces(c clientset.Interface, deleteFilter, skipFilter []string) ([]string, error)
- func DumpAllNamespaceInfo(c clientset.Interface, namespace string)
- func DumpNodeDebugInfo(c clientset.Interface, nodeNames []string, ...)
- func ExpectConsistOf(actual interface{}, extra interface{}, explain ...interface{})
- func ExpectEmpty(actual interface{}, explain ...interface{})
- func ExpectEqual(actual interface{}, extra interface{}, explain ...interface{})
- func ExpectError(err error, explain ...interface{})
- func ExpectHaveKey(actual interface{}, key interface{}, explain ...interface{})
- func ExpectNoError(err error, explain ...interface{})
- func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{})
- func ExpectNotEqual(actual interface{}, extra interface{}, explain ...interface{})
- func GenerateSecureToken(tokenLen int) (string, error)
- func GetProviders() []string
- func LoadClientset() (*clientset.Clientset, error)
- func LoadConfig() (config *restclient.Config, err error)
- func MasterOSDistroIs(supportedMasterOsDistros ...string) bool
- func NodeOSArchIs(supportedNodeOsArchs ...string) bool
- func NodeOSDistroIs(supportedNodeOsDistros ...string) bool
- func PrettyPrintJSON(metrics interface{}) string
- func ProviderIs(providers ...string) bool
- func RandomSuffix() string
- func RegisterClusterFlags(flags *flag.FlagSet)
- func RegisterCommonFlags(flags *flag.FlagSet)
- func RegisterProvider(name string, factory Factory)
- func RemoveCleanupAction(p CleanupActionHandle)
- func RunCleanupActions()
- func RunHostCmd(ns, name, cmd string) (string, error)
- func RunKubectl(namespace string, args ...string) (string, error)
- func WaitForAllNodesSchedulable(c clientset.Interface, timeout time.Duration) error
- func WaitForDefaultServiceAccountInNamespace(c clientset.Interface, namespace string) error
- func WaitForKubeRootCAInNamespace(c clientset.Interface, namespace string) error
- func WaitForNamespacesDeleted(c clientset.Interface, namespaces []string, timeout time.Duration) error
- func WaitForServiceEndpointsNum(c clientset.Interface, namespace, serviceName string, expectNum int, ...) error
- type AfterEachActionFunc
- type CleanupActionHandle
- type ClientConfigGetter
- type CloudConfig
- type ClusterVerification
- type ContainerResourceGatherer
- type ContainerResourceUsage
- type ContainerType
- type ContainerVisitor
- type CreateTestingNSFn
- type EventsLister
- type ExecOptions
- type Factory
- type FlakeReport
- type Framework
- func (f *Framework) AddAfterEach(name string, fn AfterEachActionFunc)
- func (f *Framework) AddNamespacesToDelete(namespaces ...*v1.Namespace)
- func (f *Framework) AfterEach()
- func (f *Framework) BeforeEach()
- func (f *Framework) ClientConfig() *rest.Config
- func (f *Framework) CreateNamespace(baseName string, labels map[string]string) (*v1.Namespace, error)
- func (f *Framework) DeleteNamespace(name string)
- func (f *Framework) ExecCommandInContainer(podName, containerName string, cmd ...string) string
- func (f *Framework) ExecCommandInContainerWithFullOutput(podName, containerName string, cmd ...string) (string, string, error)
- func (f *Framework) ExecWithOptions(options ExecOptions) (string, string, error)
- func (f *Framework) MatchContainerOutput(pod *v1.Pod, containerName string, expectedOutput []string, ...) error
- func (f *Framework) NewClusterVerification(namespace *v1.Namespace, filter PodStateVerification) *ClusterVerification
- func (f *Framework) PodClient() *PodClient
- func (f *Framework) PodClientNS(namespace string) *PodClient
- func (f *Framework) RecordFlakeIfError(err error, optionalDescription ...interface{})
- type KubeCluster
- type KubeConfig
- type KubeUser
- type KubectlBuilder
- type NodeKillerConfig
- type NodeTestContextType
- type NodesSet
- 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) DeleteNode(node *v1.Node) 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 Options
- type PodClient
- type PodStateVerification
- type ProviderInterface
- type ResourceConstraint
- type ResourceGathererOptions
- type ResourceUsagePerContainer
- type ResourceUsageSummary
- type SingleContainerSummary
- type TestContextType
- type TestDataSummary
- type TimeoutContext
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 )
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 )
DEPRECATED constants. Use the timeouts in framework.Framework instead.
const ( // AllContainers specifies that all containers be visited // Copied from pkg/api/v1/pod to avoid pulling extra dependencies AllContainers = InitContainers | Containers | EphemeralContainers )
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
)
const ( // DefaultPodDeletionTimeout is the default timeout for deleting pod DefaultPodDeletionTimeout = 3 * time.Minute )
Variables ¶
var ImagePrePullList sets.String
ImagePrePullList is the images used in the current test suite. It should be initialized in test suite and the images in the list should be pre-pulled in the test suite. Currently, this is only used by node e2e test.
var ( // ProvidersWithSSH are those providers where each node is accessible with SSH ProvidersWithSSH = []string{"gce", "gke", "aws", "local"} )
var RunID = uuid.NewUUID()
RunID is a unique identifier of the e2e run. Beware that this ID is not the same for all tests in the e2e run, because each Ginkgo node creates it separately.
Functions ¶
func AfterReadingAllFlags ¶
func AfterReadingAllFlags(t *TestContextType)
AfterReadingAllFlags makes changes to the context after all flags have been read.
func AllNodesReady ¶
AllNodesReady checks whether all registered nodes are ready. Setting -1 on TestContext.AllowedNotReadyNodes will bypass the post test node readiness check. 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 CheckTestingNSDeletedExcept ¶
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 ¶
ConformanceIt is wrapper function for ginkgo It. Adds "[Conformance]" tag and makes static analysis easier.
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 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 DeleteNamespaces ¶
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 DumpAllNamespaceInfo ¶
DumpAllNamespaceInfo dumps events, pods and nodes information in the given namespace.
func DumpNodeDebugInfo ¶
func DumpNodeDebugInfo(c clientset.Interface, nodeNames []string, logFunc func(fmt string, args ...interface{}))
DumpNodeDebugInfo dumps debug information of the given nodes.
func ExpectConsistOf ¶
func ExpectConsistOf(actual interface{}, extra interface{}, explain ...interface{})
ExpectConsistOf expects actual contains precisely the extra elements. The ordering of the elements does not matter.
func ExpectEmpty ¶
func ExpectEmpty(actual interface{}, explain ...interface{})
ExpectEmpty expects actual is empty
func ExpectEqual ¶
func ExpectEqual(actual interface{}, extra interface{}, explain ...interface{})
ExpectEqual expects the specified two are the same, otherwise an exception raises
func ExpectError ¶
func ExpectError(err error, explain ...interface{})
ExpectError expects an error happens, otherwise an exception raises
func ExpectHaveKey ¶
func ExpectHaveKey(actual interface{}, key interface{}, explain ...interface{})
ExpectHaveKey expects the actual map has the key in the keyset
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 ¶
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 ExpectNotEqual ¶
func ExpectNotEqual(actual interface{}, extra interface{}, explain ...interface{})
ExpectNotEqual expects the specified two are not the same, otherwise an exception raises
func GenerateSecureToken ¶
GenerateSecureToken returns a string of length tokenLen, consisting of random bytes encoded as base64 for use as a Bearer Token during communication with an APIServer
func GetProviders ¶
func GetProviders() []string
GetProviders returns the names of all currently registered providers.
func LoadClientset ¶
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 MasterOSDistroIs ¶
MasterOSDistroIs returns true if the master OS distro is included in the supportedMasterOsDistros. Otherwise false.
func NodeOSArchIs ¶
NodeOSArchIs returns true if the node OS arch is included in the supportedNodeOsArchs. Otherwise false.
func NodeOSDistroIs ¶
NodeOSDistroIs returns true if the node OS distro is included in the supportedNodeOsDistros. Otherwise false.
func PrettyPrintJSON ¶
func PrettyPrintJSON(metrics interface{}) string
PrettyPrintJSON converts metrics to JSON format.
func ProviderIs ¶
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 RegisterClusterFlags ¶
RegisterClusterFlags registers flags specific to the cluster e2e test suite.
func RegisterCommonFlags ¶
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 ¶
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 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 RunKubectl ¶
RunKubectl is a convenience wrapper over kubectlBuilder
func WaitForAllNodesSchedulable ¶
WaitForAllNodesSchedulable waits up to timeout for all (but TestContext.AllowedNotReadyNodes) to become schedulable.
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 WaitForKubeRootCAInNamespace ¶
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).
Types ¶
type AfterEachActionFunc ¶
AfterEachActionFunc is a function that can be called after each test
type CleanupActionHandle ¶
type CleanupActionHandle *int
CleanupActionHandle is an integer pointer type for handling cleanup action
func AddCleanupAction ¶
func AddCleanupAction(fn func()) CleanupActionHandle
AddCleanupAction installs a function that will be called in the event of the whole test being terminated. This allows arbitrary pieces of the overall test to hook into SynchronizedAfterSuite(). The hooks are called in last-in-first-out order.
type ClientConfigGetter ¶
type ClientConfigGetter func() (*restclient.Config, error)
ClientConfigGetter is a func that returns getter to return a config.
type CloudConfig ¶
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 and openstack NodeTag string MasterTag string Provider ProviderInterface }
CloudConfig holds the cloud configuration for e2e test suites.
type ClusterVerification ¶
type ClusterVerification struct {
// contains filtered or unexported fields
}
ClusterVerification is a struct for a verification of cluster state.
func (*ClusterVerification) ForEach ¶
func (cl *ClusterVerification) ForEach(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 ¶
WaitFor waits for some minimum number of pods to be verified, according to the PodStateVerification definition.
func (*ClusterVerification) WaitForOrFail ¶
func (cl *ClusterVerification) WaitForOrFail(atLeast int, timeout time.Duration)
WaitForOrFail provides a shorthand WaitFor with failure as an option if anything goes wrong.
type ContainerResourceGatherer ¶
type ContainerResourceGatherer struct {
// contains filtered or unexported fields
}
ContainerResourceGatherer is a struct for gathering container resource.
func NewResourceUsageGatherer ¶
func NewResourceUsageGatherer(c clientset.Interface, options ResourceGathererOptions, pods *v1.PodList) (*ContainerResourceGatherer, error)
NewResourceUsageGatherer returns a new ContainerResourceGatherer.
func (*ContainerResourceGatherer) StartGatheringData ¶
func (g *ContainerResourceGatherer) StartGatheringData()
StartGatheringData starts a stat gathering worker blocks for each node to track, and blocks until StopAndSummarize is called.
func (*ContainerResourceGatherer) StopAndSummarize ¶
func (g *ContainerResourceGatherer) StopAndSummarize(percentiles []int, constraints map[string]ResourceConstraint) (*ResourceUsageSummary, error)
StopAndSummarize stops stat gathering workers, processes the collected stats, generates resource summary for the passed-in percentiles, and returns the summary. It returns an error if the resource usage at any percentile is beyond the specified resource constraints.
type ContainerResourceUsage ¶
type ContainerResourceUsage struct { Name string Timestamp time.Time CPUUsageInCores float64 MemoryUsageInBytes uint64 MemoryWorkingSetInBytes uint64 MemoryRSSInBytes uint64 // The interval used to calculate CPUUsageInCores. CPUInterval time.Duration }
ContainerResourceUsage is a structure for gathering container resource usage.
type ContainerType ¶
type ContainerType int
ContainerType signifies container type
const ( // FeatureEphemeralContainers allows running an ephemeral container in pod namespaces to troubleshoot a running pod FeatureEphemeralContainers featuregate.Feature = "EphemeralContainers" // Containers is for normal containers Containers ContainerType = 1 << iota // InitContainers is for init containers InitContainers // EphemeralContainers is for ephemeral containers EphemeralContainers )
type ContainerVisitor ¶
type ContainerVisitor func(container *v1.Container, containerType ContainerType) (shouldContinue bool)
ContainerVisitor is called with each container spec, and returns true if visiting should continue. Copied from pkg/api/v1/pod to avoid pulling extra dependencies
type CreateTestingNSFn ¶
type CreateTestingNSFn func(baseName string, c clientset.Interface, labels map[string]string) (*v1.Namespace, error)
CreateTestingNSFn is a func that is responsible for creating namespace used for executing e2e tests.
type EventsLister ¶
EventsLister is a func that lists events.
type ExecOptions ¶
type ExecOptions struct { Command []string Namespace string PodName string ContainerName string Stdin io.Reader CaptureStdout bool CaptureStderr bool // If false, whitespace in std{err,out} will be removed. PreserveWhitespace bool Quiet bool }
ExecOptions passed to ExecWithOptions
type Factory ¶
type Factory func() (ProviderInterface, error)
Factory is a func which operates provider specific behavior.
type FlakeReport ¶
type FlakeReport struct { Flakes []string `json:"flakes"` FlakeCount int `json:"flakeCount"` // contains filtered or unexported fields }
FlakeReport is a struct for managing the 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 ¶
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 Namespace *v1.Namespace // Every test has at least one namespace unless creation is skipped NamespaceDeletionTimeout time.Duration // Constraints that passed to a check which is executed after data is gathered to // see if 99% of results are within acceptable bounds. It has to be injected in the test, // as expectations vary greatly. Constraints are grouped by the container names. AddonResourceConstraints map[string]ResourceConstraint // 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 // 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 ¶
NewDefaultFramework makes a new framework and sets up a BeforeEach/AfterEach for you (you can write additional before/after each functions).
func NewFramework ¶
NewFramework creates a test framework.
func NewFrameworkWithCustomTimeouts ¶
func NewFrameworkWithCustomTimeouts(baseName string, timeouts *TimeoutContext) *Framework
NewFrameworkWithCustomTimeouts makes a framework with with custom timeouts.
func (*Framework) AddAfterEach ¶
func (f *Framework) AddAfterEach(name string, fn AfterEachActionFunc)
AddAfterEach is a way to add a function to be called after every test. The execution order is intentionally random to avoid growing dependencies. If you register the same name twice, it is a coding error and will panic.
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) ClientConfig ¶
ClientConfig an externally accessible method for reading the kube client config.
func (*Framework) CreateNamespace ¶
func (f *Framework) CreateNamespace(baseName string, labels map[string]string) (*v1.Namespace, error)
CreateNamespace creates a namespace for e2e testing.
func (*Framework) DeleteNamespace ¶
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) ExecCommandInContainer ¶
ExecCommandInContainer executes a command in the specified container.
func (*Framework) ExecCommandInContainerWithFullOutput ¶
func (f *Framework) ExecCommandInContainerWithFullOutput(podName, containerName string, cmd ...string) (string, string, error)
ExecCommandInContainerWithFullOutput executes a command in the specified container and return stdout, stderr and error
func (*Framework) ExecWithOptions ¶
func (f *Framework) ExecWithOptions(options ExecOptions) (string, string, error)
ExecWithOptions executes a command in the specified container, returning stdout, stderr and error. `options` allowed for additional parameters to be passed.
func (*Framework) MatchContainerOutput ¶
func (f *Framework) MatchContainerOutput( pod *v1.Pod, containerName string, expectedOutput []string, matcher func(string, ...interface{}) gomegatypes.GomegaMatcher) error
MatchContainerOutput creates a pod and waits for all it's containers to exit with success. It then tests that the matcher with each expectedOutput matches the output of the specified container.
func (*Framework) NewClusterVerification ¶
func (f *Framework) NewClusterVerification(namespace *v1.Namespace, filter PodStateVerification) *ClusterVerification
NewClusterVerification creates a new cluster verification.
func (*Framework) PodClient ¶
PodClient is a 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) PodClientNS ¶
PodClientNS is a convenience method for getting a pod client interface in an alternative namespace, possibly applying test-suite specific transformations to the pod spec, e.g. for node e2e pod scheduling.
func (*Framework) RecordFlakeIfError ¶
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.
type KubeCluster ¶
type KubeCluster struct { Name string `yaml:"name"` Cluster struct { CertificateAuthorityData string `yaml:"certificate-authority-data"` Server string `yaml:"server"` } `yaml:"cluster"` }
KubeCluster is a struct for managing kubernetes cluster info.
type KubeConfig ¶
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"` }
KubeConfig is a struct for managing kubernetes config.
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 ¶
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"` }
KubeUser is a struct for managing kubernetes user info.
type KubectlBuilder ¶
type KubectlBuilder struct {
// contains filtered or unexported fields
}
KubectlBuilder is used to build, customize and execute a kubectl Command. Add more functions to customize the builder as needed.
func NewKubectlCommand ¶
func NewKubectlCommand(namespace string, args ...string) *KubectlBuilder
NewKubectlCommand returns a KubectlBuilder for running kubectl.
func (KubectlBuilder) Exec ¶
func (b KubectlBuilder) Exec() (string, error)
Exec runs the kubectl executable.
func (KubectlBuilder) ExecWithFullOutput ¶
func (b KubectlBuilder) ExecWithFullOutput() (string, string, error)
ExecWithFullOutput runs the kubectl executable, and returns the stdout and stderr.
type NodeKillerConfig ¶
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 // NodeKillerStopCh is a channel that is used to notify NodeKiller to stop killing nodes. NodeKillerStopCh chan struct{} }
NodeKillerConfig describes configuration of NodeKiller -- a utility to simulate node failures.
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 // TODO(pingcap): add this if needed // KubeletConfig is the kubelet configuration the test is running against. // KubeletConfig kubeletconfig.KubeletConfiguration // 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 }
NodeTestContextType is part of TestContextType, it is shared by all node e2e test.
type NullProvider ¶
type NullProvider struct{}
NullProvider is the default implementation of the ProviderInterface which doesn't do anything.
func (NullProvider) CleanupServiceResources ¶
func (n NullProvider) CleanupServiceResources(c clientset.Interface, loadBalancerName, region, zone string)
CleanupServiceResources 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(zone, diskName string) (*v1.PersistentVolumeSource, error)
CreatePVSource is a base implementation which creates PV source.
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(pvSource *v1.PersistentVolumeSource) error
DeletePVSource is a base implementation which deletes PV source.
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(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 ¶
type Options struct { ClientQPS float32 ClientBurst int GroupVersion *schema.GroupVersion }
Options is a struct for managing test framework options.
type PodClient ¶
type PodClient struct { v1core.PodInterface // contains filtered or unexported fields }
PodClient is a struct for pod client.
func (*PodClient) Create ¶
Create creates a new pod according to the framework specifications (don't wait for it to start).
func (*PodClient) DeleteSync ¶
DeleteSync deletes the pod and wait for the pod to disappear for `timeout`. If the pod doesn't disappear before the timeout, it will fail the test.
type PodStateVerification ¶
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 }
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 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) DeleteNode(node *v1.Node) 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 ResourceConstraint ¶
ResourceConstraint is a struct to hold constraints.
type ResourceGathererOptions ¶
type ResourceGathererOptions struct { InKubemark bool Nodes NodesSet ResourceDataGatheringPeriod time.Duration ProbeDuration time.Duration PrintVerboseLogs bool }
ResourceGathererOptions is a struct to hold options for resource.
type ResourceUsagePerContainer ¶
type ResourceUsagePerContainer map[string]*ContainerResourceUsage
ResourceUsagePerContainer is map of ContainerResourceUsage
type ResourceUsageSummary ¶
type ResourceUsageSummary map[string][]SingleContainerSummary
ResourceUsageSummary is a struct to hold resource usage summary. we can't have int here, as JSON does not accept integer keys.
func (*ResourceUsageSummary) PrintHumanReadable ¶
func (s *ResourceUsageSummary) PrintHumanReadable() string
PrintHumanReadable prints resource usage summary in human readable.
func (*ResourceUsageSummary) PrintJSON ¶
func (s *ResourceUsageSummary) PrintJSON() string
PrintJSON prints resource usage summary in JSON.
func (*ResourceUsageSummary) SummaryKind ¶
func (s *ResourceUsageSummary) SummaryKind() string
SummaryKind returns string of ResourceUsageSummary
type SingleContainerSummary ¶
SingleContainerSummary is a struct to hold single container summary.
type TestContextType ¶
type TestContextType struct { KubeConfig string KubeContext string KubeAPIContentType string KubeVolumeDir string CertDir string Host string BearerToken string `datapolicy:"token"` // TODO: Deprecating this over time... instead just use gobindata_util.go , see #23987. RepoRoot string DockershimCheckpointDir 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 Prefix string MinStartupPods int // Timeout for waiting for system pods to be running SystemPodsStartupTimeout time.Duration EtcdUpgradeStorage string EtcdUpgradeVersion 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 // 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 // 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 // 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 // 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 }
TestContextType contains test settings and global state. Due to historic reasons, it is a mixture of items managed by the test framework itself, cloud providers and individual tests. The goal is to move anything not required by the framework into the code which uses the settings.
The recommendation for those settings is:
- They are stored in their own context structure or local variables.
- The standard `flag` package is used to register them. The flag name should follow the pattern <part1>.<part2>....<partn> where the prefix is unlikely to conflict with other tests or standard packages and each part is in lower camel case. For example, test/e2e/storage/csi/context.go could define storage.csi.numIterations.
- framework/config can be used to simplify the registration of multiple options with a single function call: var storageCSI { NumIterations `default:"1" usage:"number of iterations"` } _ config.AddOptions(&storageCSI, "storage.csi")
- The direct use Viper in tests is possible, but discouraged because it only works in test suites which use Viper (which is not required) and the supported options cannot be discovered by a test suite user.
Test suite authors can use framework/viper to make all command line parameters also configurable via a configuration file.
var TestContext TestContextType
TestContext should be used by all tests to access common context data.
func (TestContextType) ClusterIsIPv6 ¶
func (tc TestContextType) ClusterIsIPv6() bool
ClusterIsIPv6 returns true if the cluster is IPv6
type TestDataSummary ¶
type TestDataSummary interface { SummaryKind() string PrintHumanReadable() string PrintJSON() string }
TestDataSummary is an interface for managing test data.
type TimeoutContext ¶
type TimeoutContext struct { // PodStart is how long to wait for the pod to be started. 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. 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 // 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 }
TimeoutContext contains timeout settings for several actions.
func NewTimeoutContextWithDefaults ¶
func NewTimeoutContextWithDefaults() *TimeoutContext
NewTimeoutContextWithDefaults returns a TimeoutContext with default values.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package ginkgowrapper wraps Ginkgo Fail and Skip functions to panic with structured data instead of a constant string.
|
Package ginkgowrapper wraps Ginkgo Fail and Skip functions to panic with structured data instead of a constant string. |