tests

package
v1.12.1-RC1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2020 License: Apache-2.0 Imports: 45 Imported by: 0

README

Behavior Driven Development(BDD)

Maya makes use of ginkgo & gomega libraries to implement its integration tests.

To run the BDD test:

  1. Copy kubeconfig file into path ~/.kube/config or set the KUBECONFIG env.
  2. Change the current directory path to test related directory Example: To trigger the statefulesets test Step1: Change the pwd to test directory. cd github.com/openebs/maya/tests/sts/ Step2: Execute the command ginkgo -v -- -kubeconfig=/path/to/kubeconfig

Output: Sample example output

Running Suite: StatefulSet
==========================
Random Seed: 1555919486
Will run 1 of 2 specs

StatefulSet test statefulset application on cstor
  should distribute the cstor volume replicas across pools
  /home/sai/gocode/src/github.com/openebs/maya/tests/sts/sts_test.go:227
---------------------------------------------------------

Ran 1 of 1 Specs in 767.022 seconds
FAIL! -- 1 Passed | 0 Failed | 0 Pending | 0 Skipped

Ginkgo ran 1 suite in 12m49.573774959s
Test Suite Failed

Note: Above is the sample output how it looks when you ran ginkgo -v -- -kubeconfig=/path/to/kubeconfig

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CVRConfig

type CVRConfig struct {
	PoolObj    *apis.CStorPool
	VolumeName string
	Namespace  string
	Capacity   string
	Phase      string
	TargetIP   string
	ReplicaID  string
}

CVRConfig provides config to create CStorVolumeReplica

type Operations

type Operations struct {
	KubeClient     *kubeclient.Client
	NodeClient     *node.Kubeclient
	PodClient      *pod.KubeClient
	SCClient       *sc.Kubeclient
	PVCClient      *pvc.Kubeclient
	PVClient       *pv.Kubeclient
	NSClient       *ns.Kubeclient
	SnapClient     *snap.Kubeclient
	SnapDataClient *snapdata.Kubeclient
	CSPClient      *csp.Kubeclient
	CSPIClient     *cspi.Kubeclient
	SPCClient      *spc.Kubeclient
	SVCClient      *svc.Kubeclient
	CVClient       *cv.Kubeclient
	CVCClient      *cvc.Kubeclient
	CSPCClient     *cspc.Kubeclient
	CVRClient      *cvr.Kubeclient
	URClient       *result.Kubeclient
	UnstructClient *unstruct.Kubeclient
	DeployClient   *deploy.Kubeclient
	BDClient       *bd.Kubeclient
	BDCClient      *bdc.Kubeclient
	KubeConfigPath string
	NameSpace      string
	Config         interface{}
}

Operations provides clients amd methods to perform operations

func NewOperations

func NewOperations(opts ...OperationsOptions) *Operations

NewOperations returns a new instance of kubeclient meant for cstor volume replica operations

func (*Operations) BuildAndCreateCVR

func (ops *Operations) BuildAndCreateCVR() *apis.CStorVolumeReplica

BuildAndCreateCVR builds and creates CVR in cluster

func (*Operations) BuildAndCreatePVC

func (ops *Operations) BuildAndCreatePVC() *corev1.PersistentVolumeClaim

BuildAndCreatePVC builds and creates PersistentVolumeClaim in cluster

func (*Operations) BuildAndCreateSPC

func (ops *Operations) BuildAndCreateSPC() *apis.StoragePoolClaim

BuildAndCreateSPC builds and creates StoragePoolClaim in cluster

func (*Operations) BuildAndCreateService

func (ops *Operations) BuildAndCreateService() *corev1.Service

BuildAndCreateService builds and creates Service in cluster

func (*Operations) BuildAndDeployBusyBoxPod

func (ops *Operations) BuildAndDeployBusyBoxPod(
	appName, pvcName, namespace string,
	labels map[string]string) (*appsv1.Deployment, error)

func (*Operations) CreateStorageClass

func (ops *Operations) CreateStorageClass() *storagev1.StorageClass

