framework

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// E2E represents a test suite for e2e.
	E2E Suite = "e2e"
	// NodeE2E represents a test suite for node e2e.
	NodeE2E Suite = "node e2e"

	// Poll how often to poll for conditions
	Poll = 2 * time.Second

	// DefaultTimeout time to wait for operations to complete
	DefaultTimeout = 90 * time.Second
)

Variables

View Source
var (
	// KubectlPath defines the full path of the kubectl binary
	KubectlPath = "/usr/local/bin/kubectl"
)
View Source
var RunID = uuid.NewUUID()

RunID unique identifier of the e2e run

Functions

func CrainaDescribe

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

Craina wrapper function for ginkgo describe. Adds namespacing.

func CreateKubeNamespace

func CreateKubeNamespace(baseName string, c kubernetes.Interface) (string, error)

CreateKubeNamespace creates a new namespace in the cluster

func DeleteKubeNamespace

func DeleteKubeNamespace(c kubernetes.Interface, namespace string) error

DeleteKubeNamespace deletes a namespace and all the objects inside

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 ExpectNotEqual

func ExpectNotEqual(actual interface{}, extra interface{}, explain ...interface{})

ExpectNotEqual expects the specified two are not the same, otherwise an exception raises

func Failf

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

Failf logs to the INFO logs and fails the test.

func GetConfig

func GetConfig() (*rest.Config, error)

GetConfig creates a *rest.Config for talking to a Kubernetes API server. If --kubeconfig is set, will use the kubeconfig file at that location. Otherwise will assume running in cluster and use the cluster provided kubeconfig.

It also applies saner defaults for QPS and burst based on the Kubernetes controller manager defaults (20 QPS, 30 burst)

Config precedence

* --kubeconfig flag pointing at a file

* KUBECONFIG environment variable pointing at a file

* In-cluster config if running in cluster

* $HOME/.kube/config if exists

func GetConfigOrDie

func GetConfigOrDie() *rest.Config

GetConfigOrDie creates a *rest.Config for talking to a Kubernetes apiserver. If --kubeconfig is set, will use the kubeconfig file at that location. Otherwise will assume running in cluster and use the cluster provided kubeconfig.

Will log an error and exit if there is an error creating the rest.Config.

func Logf

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

Logf logs to the INFO logs.

func PatchPvcWithRetries

func PatchPvcWithRetries(c kubernetes.Interface, namespace, name, patchStr string) error

func RegisterParseFlags

func RegisterParseFlags()

RegisterParseFlags registers and parses flags for the test binary.

Types

type Framework

type Framework struct {
	BaseName string
	// A Kubernetes and Service Catalog client
	KubeClientSet          kubernetes.Interface
	KubeConfig             *restclient.Config
	APIExtensionsClientSet apiextcs.Interface
	Namespace              string
}

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 NewSimpleFramework

func NewSimpleFramework(baseName string) *Framework

NewSimpleFramework makes a new framework that allows the usage of a namespace for arbitraty tests.

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

func (f *Framework) CreateEnvironment()

func (*Framework) DeletePod

func (f *Framework) DeletePod(ns, name string) error

func (*Framework) DeletePvc

func (f *Framework) DeletePvc(name, namespace string) error

func (*Framework) DeleteStorageClass

func (f *Framework) DeleteStorageClass(storageClassName string)

func (*Framework) DestroyEnvironment

func (f *Framework) DestroyEnvironment()

func (*Framework) EnsurDeployment

func (f *Framework) EnsurDeployment(deploy *appsv1.Deployment, selector string) *appsv1.Deployment

func (*Framework) EnsurePvc

EnsurePvc creates a pvc object and returns it, throws error if it already exists.

func (*Framework) GetDeployment

func (f *Framework) GetDeployment(namespace string, name string) *appsv1.Deployment

func (*Framework) GetPods

func (f *Framework) GetPods(ns, labelSelector string) (pods *v1.PodList)

func (*Framework) GetPvc

func (f *Framework) GetPvc(namespace string, name string) *corev1.PersistentVolumeClaim

func (*Framework) Kubectl

func (f *Framework) Kubectl(args ...string) ([]byte, []byte, error)

func (*Framework) KubectlWithInput

func (f *Framework) KubectlWithInput(input []byte, args ...string) ([]byte, []byte, error)

func (*Framework) NewStorageClass

func (f *Framework) NewStorageClass(s *storagev1.StorageClass)

func (*Framework) PatchPvc

func (f *Framework) PatchPvc(namespace, name, patchStr string) *corev1.PersistentVolumeClaim

UpdatePvc updates a pvc object and returns the updated object.

func (*Framework) UpdatePvc

UpdatePvc updates a pvc object and returns the updated object.

func (*Framework) WaitForPod

func (f *Framework) WaitForPod(selector string, timeout time.Duration, shouldFail bool)

WaitForPod waits for a specific Pod to be ready, using a label selector

type Suite

type Suite string

Suite represents test suite.

var CurrentSuite Suite

CurrentSuite represents current test suite.

type TestContextType

type TestContextType struct {
	KubeHost string
	//KubeConfig  string
	KubeContext string
}

TestContextType describes the client context to use in communications with the Kubernetes API.

var TestContext TestContextType

TestContext is the global client context for tests.

Jump to

Keyboard shortcuts

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