Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tests/e2e/config_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var _ bool = ginkgo.Describe("[csi-supervisor] config-change-test", func() {
namespace = getNamespaceToRunTests(f)
ctx, cancel = context.WithCancel(context.Background())
defer cancel()

nodeList, err := fnodes.GetReadySchedulableNodes(ctx, f.ClientSet)
framework.ExpectNoError(err, "Unable to find ready and schedulable Node")
if !(len(nodeList.Items) > 0) {
Expand Down Expand Up @@ -81,7 +82,7 @@ var _ bool = ginkgo.Describe("[csi-supervisor] config-change-test", func() {
gomega.Expect(err).NotTo(gomega.HaveOccurred())

ginkgo.By(fmt.Sprintf("Waiting for claim %s to be in bound phase", pvc.Name))
pvs, err := fpv.WaitForPVClaimBoundPhase(ctx, client,
pvs, err := WaitForPVClaimBoundPhase(ctx, client,
[]*v1.PersistentVolumeClaim{pvc}, framework.ClaimProvisionTimeout)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(pvs).NotTo(gomega.BeEmpty())
Expand Down
81 changes: 49 additions & 32 deletions tests/e2e/csi_snapshot_basic.go

Large diffs are not rendered by default.

62 changes: 41 additions & 21 deletions tests/e2e/csi_snapshot_negative.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@ var _ = ginkgo.Describe("[block-snapshot-negative] Volume Snapshot Fault-Injecti
serviceName string
pandoraSyncWaitTime int
storagePolicyName string
adminClient clientset.Interface
)

ginkgo.BeforeEach(func() {
bootstrap()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
client = f.ClientSet
var err error

adminClient, client = initializeClusterClientsByUserRoles(client)
namespace = getNamespaceToRunTests(f)
scParameters = make(map[string]string)
isServiceStopped = false
Expand Down Expand Up @@ -114,12 +118,13 @@ var _ = ginkgo.Describe("[block-snapshot-negative] Volume Snapshot Fault-Injecti
ctx, vSphereCSIControllerPodNamePrefix, metav1.GetOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
svcCsiReplicas = *csiDeployment.Spec.Replicas
}
} else {

csiDeployment, err := client.AppsV1().Deployments(csiNamespace).Get(
ctx, vSphereCSIControllerPodNamePrefix, metav1.GetOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
csiReplicas = *csiDeployment.Spec.Replicas
csiDeployment, err := client.AppsV1().Deployments(csiNamespace).Get(
ctx, vSphereCSIControllerPodNamePrefix, metav1.GetOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
csiReplicas = *csiDeployment.Spec.Replicas
}

if os.Getenv(envPandoraSyncWaitTime) != "" {
pandoraSyncWaitTime, err = strconv.Atoi(os.Getenv(envPandoraSyncWaitTime))
Expand All @@ -143,15 +148,15 @@ var _ = ginkgo.Describe("[block-snapshot-negative] Volume Snapshot Fault-Injecti
if serviceName == "CSI" {
framework.Logf("Starting CSI driver")
ignoreLabels := make(map[string]string)
err := updateDeploymentReplicawithWait(client, csiReplicas, vSphereCSIControllerPodNamePrefix,
err := updateDeploymentReplicawithWait(adminClient, csiReplicas, vSphereCSIControllerPodNamePrefix,
csiSystemNamespace)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

// Wait for the CSI Pods to be up and Running
list_of_pods, err := fpod.GetPodsInNamespace(ctx, client, csiSystemNamespace, ignoreLabels)
list_of_pods, err := fpod.GetPodsInNamespace(ctx, adminClient, csiSystemNamespace, ignoreLabels)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
num_csi_pods := len(list_of_pods)
err = fpod.WaitForPodsRunningReady(ctx, client, csiSystemNamespace, int(num_csi_pods),
err = fpod.WaitForPodsRunningReady(ctx, adminClient, csiSystemNamespace, int(num_csi_pods),
time.Duration(pollTimeout))
gomega.Expect(err).NotTo(gomega.HaveOccurred())
} else if serviceName == hostdServiceName {
Expand All @@ -170,7 +175,15 @@ var _ = ginkgo.Describe("[block-snapshot-negative] Volume Snapshot Fault-Injecti
}

ginkgo.By(fmt.Sprintf("Resetting provisioner time interval to %s sec", defaultProvisionerTimeInSec))
updateCSIDeploymentProvisionerTimeout(client, csiSystemNamespace, defaultProvisionerTimeInSec)
updateCSIDeploymentProvisionerTimeout(adminClient, csiSystemNamespace, defaultProvisionerTimeInSec)

if supervisorCluster {
dumpSvcNsEventsOnTestFailure(client, namespace)
}
if guestCluster {
svcClient, svNamespace := getSvcClientAndNamespace()
dumpSvcNsEventsOnTestFailure(svcClient, svNamespace)
}
})

/*
Expand Down Expand Up @@ -318,6 +331,13 @@ func snapshotOperationWhileServiceDown(serviceName string, namespace string,

storagePolicyName := GetAndExpectStringEnvVar(envStoragePolicyNameForSharedDatastores)

/*var testClient clientset.Interface
if vanillaCluster {
testClient = client
} else {
testClient = adminClient
}*/
adminClient, _ := initializeClusterClientsByUserRoles(client)
if vanillaCluster {
ginkgo.By("Create storage class")
scParameters[scParamDatastoreURL] = datastoreURL
Expand All @@ -329,7 +349,7 @@ func snapshotOperationWhileServiceDown(serviceName string, namespace string,
}()
} else if supervisorCluster {
ginkgo.By("Get storage class")
storageclass, err = client.StorageV1().StorageClasses().Get(ctx, storagePolicyName, metav1.GetOptions{})
storageclass, err = adminClient.StorageV1().StorageClasses().Get(ctx, storagePolicyName, metav1.GetOptions{})
if !apierrors.IsNotFound(err) {
gomega.Expect(err).NotTo(gomega.HaveOccurred())
}
Expand All @@ -340,7 +360,7 @@ func snapshotOperationWhileServiceDown(serviceName string, namespace string,
storageclass, err = createStorageClass(client, scParameters, nil, "", "", false, "")
gomega.Expect(err).NotTo(gomega.HaveOccurred())
defer func() {
err := client.StorageV1().StorageClasses().Delete(ctx, storageclass.Name, *metav1.NewDeleteOptions(0))
err := adminClient.StorageV1().StorageClasses().Delete(ctx, storageclass.Name, *metav1.NewDeleteOptions(0))
gomega.Expect(err).NotTo(gomega.HaveOccurred())
}()
}
Expand Down Expand Up @@ -404,18 +424,18 @@ func snapshotOperationWhileServiceDown(serviceName string, namespace string,

if serviceName == "CSI" {
ginkgo.By("Stopping CSI driver")
isServiceStopped, err = stopCSIPods(ctx, client, csiNamespace)
isServiceStopped, err = stopCSIPods(ctx, adminClient, csiNamespace)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

defer func() {
if isServiceStopped {
framework.Logf("Starting CSI driver")
isServiceStopped, err = startCSIPods(ctx, client, csiReplicas, csiNamespace)
isServiceStopped, err = startCSIPods(ctx, adminClient, csiReplicas, csiNamespace)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
}
}()
framework.Logf("Starting CSI driver")
isServiceStopped, err = startCSIPods(ctx, client, csiReplicas, csiNamespace)
isServiceStopped, err = startCSIPods(ctx, adminClient, csiReplicas, csiNamespace)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

ginkgo.By(fmt.Sprintf("Sleeping for %v seconds to allow full sync finish", fullSyncWaitTime))
Expand Down Expand Up @@ -531,17 +551,17 @@ func snapshotOperationWhileServiceDown(serviceName string, namespace string,

if serviceName == "CSI" {
ginkgo.By("Stopping CSI driver")
isServiceStopped, err = stopCSIPods(ctx, client, csiNamespace)
isServiceStopped, err = stopCSIPods(ctx, adminClient, csiNamespace)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
defer func() {
if isServiceStopped {
framework.Logf("Starting CSI driver")
isServiceStopped, err = startCSIPods(ctx, client, csiReplicas, csiNamespace)
isServiceStopped, err = startCSIPods(ctx, adminClient, csiReplicas, csiNamespace)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
}
}()
framework.Logf("Starting CSI driver")
isServiceStopped, err = startCSIPods(ctx, client, csiReplicas, csiNamespace)
isServiceStopped, err = startCSIPods(ctx, adminClient, csiReplicas, csiNamespace)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

ginkgo.By(fmt.Sprintf("Sleeping for %v seconds to allow full sync finish", fullSyncWaitTime))
Expand Down Expand Up @@ -633,7 +653,7 @@ func snapshotOperationWhileServiceDown(serviceName string, namespace string,

//After service restart
bootstrap()
persistentvolumes2, err := fpv.WaitForPVClaimBoundPhase(ctx, client,
persistentvolumes2, err := WaitForPVClaimBoundPhase(ctx, client,
[]*v1.PersistentVolumeClaim{pvclaim2}, framework.ClaimProvisionTimeout)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
volHandle2 := persistentvolumes2[0].Spec.CSI.VolumeHandle
Expand All @@ -657,18 +677,18 @@ func snapshotOperationWhileServiceDown(serviceName string, namespace string,
if isSnapshotCreated {
if serviceName == "CSI" {
ginkgo.By("Stopping CSI driver")
isServiceStopped, err = stopCSIPods(ctx, client, csiNamespace)
isServiceStopped, err = stopCSIPods(ctx, adminClient, csiNamespace)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

defer func() {
if isServiceStopped {
framework.Logf("Starting CSI driver")
isServiceStopped, err = startCSIPods(ctx, client, csiReplicas, csiNamespace)
isServiceStopped, err = startCSIPods(ctx, adminClient, csiReplicas, csiNamespace)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
}
}()
framework.Logf("Starting CSI driver")
isServiceStopped, err = startCSIPods(ctx, client, csiReplicas, csiNamespace)
isServiceStopped, err = startCSIPods(ctx, adminClient, csiReplicas, csiNamespace)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

ginkgo.By(fmt.Sprintf("Sleeping for %v seconds to allow full sync finish", fullSyncWaitTime))
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/csi_snapshot_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ func verifyVolumeRestoreOperation(ctx context.Context, client clientset.Interfac
pvclaim2, err := fpv.CreatePVC(ctx, client, namespace, pvcSpec)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

persistentvolumes2, err := fpv.WaitForPVClaimBoundPhase(ctx, client,
persistentvolumes2, err := WaitForPVClaimBoundPhase(ctx, client,
[]*v1.PersistentVolumeClaim{pvclaim2}, framework.ClaimProvisionTimeout)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
volHandle2 := persistentvolumes2[0].Spec.CSI.VolumeHandle
Expand Down Expand Up @@ -759,8 +759,8 @@ func verifyVolumeRestoreOperation(ctx context.Context, client clientset.Interfac

// createPVCAndQueryVolumeInCNS creates PVc with a given storage class on a given namespace
// and verifies cns metadata of that volume if verifyCNSVolume is set to true
func createPVCAndQueryVolumeInCNS(ctx context.Context, client clientset.Interface, namespace string,
pvclaimLabels map[string]string, accessMode v1.PersistentVolumeAccessMode,
func createPVCAndQueryVolumeInCNS(ctx context.Context, client clientset.Interface,
namespace string, pvclaimLabels map[string]string, accessMode v1.PersistentVolumeAccessMode,
ds string, storageclass *storagev1.StorageClass,
verifyCNSVolume bool) (*v1.PersistentVolumeClaim, []*v1.PersistentVolume, error) {

Expand All @@ -771,7 +771,7 @@ func createPVCAndQueryVolumeInCNS(ctx context.Context, client clientset.Interfac
}

// Wait for PVC to be bound to a PV
persistentvolumes, err := fpv.WaitForPVClaimBoundPhase(ctx, client,
persistentvolumes, err := WaitForPVClaimBoundPhase(ctx, client,
[]*v1.PersistentVolumeClaim{pvclaim}, framework.ClaimProvisionTimeout*2)
if err != nil {
return pvclaim, persistentvolumes, fmt.Errorf("failed to wait for PVC to bind to a PV: %w", err)
Expand Down
Loading