CreateStorageClass builds and creates storageclass in cluster

func (*Operations) DeleteCSP

func (ops *Operations) DeleteCSP(spcName string, deleteCount int)

DeleteCSP ...

func (*Operations) DeleteCSPI

func (ops *Operations) DeleteCSPI(cspcName string, deleteCount int)

DeleteCSPI deletes ...

func (*Operations) DeletePersistentVolumeClaim

func (ops *Operations) DeletePersistentVolumeClaim(name, namespace string)

DeletePersistentVolumeClaim deletes PVC from cluster based on provided argument

func (*Operations) DeleteStoragePoolClaim

func (ops *Operations) DeleteStoragePoolClaim(spcName string)

DeleteStoragePoolClaim deletes StoragePoolClaim based on pool name

func (*Operations) DeleteVolumeResources

func (ops *Operations) DeleteVolumeResources(
	pvcObj *corev1.PersistentVolumeClaim,
	scObj *storagev1.StorageClass)

DeleteVolumeResources deletes pvc and storageclass from cluster

func (*Operations) ExecPod

func (ops *Operations) ExecPod(opts *Options) ([]byte, error)

ExecPod executes arbitrary command inside the pod

func (*Operations) ExecuteCMDEventually

func (ops *Operations) ExecuteCMDEventually(
	podObj *corev1.Pod,
	containerName,
	cmd string,
	expectStdout bool,
) string

ExecuteCMDEventually executes the command on pod container and returns stdout

func (*Operations) GetBDCCount

func (ops *Operations) GetBDCCount(lSelector, namespace string) int

GetBDCCount gets BDC resource count based on provided label selector

func (*Operations) GetBDCCountEventually

func (ops *Operations) GetBDCCountEventually(listOptions metav1.ListOptions, expectedBDCCount int, namespace string) int

GetBDCCountEventually gets BDC resource count based on provided list option.

func (*Operations) GetCSPCBDListForNode

func (ops *Operations) GetCSPCBDListForNode(node *corev1.Node, blockDeviceCount int) []*apis.CStorPoolClusterBlockDevice

GetCSPCBDListForNode returns unclaimed block devices that can be used.

func (*Operations) GetCSPCount

func (ops *Operations) GetCSPCount(labelSelector string) int

GetCSPCount gets csp count based on spcName at that time

func (*Operations) GetCSPCountEventually

func (ops *Operations) GetCSPCountEventually(labelSelector string, count int) bool

GetCSPCountEventually get csp count based on the labelSelector and wait til csp count matches to provided argument count

func (*Operations) GetCSPICount

func (ops *Operations) GetCSPICount(labelSelector string) int

GetCSPICount gets cspi count based on cspc name at that time

func (*Operations) GetCSPIResourceCountEventually

func (ops *Operations) GetCSPIResourceCountEventually(labelSelector string, expectedCSPICount int) int

GetCSPIResourceCountEventually gets cspis based on cspcName

func (*Operations) GetCVCount

func (ops *Operations) GetCVCount(namespace, lselector string, pred ...cv.Predicate) int

GetCVCount gives cstorvolume healthy count currently based on selecter

func (*Operations) GetCstorVolumeClaimCount

func (ops *Operations) GetCstorVolumeClaimCount(namespace, cvcName string) int

GetCstorVolumeClaimCount gives cstorVolumeClaim healthy count currently

func (*Operations) GetCstorVolumeClaimCountEventually

func (ops *Operations) GetCstorVolumeClaimCountEventually(namespace, cvcName string, expectedCVCCount int) bool

GetCstorVolumeClaimCountEventually gives the count of cstorvolume claim

func (*Operations) GetCstorVolumeCount

func (ops *Operations) GetCstorVolumeCount(namespace, lselector string, expectedCVCount int, preds ...cv.Predicate) int

GetCstorVolumeCount gives the count of cstorvolume based on selecter

func (*Operations) GetCstorVolumeCountEventually

func (ops *Operations) GetCstorVolumeCountEventually(namespace, lselector string, expectedCVCount int) bool

