Skip to content

Commit d18886a

Browse files
committed
wffc vmservicevm regression code changes
1 parent f03e1fe commit d18886a

File tree

5 files changed

+735
-217
lines changed

5 files changed

+735
-217
lines changed

tests/e2e/csi_snapshot_utils.go

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ func deleteVolumeSnapshot(ctx context.Context, snapc *snapclient.Clientset, name
349349
}
350350
snapshotContentCreated := false
351351

352-
if performCnsQueryVolumeSnapshot {
352+
if performCnsQueryVolumeSnapshot && !latebinding {
353353
framework.Logf("Verify snapshot entry %v is deleted from CNS for volume %v", snapshotID, volHandle)
354354
err = waitForCNSSnapshotToBeDeleted(volHandle, snapshotID)
355355
if err != nil {
@@ -489,7 +489,7 @@ func createDynamicVolumeSnapshot(ctx context.Context, namespace string,
489489
return volumeSnapshot, snapshotContent, false, false, snapshotId, "", err
490490
}
491491

492-
if performCnsQueryVolumeSnapshot {
492+
if performCnsQueryVolumeSnapshot && !latebinding {
493493
ginkgo.By("Query CNS and check the volume snapshot entry")
494494
err = waitForCNSSnapshotToBeCreated(volHandle, snapshotId)
495495
if err != nil {
@@ -684,21 +684,26 @@ func verifyVolumeRestoreOperation(ctx context.Context, client clientset.Interfac
684684
volumeSnapshot *snapV1.VolumeSnapshot, diskSize string,
685685
verifyPodCreation bool) (*v1.PersistentVolumeClaim, []*v1.PersistentVolume, *v1.Pod) {
686686

687+
var volHandle2 string
688+
var persistentvolumes2 []*v1.PersistentVolume
687689
ginkgo.By("Create PVC from snapshot")
688690
pvcSpec := getPersistentVolumeClaimSpecWithDatasource(namespace, diskSize, storageclass, nil,
689691
v1.ReadWriteOnce, volumeSnapshot.Name, snapshotapigroup)
690692

691693
pvclaim2, err := fpv.CreatePVC(ctx, client, namespace, pvcSpec)
692694
gomega.Expect(err).NotTo(gomega.HaveOccurred())
693695

694-
persistentvolumes2, err := fpv.WaitForPVClaimBoundPhase(ctx, client,
695-
[]*v1.PersistentVolumeClaim{pvclaim2}, framework.ClaimProvisionTimeout)
696-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
697-
volHandle2 := persistentvolumes2[0].Spec.CSI.VolumeHandle
698-
if guestCluster {
699-
volHandle2 = getVolumeIDFromSupervisorCluster(volHandle2)
696+
if !latebinding {
697+
ginkgo.By("Verify PVC bound state created with Immediate binding mode storage policy")
698+
persistentvolumes2, err = fpv.WaitForPVClaimBoundPhase(ctx, client,
699+
[]*v1.PersistentVolumeClaim{pvclaim2}, framework.ClaimProvisionTimeout)
700+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
701+
volHandle2 = persistentvolumes2[0].Spec.CSI.VolumeHandle
702+
if guestCluster {
703+
volHandle2 = getVolumeIDFromSupervisorCluster(volHandle2)
704+
}
705+
gomega.Expect(volHandle2).NotTo(gomega.BeEmpty())
700706
}
701-
gomega.Expect(volHandle2).NotTo(gomega.BeEmpty())
702707

703708
var pod *v1.Pod
704709
if verifyPodCreation {
@@ -770,35 +775,38 @@ func createPVCAndQueryVolumeInCNS(ctx context.Context, client clientset.Interfac
770775
return pvclaim, nil, fmt.Errorf("failed to create PVC: %w", err)
771776
}
772777

773-
// Wait for PVC to be bound to a PV
774-
persistentvolumes, err := fpv.WaitForPVClaimBoundPhase(ctx, client,
775-
[]*v1.PersistentVolumeClaim{pvclaim}, framework.ClaimProvisionTimeout*2)
776-
if err != nil {
777-
return pvclaim, persistentvolumes, fmt.Errorf("failed to wait for PVC to bind to a PV: %w", err)
778-
}
779-
780-
// Get VolumeHandle from the PV
781-
volHandle := persistentvolumes[0].Spec.CSI.VolumeHandle
782-
if guestCluster {
783-
volHandle = getVolumeIDFromSupervisorCluster(volHandle)
784-
}
785-
if volHandle == "" {
786-
return pvclaim, persistentvolumes, fmt.Errorf("volume handle is empty")
787-
}
788-
789-
// Verify the volume in CNS if required
790-
if verifyCNSVolume {
791-
ginkgo.By(fmt.Sprintf("Invoking QueryCNSVolumeWithResult with VolumeID: %s", volHandle))
792-
queryResult, err := e2eVSphere.queryCNSVolumeWithResult(volHandle)
778+
if !latebinding {
779+
ginkgo.By("Verify PVC bound state created with Immediate binding mode storage policy")
780+
persistentvolumes, err := fpv.WaitForPVClaimBoundPhase(ctx, client,
781+
[]*v1.PersistentVolumeClaim{pvclaim}, framework.ClaimProvisionTimeout*2)
793782
if err != nil {
794-
return pvclaim, persistentvolumes, fmt.Errorf("failed to query CNS volume: %w", err)
783+
return pvclaim, persistentvolumes, fmt.Errorf("failed to wait for PVC to bind to a PV: %w", err)
784+
}
785+
786+
// Get VolumeHandle from the PV
787+
volHandle := persistentvolumes[0].Spec.CSI.VolumeHandle
788+
if guestCluster {
789+
volHandle = getVolumeIDFromSupervisorCluster(volHandle)
790+
}
791+
if volHandle == "" {
792+
return pvclaim, persistentvolumes, fmt.Errorf("volume handle is empty")
795793
}
796-
if len(queryResult.Volumes) == 0 || queryResult.Volumes[0].VolumeId.Id != volHandle {
797-
return pvclaim, persistentvolumes, fmt.Errorf("CNS query returned unexpected result")
794+
795+
// Verify the volume in CNS if required
796+
if verifyCNSVolume {
797+
ginkgo.By(fmt.Sprintf("Invoking QueryCNSVolumeWithResult with VolumeID: %s", volHandle))
798+
queryResult, err := e2eVSphere.queryCNSVolumeWithResult(volHandle)
799+
if err != nil {
800+
return pvclaim, persistentvolumes, fmt.Errorf("failed to query CNS volume: %w", err)
801+
}
802+
if len(queryResult.Volumes) == 0 || queryResult.Volumes[0].VolumeId.Id != volHandle {
803+
return pvclaim, persistentvolumes, fmt.Errorf("CNS query returned unexpected result")
804+
}
798805
}
806+
return pvclaim, persistentvolumes, nil
799807
}
800808

801-
return pvclaim, persistentvolumes, nil
809+
return pvclaim, nil, nil
802810
}
803811

804812
// waitForVolumeSnapshotContentReadyToUse waits for the volume's snapshot content to be in ReadyToUse

tests/e2e/e2e_common.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ var (
364364
multipleSvc bool
365365
multivc bool
366366
stretchedSVC bool
367+
latebinding bool
367368
)
368369

369370
// For busybox pod image
@@ -635,6 +636,12 @@ func setClusterFlavor(clusterFlavor cnstypes.CnsClusterFlavor) {
635636
if strings.TrimSpace(string(testbedType)) == "1" {
636637
stretchedSVC = true
637638
}
639+
640+
//Check if policy given is latebinding
641+
bindingModeType := os.Getenv("BINDING_MODE_TYPE")
642+
if strings.TrimSpace(string(bindingModeType)) == "WFFC" {
643+
latebinding = true
644+
}
638645
}
639646

640647
var (

0 commit comments

Comments
 (0)