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
74 changes: 41 additions & 33 deletions tests/e2e/csi_snapshot_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func deleteVolumeSnapshot(ctx context.Context, snapc *snapclient.Clientset, name
}
snapshotContentCreated := false

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

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

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

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

persistentvolumes2, err := fpv.WaitForPVClaimBoundPhase(ctx, client,
[]*v1.PersistentVolumeClaim{pvclaim2}, framework.ClaimProvisionTimeout)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
volHandle2 := persistentvolumes2[0].Spec.CSI.VolumeHandle
if guestCluster {
volHandle2 = getVolumeIDFromSupervisorCluster(volHandle2)
if !latebinding {
ginkgo.By("Verify PVC bound state created with Immediate binding mode storage policy")
persistentvolumes2, err = fpv.WaitForPVClaimBoundPhase(ctx, client,
[]*v1.PersistentVolumeClaim{pvclaim2}, framework.ClaimProvisionTimeout)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
volHandle2 = persistentvolumes2[0].Spec.CSI.VolumeHandle
if guestCluster {
volHandle2 = getVolumeIDFromSupervisorCluster(volHandle2)
}
gomega.Expect(volHandle2).NotTo(gomega.BeEmpty())
}
gomega.Expect(volHandle2).NotTo(gomega.BeEmpty())

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

// Wait for PVC to be bound to a PV
persistentvolumes, err := fpv.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)
}

// Get VolumeHandle from the PV
volHandle := persistentvolumes[0].Spec.CSI.VolumeHandle
if guestCluster {
volHandle = getVolumeIDFromSupervisorCluster(volHandle)
}
if volHandle == "" {
return pvclaim, persistentvolumes, fmt.Errorf("volume handle is empty")
}

// Verify the volume in CNS if required
if verifyCNSVolume {
ginkgo.By(fmt.Sprintf("Invoking QueryCNSVolumeWithResult with VolumeID: %s", volHandle))
queryResult, err := e2eVSphere.queryCNSVolumeWithResult(volHandle)
if !latebinding {
ginkgo.By("Verify PVC bound state created with Immediate binding mode storage policy")
persistentvolumes, err := fpv.WaitForPVClaimBoundPhase(ctx, client,
[]*v1.PersistentVolumeClaim{pvclaim}, framework.ClaimProvisionTimeout*2)
if err != nil {
return pvclaim, persistentvolumes, fmt.Errorf("failed to query CNS volume: %w", err)
return pvclaim, persistentvolumes, fmt.Errorf("failed to wait for PVC to bind to a PV: %w", err)
}

// Get VolumeHandle from the PV
volHandle := persistentvolumes[0].Spec.CSI.VolumeHandle
if guestCluster {
volHandle = getVolumeIDFromSupervisorCluster(volHandle)
}
if volHandle == "" {
return pvclaim, persistentvolumes, fmt.Errorf("volume handle is empty")
}
if len(queryResult.Volumes) == 0 || queryResult.Volumes[0].VolumeId.Id != volHandle {
return pvclaim, persistentvolumes, fmt.Errorf("CNS query returned unexpected result")

// Verify the volume in CNS if required
if verifyCNSVolume {
ginkgo.By(fmt.Sprintf("Invoking QueryCNSVolumeWithResult with VolumeID: %s", volHandle))
queryResult, err := e2eVSphere.queryCNSVolumeWithResult(volHandle)
if err != nil {
return pvclaim, persistentvolumes, fmt.Errorf("failed to query CNS volume: %w", err)
}
if len(queryResult.Volumes) == 0 || queryResult.Volumes[0].VolumeId.Id != volHandle {
return pvclaim, persistentvolumes, fmt.Errorf("CNS query returned unexpected result")
}
}
return pvclaim, persistentvolumes, nil
}

return pvclaim, persistentvolumes, nil
return pvclaim, nil, nil
}

// waitForVolumeSnapshotContentReadyToUse waits for the volume's snapshot content to be in ReadyToUse
Expand Down
7 changes: 7 additions & 0 deletions tests/e2e/e2e_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ var (
multipleSvc bool
multivc bool
stretchedSVC bool
latebinding bool
)

// For busybox pod image
Expand Down Expand Up @@ -635,6 +636,12 @@ func setClusterFlavor(clusterFlavor cnstypes.CnsClusterFlavor) {
if strings.TrimSpace(string(testbedType)) == "1" {
stretchedSVC = true
}

//Check if policy given is latebinding
bindingModeType := os.Getenv("BINDING_MODE_TYPE")
if strings.TrimSpace(string(bindingModeType)) == "WFFC" {
latebinding = true
}
}

var (
Expand Down
Loading