GetCstorVolumeCountEventually gives the count of cstorvolume based on selecter eventually

func (*Operations) GetCstorVolumeReplicaCount

func (ops *Operations) GetCstorVolumeReplicaCount(namespace, lselector string, pred ...cvr.Predicate) int

GetCstorVolumeReplicaCount gives cstorvolumereplica healthy count currently based on selecter

func (*Operations) GetCstorVolumeReplicaCountEventually

func (ops *Operations) GetCstorVolumeReplicaCountEventually(namespace, lselector string, expectedCVRCount int, pred ...cvr.Predicate) bool

GetCstorVolumeReplicaCountEventually gives the count of cstorvolume based on selecter eventually

func (*Operations) GetHealthyCSPCount

func (ops *Operations) GetHealthyCSPCount(spcName string, expectedCSPCount int) int

GetHealthyCSPCount gets healthy csp based on spcName

func (*Operations) GetHealthyCSPCountEventually

func (ops *Operations) GetHealthyCSPCountEventually(spcName string, expectedCSPCount int) bool

GetHealthyCSPCountEventually gets healthy csp based on spcName

func (*Operations) GetHealthyCSPICount

func (ops *Operations) GetHealthyCSPICount(cspcName string, expectedCSPICount int) int

GetHealthyCSPICount gets healthy csp based on spcName

func (*Operations) GetPVNameFromPVCName

func (ops *Operations) GetPVNameFromPVCName(pvcName string) string

GetPVNameFromPVCName gives the pv name for the given pvc

func (*Operations) GetPodCompletedCount

func (ops *Operations) GetPodCompletedCount(namespace, lselector string) int

GetPodCompletedCount gives number of pods running currently

func (*Operations) GetPodCompletedCountEventually

func (ops *Operations) GetPodCompletedCountEventually(namespace, lselector string, expectedPodCount int) int

GetPodCompletedCountEventually gives the number of pods running eventually

func (*Operations) GetPodCountEventually

func (ops *Operations) GetPodCountEventually(
	namespace, lselector string,
	predicateList pod.PredicateList, expectedCount int) int

GetPodCountEventually returns the no.of pods exists with specified labelselector

func (*Operations) GetPodList

func (ops *Operations) GetPodList(namespace, lselector string, predicateList pod.PredicateList) *pod.PodList

GetPodList gives list of running pods for given namespace + label

func (*Operations) GetPodRunningCount

func (ops *Operations) GetPodRunningCount(namespace, lselector string) int

GetPodRunningCount gives number of pods running currently

func (*Operations) GetPodRunningCountEventually

func (ops *Operations) GetPodRunningCountEventually(namespace, lselector string, expectedPodCount int) int

GetPodRunningCountEventually gives the number of pods running eventually

func (*Operations) GetReadyNodes

func (ops *Operations) GetReadyNodes() *corev1.NodeList

GetReadyNodes gives cstorvolumereplica healthy count currently based on selecter

func (*Operations) GetSVCClusterIP

func (ops *Operations) GetSVCClusterIP(ns, lselector string) ([]string, error)

GetSVCClusterIP returns list of IP address of the services, having given label and namespace

func (*Operations) GetSnapshotType

func (ops *Operations) GetSnapshotType(snapName string) string

GetSnapshotType returns type of snapshot currently

func (*Operations) GetSnapshotTypeEventually

func (ops *Operations) GetSnapshotTypeEventually(snapName string) string

GetSnapshotTypeEventually returns type of snapshot eventually

func (*Operations) GetUnUsedCStorPool

func (ops *Operations) GetUnUsedCStorPool(
	cvrList *apis.CStorVolumeReplicaList,
	poolLabel string) *apis.CStorPool

GetUnUsedCStorPool returns the csp object where the volume replica doesn't exist

func (*Operations) IsCSPCDeletedEventually

func (ops *Operations) IsCSPCDeletedEventually(cspcName string) bool

IsCSPCDeletedEventually tries to get the deleted cspc and returns true if cspc is not found else returns false

