framework

package
v0.0.0-...-2c9fce1 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2021 License: Apache-2.0 Imports: 35 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// How long to wait for a job to finish.
	JobTimeout = 15 * time.Minute

	// Job selector name
	JobSelectorKey = "name"
)
View Source
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

	// 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 = 1 * 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

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

	DefaultPodDeletionTimeout = 3 * time.Minute
)

Variables

View Source
var (
	BusyBoxImage = "busybox"
	// Label allocated to the image puller static pod that runs on each node
	// before e2es.
	ImagePullerLabels = map[string]string{"name": "e2e-image-puller"}
)

Functions

func AddLabelsToNode

func AddLabelsToNode(c clientset.Interface, nodeName string, labels map[string]string) error

func AddOrUpdateLabelOnNode

func AddOrUpdateLabelOnNode(c clientset.Interface, nodeName string, labelKey, labelValue string)

func AddOrUpdateTaintOnNode

func AddOrUpdateTaintOnNode(c clientset.Interface, nodeName string, taint v1.Taint)

func ExpectNoError

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

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 ExpectNodeHasLabel

func ExpectNodeHasLabel(c clientset.Interface, nodeName string, labelKey string, labelValue string)

func ExpectNodeHasTaint

func ExpectNodeHasTaint(c clientset.Interface, nodeName string, taint *v1.Taint)

func Failf

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

func FailfWithOffset

func FailfWithOffset(offset int, format string, args ...interface{})

FailfWithOffset calls "Fail" and logs the error at "offset" levels above its caller (for example, for call chain f -> g -> FailfWithOffset(1, ...) error would be logged for "f").

func GetJob

func GetJob(c clientset.Interface, ns, name string) (*batch.Job, error)

GetJob uses c to get the Job in namespace ns named name. If the returned error is nil, the returned Job is valid.

func GetJobPods

func GetJobPods(c clientset.Interface, ns, jobName string) (*v1.PodList, error)

GetJobPods returns a list of Pods belonging to a Job.

func GetNodesOrDie

func GetNodesOrDie(c clientset.Interface) *v1.NodeList

GetMasterAndWorkerNodesOrDie will return a list masters and schedulable worker nodes

func GetPodCondition

func GetPodCondition(status *v1.PodStatus, conditionType v1.PodConditionType) (int, *v1.PodCondition)

GetPodCondition extracts the provided condition from the given status and returns that. Returns nil and -1 if the condition is not present, and the index of the located condition.

func GetPodConditionFromList

func GetPodConditionFromList(conditions []v1.PodCondition, conditionType v1.PodConditionType) (int, *v1.PodCondition)

GetPodConditionFromList extracts the provided condition from the given list of condition and returns the index of the condition and the condition. Returns -1 and nil if the condition is not present.

func GetPodLogs

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

func GetPodsScheduled

func GetPodsScheduled(pods *v1.PodList) (scheduledPods, notScheduledPods []v1.Pod)

GetPodsScheduled returns a number of currently scheduled and not scheduled Pods.

func IsMasterNode

func IsMasterNode(nodeName string) bool

IsMasterNode returns true if its a master node or false otherwise.

func KubectlCmd

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

KubectlCmd runs the kubectl executable through the wrapper script.

func ListSchedulableNodes

func ListSchedulableNodes(c clientset.Interface) []v1.Node

ListSchedulabelNodes get an slice of nodes that are schedulable

func Logf

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

func NodeHasTaint

func NodeHasTaint(c clientset.Interface, nodeName string, taint *v1.Taint) (bool, error)

func RemoveLabelOffNode

func RemoveLabelOffNode(c clientset.Interface, nodeName string, labelKey string)

RemoveLabelOffNode is for cleaning up labels temporarily added to node, won't fail if target label doesn't exist or has been removed.

func RemoveTaintOffNode

func RemoveTaintOffNode(c clientset.Interface, nodeName string, taint v1.Taint)

func TaintExists

func TaintExists(taints []v1.Taint, taintToFind *v1.Taint) bool

TaintExists checks if the given taint exists in list of taints. Returns true if exists false otherwise.

func VerifyLabelsRemoved

func VerifyLabelsRemoved(c clientset.Interface, nodeName string, labelKeys []string) error

VerifyLabelsRemoved checks if Node for given nodeName does not have any of labels from labelKeys. Return non-nil error if it does.

func VerifyThatTaintIsGone

func VerifyThatTaintIsGone(c clientset.Interface, nodeName string, taint *v1.Taint)

func WaitForPodNameRunningInNamespace

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

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 WaitForPodNoLongerRunningInNamespace

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

Waits default amount of time (DefaultPodDeletionTimeout) for the specified pod to stop running. Returns an error if timeout occurs first.

func WaitForPodNotPending

func WaitForPodNotPending(c clientset.Interface, ns, podName string) error

WaitForPodNotPending returns an error if it took too long for the pod to go out of pending state. The resourceVersion is used when Watching object changes, it tells since when we care about changes to the pod.

func WaitForPodRunningInNamespace

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

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 WaitForStableCluster

func WaitForStableCluster(c clientset.Interface) int

WaitForStableCluster waits until all existing pods are scheduled and returns their amount.

func WaitTimeoutForPodNoLongerRunningInNamespace

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

func WaitTimeoutForPodNotPending

func WaitTimeoutForPodNotPending(c clientset.Interface, ns, podName string, timeout time.Duration) error

WaitTimeoutForPodNotPending returns an error if it took too long for the pod to go out of pending state. The resourceVersion is used when Watching object changes, it tells since when we care about changes to the pod.

func WaitTimeoutForPodRunningInNamespace

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

