framework

package
v0.0.0-...-43d0de1 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2020 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OCIConfigVar       = "OCICONFIG_VAR"
	KubeConfigVar      = "KUBECONFIG_VAR"
	SubnetOCID         = "SUBNET_OCID"
	MntTargetOCID      = "MNT_TARGET_OCID"
	KubeSystemNS       = "kube-system"
	ClassOCI           = "oci"
	ClassOCIExt3       = "oci-ext3"
	ClassOCINoParamFss = "oci-fss-noparam"
	ClassOCIMntFss     = "oci-fss-mnt"
	ClassOCISubnetFss  = "oci-fss-subnet"
	MinVolumeBlock     = "50Gi"
	VolumeFss          = "1Gi"
	FSSProv            = "oci-volume-provisioner-fss"
	OCIProv            = "oci-volume-provisioner"
	SecretNameDefault  = "oci-volume-provisioner"
)
View Source
const (
	// Poll defines how regularly to poll kubernetes resources.
	Poll = 2 * time.Second
	// DefaultTimeout is how long we wait for long-running operations in the
	// test suite before giving up.
	DefaultTimeout = 10 * time.Minute
)

Variables

This section is empty.

Functions

func Failf

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

Failf used in framework

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 KubectlCmd

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

KubectlCmd runs the kubectl executable through the wrapper script.

func Logf

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

Logf used in framework

func RegisterFlags

func RegisterFlags()

RegisterFlags registers the test framework flags and populates TestContext.

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.

Types

type CleanupActionHandle

type CleanupActionHandle *int

CleanupActionHandle is declared as int, checked in case of a cleanup

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 Framework

type Framework struct {
	BaseName                  string
	ProvisionerFSSInstalled   bool
	ProvisionerBlockInstalled bool

	ClientSet clientset.Interface

	BlockStorageClient ocicore.BlockstorageClient
	IsBackup           bool
	BackupIDs          []string
	StorageClasses     []string

	Namespace *v1.Namespace // Every test has at least one namespace unless creation is skipped
	// contains filtered or unexported fields
}

Framework is used in the execution of e2e tests.

func NewBackupFramework

func NewBackupFramework(baseName string) *Framework

NewBackupFramework constructs a new e2e test Framework initialising a storage client used to create a backup

func NewDefaultFramework

func NewDefaultFramework(baseName string) *Framework

NewDefaultFramework constructs a new e2e test Framework with default options.

func NewFramework

func NewFramework(baseName string, client clientset.Interface, backup bool) *Framework

NewFramework constructs a new e2e test Framework.

func (*Framework) AfterEach

func (f *Framework) AfterEach()

AfterEach deletes the namespace(s).

func (*Framework) BeforeEach

func (f *Framework) BeforeEach()

BeforeEach gets a client and makes a namespace.

func (*Framework) CheckandInstallProvisioner

func (f *Framework) CheckandInstallProvisioner(provisionerName string, provisionerType string) bool

CheckandInstallProvisioner checks if a provisioner is installed, if installed uses the following provisioner. Otherwise, creates a provisioner in the test namespace such that after the test it can go back to its original state.

func (*Framework) CreateNamespace

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

CreateNamespace creates a e2e test namespace.

func (*Framework) CreateStorageClassOrFail

func (f *Framework) CreateStorageClassOrFail(name string, provisionerType string, parameters map[string]string, testLabels map[string]string) string

CreateStorageClassOrFail creates a new storage class based on the jig's defaults.

func (*Framework) DeleteNamespace

func (f *Framework) DeleteNamespace(namespace string, timeout time.Duration) error

DeleteNamespace deletes a given namespace and waits until its contents are deleted.

type PVCTestJig

type PVCTestJig struct {
	ID     string
	Name   string
	Labels map[string]string

	BlockStorageClient *ocicore.BlockstorageClient
	KubeClient         clientset.Interface
}

PVCTestJig is a jig to help create PVC tests.

func NewPVCTestJig

func NewPVCTestJig(kubeClient clientset.Interface, name string) *PVCTestJig

NewPVCTestJig allocates and inits a new PVCTestJig.

func (*PVCTestJig) CheckVolumeReadWrite

func (j *PVCTestJig) CheckVolumeReadWrite(namespace string, pvcParam *v1.PersistentVolumeClaim)

CheckVolumeReadWrite creates a pod with a dymincally provisioned volume

func (*PVCTestJig) CreateAndAwaitNginxPodOrFail

func (j *PVCTestJig) CreateAndAwaitNginxPodOrFail(ns string, pvc *v1.PersistentVolumeClaim, command string)

CreateAndAwaitNginxPodOrFail returns a pod definition based on the namespace using nginx image

func (*PVCTestJig) CreateAndAwaitPVCOrFail

func (j *PVCTestJig) CreateAndAwaitPVCOrFail(namespace string, volumeSize string, scName string, adLabel string, tweak func(pvc *v1.PersistentVolumeClaim)) *v1.PersistentVolumeClaim

CreateAndAwaitPVCOrFail creates a new PVC based on the jig's defaults, waits for it to become ready, and then sanity checks it and its dependant resources. Callers can provide a function to tweak the PVC object before it is created.

func (*PVCTestJig) CreateBackupVolume

func (j *PVCTestJig) CreateBackupVolume(storageClient ocicore.BlockstorageClient, pvc *v1.PersistentVolumeClaim) (string, error)

CreateBackupVolume creates a volume backup on OCI from an exsiting volume and returns the backup volume id

func (*PVCTestJig) CreatePVCorFail

func (j *PVCTestJig) CreatePVCorFail(namespace string, volumeSize string, scName string, adLabel string, tweak func(pvc *v1.PersistentVolumeClaim)) *v1.PersistentVolumeClaim

CreatePVCorFail creates a new claim based on the jig's defaults. Callers can provide a function to tweak the claim object before it is created.

func (*PVCTestJig) DeletePersistentVolumeClaim

func (j *PVCTestJig) DeletePersistentVolumeClaim(ns string, pvcName string) error

DeletePersistentVolumeClaim deletes the PersistentVolumeClaim with the given name / namespace.

func (*PVCTestJig) SanityCheckPV

func (j *PVCTestJig) SanityCheckPV(pvc *v1.PersistentVolumeClaim)

SanityCheckPV checks basic properties of a given volume match our expectations.

func (*PVCTestJig) WaitForPVCPhase

func (j *PVCTestJig) WaitForPVCPhase(phase v1.PersistentVolumeClaimPhase, ns string, pvcName string) error

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

type TestContextType

type TestContextType struct {
	// RepoRoot is the root directory of the repository.
	RepoRoot string

	// KubeConfig is the path to the kubeconfig file.
	KubeConfig string

	// OCIConfig is the path to the ociconfig file
	OCIConfig string

	// AD used to specify an availability domain to create the volumes in.
	AD string

	// MntTargetOCID used mount a volume to the specific mount id
	MntTargetOCID string

	// SubnetOCID used to mount a volume looking for a mount in the specified subnet
	SubnetOCID string

	// Image is the docker image to which we are building
	Image string

	// Namespace (if provided) is the namespace of an existing namespace to
	// use for test execution rather than creating a new namespace.
	Namespace string
	// DeleteNamespace controls whether or not to delete test namespaces
	DeleteNamespace bool
	// DeleteNamespaceOnFailure controls whether or not to delete test
	// namespaces when the test fails.
	DeleteNamespaceOnFailure bool
}

TestContextType represents the framework flags

var TestContext TestContextType

TestContext holds the context of the the test run.

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