func (*Operations) IsCSPCFinalizerExistsOnBDCs

func (ops *Operations) IsCSPCFinalizerExistsOnBDCs(listOptions metav1.ListOptions, cspcFinalizer string) bool

IsCSPCFinalizerExistsOnBDCs returns true if the all the BDCs( selected by provided list options) has cspc finalizer on it.

func (*Operations) IsCSPCFinalizerExistsOnCSPC

func (ops *Operations) IsCSPCFinalizerExistsOnCSPC(cspcName, cspcFinalizer string) bool

IsCSPCFinalizerExistsOnCSPC returns true if the cspc with provided name contains the cspc finalizer.

func (*Operations) IsCSPCNotExists

func (ops *Operations) IsCSPCNotExists(cspcName string) bool

IsCSPCNotExists returns true if the cspc with provided name does not exists.

func (*Operations) IsFinalizerExistsOnBDC

func (ops *Operations) IsFinalizerExistsOnBDC(bdcName, finalizer string) bool

IsFinalizerExistsOnBDC returns true if the object with provided name contains the finalizer.

func (*Operations) IsFinalizerExistsOnCSP

func (ops *Operations) IsFinalizerExistsOnCSP(
	listOptions metav1.ListOptions,
	finalizer string) error

IsFinalizerExistsOnCSP returns nil if all the CSPs(selected by listoption) has pool protection finalizer and returns error if timeout occured (or) error occured during list call

func (*Operations) IsPVCBound

func (ops *Operations) IsPVCBound(pvcName string) bool

IsPVCBound checks if the pvc is bound or not

func (*Operations) IsPVCBoundEventually

func (ops *Operations) IsPVCBoundEventually(pvcName string) bool

IsPVCBoundEventually checks if the pvc is bound or not eventually

func (*Operations) IsPVCDeleted

func (ops *Operations) IsPVCDeleted(pvcName string) bool

IsPVCDeleted tries to get the deleted pvc and returns true if pvc is not found else returns false

func (*Operations) IsPVCDeletedEventually

func (ops *Operations) IsPVCDeletedEventually(pvcName string) bool

IsPVCDeletedEventually tries to get the deleted pvc and returns true if pvc is not found else returns false

func (*Operations) IsPodDeletedEventually

func (ops *Operations) IsPodDeletedEventually(namespace, podName string) bool

IsPodDeletedEventually checks if the pod is deleted or not eventually

func (*Operations) IsPodRunningEventually

func (ops *Operations) IsPodRunningEventually(namespace, podName string) bool

IsPodRunningEventually return true if the pod comes to running state

func (*Operations) IsSPCFinalizerExistsOnBDCs

func (ops *Operations) IsSPCFinalizerExistsOnBDCs(listOptions metav1.ListOptions, spcFinalizer string) bool

IsSPCFinalizerExistsOnBDCs returns true if the all the BDCs( selected by provided list options) has spc finalizer on it.

func (*Operations) IsSPCFinalizerExistsOnSPC

func (ops *Operations) IsSPCFinalizerExistsOnSPC(spcName, spcFinalizer string) bool

IsSPCFinalizerExistsOnSPC returns true if the spc with provided name contains the spc finalizer.

func (*Operations) IsSPCNotExists

func (ops *Operations) IsSPCNotExists(spcName string) bool

IsSPCNotExists returns true if the spc with provided name does not exists.

func (*Operations) IsSnapshotDataDeleted

func (ops *Operations) IsSnapshotDataDeleted(snapshotDataName string) bool

IsSnapshotDataDeleted checks if the snapshotdata is deleted or not

func (*Operations) IsSnapshotDeleted

func (ops *Operations) IsSnapshotDeleted(snapName string) bool

IsSnapshotDeleted checks if the snapshot is deleted or not

func (*Operations) PodDeleteCollection

func (ops *Operations) PodDeleteCollection(ns string, lopts metav1.ListOptions) error

PodDeleteCollection deletes all the pods in a namespace matched the given labelselector