Types

type Action

type Action func() error

type Framework

type Framework struct {
	BaseName  string
	ClientSet clientset.Interface
	Namespace *v1.Namespace
	TestingNS string
	Options   FrameworkOptions
}

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

func NewDefaultFramework

func NewDefaultFramework(baseName string) *Framework

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

func NewFramework

func NewFramework(baseName string, options FrameworkOptions) *Framework

NewFramework makes a new framework and sets up a BeforeEach/AfterEach

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) CreateFirmament

func (f *Framework) CreateFirmament() error

CreateFirmament create firmament deployment

func (*Framework) CreatePoseidon

func (f *Framework) CreatePoseidon() error

CreatePoseidon create firmament deployment

func (*Framework) DeleteDeploymentIfExist

func (f *Framework) DeleteDeploymentIfExist(nsName string, deploymentName string) error

DeleteDeploymentIfExist deletes a deployment if it exists

func (*Framework) DeletePoseidonClusterRole

func (f *Framework) DeletePoseidonClusterRole(clusterRole string, nsName string) error

DeletePoseidonClusterRole deletes a cluster role and role binding

func (*Framework) DeleteService

func (f *Framework) DeleteService(nsName string, serviceName string) error

DeleteService deletes a service

func (*Framework) FetchLogsForAllPodsInNamespace

func (f *Framework) FetchLogsForAllPodsInNamespace(nsName string)

FetchLogsForAllPodsInNamespace will fetch logs from all the pods in the namespace This can be called after each test is run

func (*Framework) FetchLogsFromFirmament

func (f *Framework) FetchLogsFromFirmament(nsName string)

FetchLogsFromPoseidon will get the Poseidon and firmament deplyment logs

func (*Framework) FetchLogsFromPoseidon

func (f *Framework) FetchLogsFromPoseidon(nsName string)

FetchLogsFromPoseidon will get the Poseidon and firmament deplyment logs

func (*Framework) KubectlExecCreate

func (f *Framework) KubectlExecCreate(manifestPath string) (string, string, error)

func (*Framework) ListPodsInNamespace

func (f *Framework) ListPodsInNamespace(ns string)

ListPodsInNamespace will list all the pods in a given namespaces

func (*Framework) LogPodsWithOptionalLabels

func (f *Framework) LogPodsWithOptionalLabels(ns string, match map[string]string, logFunc func(ftm string, args ...interface{}))

func (*Framework) ObserveEventAfterAction

func (f *Framework) ObserveEventAfterAction(eventPredicate func(*v1.Event) bool, action Action) (bool, error)

Returns true if an event matching the predicate was emitted from the system after performing the supplied action.

func (*Framework) WaitForAllJobPodsRunning

func (f *Framework) WaitForAllJobPodsRunning(jobName string, parallelism int32) error

WaitForAllJobPodsRunning wait for all pods for the Job named JobName in namespace ns to become Running. Only use when pods will run for a long time, or it will be racy.

func (*Framework) WaitForDeploymentComplete

func (f *Framework) WaitForDeploymentComplete(d *extensions.Deployment) error

WaitForDeploymentComplete waits for the deployment to complete, and don't check if rolling update strategy is broken.

func (*Framework) WaitForDeploymentDelete

func (f *Framework) WaitForDeploymentDelete(d *extensions.Deployment) error

WaitForDeploymentDelete waits for the Deployment to be removed

func (*Framework) WaitForJobDelete

func (f *Framework) WaitForJobDelete(job *batchv1.Job) error

WaitForJobDelete waits for job to be removed

func (*Framework) WaitForPodNoLongerRunning

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

WaitForPodNoLongerRunning waits for the pod to no longer be running in the namespace, for either success or failure.

func (*Framework) WaitForPodNotFound

func (f *Framework) WaitForPodNotFound(podName string, timeout time.Duration) error

WaitForPodNotFound waits for the pod to be completely terminated (not "Get-able").

func (*Framework) WaitForPodRunning

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

WaitForPodRunning waits for the pod to run in the namespace.

func (*Framework) WaitForPodRunningSlow

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

WaitForPodRunningSlow waits for the pod to run in the namespace. It has a longer timeout then WaitForPodRunning (util.slowPodStartTimeout).

func (*Framework) WaitForReadyReplicaSet

func (f *Framework) WaitForReadyReplicaSet(name string) error

WaitForReadyReplicaSet waits until the replicaset has all of its replicas ready.

func (*Framework) WaitForReplicaSetDelete

func (f *Framework) WaitForReplicaSetDelete(replicaSet *extensions.ReplicaSet) error

WaitForReplicaSetDelete waits for the ReplicateSet to be removed

func (*Framework) WaitForReplicaSetTargetSpecReplicas

func (f *Framework) WaitForReplicaSetTargetSpecReplicas(replicaSet *extensions.ReplicaSet, targetReplicaNum int32) error

WaitForReplicaSetTargetSpecReplicas waits for .spec.replicas of a RS to equal targetReplicaNum

func (*Framework) WaitForSchedulerAfterAction

func (f *Framework) WaitForSchedulerAfterAction(action Action, ns, podName string, expectSuccess bool)

WaitForSchedulerAfterAction performs the provided action and then waits for scheduler to act on the given pod.

type FrameworkOptions

type FrameworkOptions struct {
	ClientQPS   float32
	ClientBurst int
}

Directories

Path Synopsis
Package ginkgowrapper wraps Ginkgo Fail and Skip functions to panic with structured data instead of a constant string.
Package ginkgowrapper wraps Ginkgo Fail and Skip functions to panic with structured data instead of a constant string.

Jump to

Keyboard shortcuts

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