framework

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2017 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 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

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

	// How long claims have to become dynamically provisioned
	ClaimProvisionTimeout = 5 * time.Minute
)

Variables

View Source
var ErrPodCompleted = fmt.Errorf("pod ran to completion")

ErrPodCompleted is returned by PodRunning or PodContainerRunning to indicate that the pod has already reached completed state.

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

unique identifier of the e2e run

Functions

func AllNodesReady

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

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

func DumpAllNamespaceInfo(c clientset.Interface, namespace string)

func DumpEventsInNamespace

func DumpEventsInNamespace(eventsLister EventsLister, namespace string)

func DumpNodeDebugInfo

func DumpNodeDebugInfo(c clientset.Interface, nodeNames []string, logFunc func(fmt string, args ...interface{}))

func ExpectNoError

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

func Failf

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

func GetKubeletPods

func GetKubeletPods(c clientset.Interface, node string) (*v1.PodList, error)

GetKubeletPods retrieves the list of pods on the kubelet

func GetNodeCondition

func GetNodeCondition(status *v1.NodeStatus, conditionType v1.NodeConditionType) (int, *v1.NodeCondition)

GetNodeCondition 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 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 GetPodReadyCondition

func GetPodReadyCondition(status v1.PodStatus) *v1.PodCondition

Extracts the pod ready condition from the given status and returns that. Returns nil if the condition is not present.

func IsNodeConditionSetAsExpected

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

func IsNodeConditionSetAsExpectedSilent

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

func IsPodReady

func IsPodReady(pod *v1.Pod) bool

IsPodReady returns true if a pod is ready; false otherwise.

func IsPodReadyConditionTrue

func IsPodReadyConditionTrue(status v1.PodStatus) bool

IsPodReady retruns true if a pod is ready; false otherwise.

func KubeDescribe

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

Wrapper function for ginkgo describe. Adds namespacing. TODO: Support type safe tagging as well https://github.com/kubernetes/kubernetes/pull/22401.

func LoadConfig

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

func Logf

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

func NodeProxyRequest

func NodeProxyRequest(c clientset.Interface, node, endpoint string) (restclient.Result, error)

NodeProxyRequest performs a get on a node proxy endpoint given the nodename and rest client.

func PodRunning

func PodRunning(event watch.Event) (bool, error)

PodRunning returns true if the pod is running, false if the pod has not yet reached running state, returns ErrPodCompleted if the pod has run to completion, or an error in any other case.

func RegisterClusterFlags

func RegisterClusterFlags()

Register flags specific to the cluster e2e test suite.

func RegisterCommonFlags

func RegisterCommonFlags()

Register flags common to all e2e test suites.

func RegisterNodeFlags

func RegisterNodeFlags()

Register flags specific to the node e2e test suite.

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 ServerVersionGTE

func ServerVersionGTE(v semver.Version, c discovery.ServerVersionInterface) (bool, error)

ServerVersionGTE returns true if v is greater than or equal to the server version.

TODO(18726): This should be incorporated into client.VersionInterface.

func SingleObject

func SingleObject(meta v1.ObjectMeta) v1.ListOptions

SingleObject returns a ListOptions for watching a single object.

func ViperizeFlags

func ViperizeFlags()

ViperizeFlags sets up all flag and config processing. Future configuration info should be added to viper, not to flags.

func WaitForDeploymentPodsRunning

func WaitForDeploymentPodsRunning(c clientset.Interface, ns, name string) error

func WaitForPersistentVolumeClaimPhase

func WaitForPersistentVolumeClaimPhase(phase v1.PersistentVolumeClaimPhase, c clientset.Interface, ns string, pvcName string, Poll, timeout time.Duration) error

WaitForPersistentVolumeClaimPhase waits for a PersistentVolumeClaim to be in a specific phase or until timeout occurs, whichever comes first.

func WaitForPersistentVolumeDeleted

func WaitForPersistentVolumeDeleted(c clientset.Interface, pvName string, Poll, timeout time.Duration) error

WaitForPersistentVolumeDeleted waits for a PersistentVolume to get deleted or until timeout occurs, whichever comes first.

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 WaitForPodSuccessInNamespace

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

WaitForPodSuccessInNamespace returns nil if the pod reached state success, or an error if it reached failure or until podStartupTimeout.

func WaitForPodSuccessInNamespaceSlow

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

WaitForPodSuccessInNamespaceSlow returns nil if the pod reached state success, or an error if it reached failure or until slowPodStartupTimeout.

func WaitForPodToDisappear

func WaitForPodToDisappear(c clientset.Interface, ns, podName string, label labels.Selector, interval, timeout time.Duration) error

func WaitForPodsWithLabelRunning

func WaitForPodsWithLabelRunning(c clientset.Interface, ns string, label labels.Selector) error

Wait up to 1 minute for all matching pods to become Running and at least one matching pod exists.

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 CloudConfig

type CloudConfig struct {
	ProjectID         string
	Zone              string
	Cluster           string
	MasterName        string
	NodeInstanceGroup string
	NumNodes          int
	ClusterTag        string
	Network           string

	Provider cloudprovider.Interface
}

type CreateTestingNSFn

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

type EventsLister

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

type Framework

type Framework struct {
	BaseName string

	ClientSet clientset.Interface

	ClientPool dynamic.ClientPool

	Namespace *v1.Namespace // Every test has at least one namespace

	NamespaceDeletionTimeout time.Duration
	// contains filtered or unexported fields
}

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

func NewDefaultFramework

func NewDefaultFramework(baseName string) *Framework

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

func (f *Framework) AfterEach()

AfterEach deletes the namespace, after reading its events.

func (*Framework) BeforeEach

func (f *Framework) BeforeEach()

BeforeEach gets a client and makes a namespace.

func (*Framework) CreateNamespace

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

type FrameworkOptions

type FrameworkOptions struct {
	ClientQPS    float32
	ClientBurst  int
	GroupVersion *unversioned.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
	// KubeletConfig is the kubelet configuration the test is running against.
	KubeletConfig componentconfig.KubeletConfiguration
}

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

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

	Provider       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
	UpgradeTarget            string
	UpgradeImage             string
	PrometheusPushGateway    string
	ContainerRuntime         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            bool
	// Currently supported values are 'hr' for human-readable and 'json'. It's a comma separated list.
	OutputPrintType string
	// CreateTestingNS is responsible for creating namespace used for executing e2e tests.
	// It accepts namespace base name, which will be prepended with e2e prefix, kube client
	// and labels to be applied to a namespace.
	CreateTestingNS CreateTestingNSFn
	// If set to true test will dump data about the namespace in which test was running.
	DumpLogsOnFailure bool
	// If the garbage collector is enabled in the kube-apiserver and kube-controller-manager.
	GarbageCollectorEnabled bool
	// FeatureGates is a set of key=value pairs that describe feature gates for alpha/experimental features.
	FeatureGates string
	// Node e2e specific test context
	NodeTestContextType

	Viper    string
	Cadvisor struct {
		MaxRetries      int
		SleepDurationMS int
	}

	LoggingSoak struct {
		Scale                    int
		MilliSecondsBetweenWaves int
	}
}
var TestContext TestContextType

type TestDataSummary

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

Jump to

Keyboard shortcuts

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