func (*Operations) RestartPodEventually

func (ops *Operations) RestartPodEventually(podObj *corev1.Pod) error

RestartPodEventually restarts the pod and return

func (*Operations) VerifyCapacity

func (ops *Operations) VerifyCapacity(pvcName, capacity string) bool

VerifyCapacity checks if the pvc capacity has been updated

func (*Operations) VerifyDesiredCSPCount

func (ops *Operations) VerifyDesiredCSPCount(spcObj *apis.StoragePoolClaim, poolCount int)

VerifyDesiredCSPCount verifies whether count of CSP belongs to SPC in cluster matched with provided argument count

func (*Operations) VerifyOpenebs

func (ops *Operations) VerifyOpenebs(expectedPodCount int) *Operations

VerifyOpenebs verify running state of required openebs control plane components

func (*Operations) VerifyPoolResources

func (ops *Operations) VerifyPoolResources(spcName string)

VerifyPoolResources verifies whether pool resource exist or not

func (*Operations) VerifyUpgradeResultTasksIsNotFail

func (ops *Operations) VerifyUpgradeResultTasksIsNotFail(namespace, lselector string) bool

VerifyUpgradeResultTasksIsNotFail checks whether all the tasks in upgraderesult have success

func (*Operations) VerifyVolumeResources

func (ops *Operations) VerifyVolumeResources(pvName, namespace string, cvrPred cvr.PredicateList, cvPred cv.PredicateList)

VerifyVolumeResources verifies whether volume resource exist or not

func (*Operations) VerifyVolumeStatus

func (ops *Operations) VerifyVolumeStatus(
	pvcObj *corev1.PersistentVolumeClaim, replicaCount int, cvrPred cvr.PredicateList, cvPred cv.PredicateList)

VerifyVolumeStatus checks multiple resources related to volume 1. Verifies whether PVC is bound to pv or not 2. Verifies whether CStorVolume is in Healthy or not 3. Verifies whether specified number of CVR's are healthy or not

type OperationsOptions

type OperationsOptions func(*Operations)

OperationsOptions abstracts creating an instance of operations

func WithKubeConfigPath

func WithKubeConfigPath(path string) OperationsOptions

WithKubeConfigPath sets the kubeConfig path against operations instance

type Options

type Options struct {
	// contains filtered or unexported fields
}

Options holds the args used for exec'ing into the pod

func NewOptions

func NewOptions() *Options

NewOptions returns the new instance of Options

func (*Options) WithCommand

func (o *Options) WithCommand(cmd ...string) *Options

WithCommand fills the cmd field in Options struct

func (*Options) WithContainer

func (o *Options) WithContainer(container string) *Options

WithContainer fills the container field in Options struct

func (*Options) WithNamespace

func (o *Options) WithNamespace(ns string) *Options

WithNamespace fills the namespace field in Options struct

func (*Options) WithPodName

func (o *Options) WithPodName(name string) *Options

WithPodName fills the podName field in Options struct

type PVCConfig

type PVCConfig struct {
	Name        string
	Namespace   string
	SCName      string
	Capacity    string
	AccessModes []corev1.PersistentVolumeAccessMode
}

PVCConfig provides config to create PersistentVolumeClaim

type SCConfig

type SCConfig struct {
	Name              string
	Annotations       map[string]string
	Provisioner       string
	VolumeBindingMode storagev1.VolumeBindingMode
}

SCConfig provides config to create storage class

type SPCConfig

type SPCConfig struct {
	Name      string
	DiskType  string
	PoolType  string
	PoolCount int
	// OverProvisioning field is deprecated and not honoured
	IsOverProvisioning bool

	IsThickProvisioning bool
}

SPCConfig provides config to create cstor pools

type ServiceConfig

type ServiceConfig struct {
	Name        string
	Namespace   string
	Selectors   map[string]string
	ServicePort []corev1.ServicePort
}

ServiceConfig provides config to create Service

Directories

Path Synopsis
csi
framework

Jump to

Keyboard shortcuts

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