Skip to content

Commit 08c1c23

Browse files
committed
new changes
1 parent 3b89d73 commit 08c1c23

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

tests/e2e/vmservice_utils.go

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,25 +1130,29 @@ func deleteVMServiceVmInParallel(ctx context.Context, c ctlrclient.Client,
11301130
func performVolumeLifecycleActionForVmServiceVM(ctx context.Context, client clientset.Interface,
11311131
vmopC ctlrclient.Client, cnsopC ctlrclient.Client, vmClass string, namespace string, vmi string,
11321132
sc *storagev1.StorageClass, secretName string) {
1133+
var volHandle string
11331134
ginkgo.By("Create a PVC")
11341135
pvc, err := createPVC(ctx, client, namespace, nil, "", sc, "")
11351136
gomega.Expect(err).NotTo(gomega.HaveOccurred())
1136-
ginkgo.By("Waiting for all claims to be in bound state")
1137-
pvs, err := fpv.WaitForPVClaimBoundPhase(ctx, client, []*v1.PersistentVolumeClaim{pvc}, pollTimeout)
1138-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
1139-
pv := pvs[0]
1140-
volHandle := pv.Spec.CSI.VolumeHandle
1141-
gomega.Expect(volHandle).NotTo(gomega.BeEmpty())
1142-
defer func() {
1143-
ginkgo.By("Delete PVCs")
1144-
err = fpv.DeletePersistentVolumeClaim(ctx, client, pvc.Name, namespace)
1137+
if !latebinding {
1138+
ginkgo.By("Waiting for all claims to be in bound state")
1139+
pvs, err := fpv.WaitForPVClaimBoundPhase(ctx, client, []*v1.PersistentVolumeClaim{pvc}, pollTimeout)
11451140
gomega.Expect(err).NotTo(gomega.HaveOccurred())
1141+
pv := pvs[0]
1142+
volHandle = pv.Spec.CSI.VolumeHandle
1143+
gomega.Expect(volHandle).NotTo(gomega.BeEmpty())
1144+
defer func() {
1145+
ginkgo.By("Delete PVCs")
1146+
err = fpv.DeletePersistentVolumeClaim(ctx, client, pvc.Name, namespace)
1147+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
11461148

1147-
ginkgo.By("Waiting for CNS volumes to be deleted")
1148-
err = e2eVSphere.waitForCNSVolumeToBeDeleted(volHandle)
1149-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
1149+
ginkgo.By("Waiting for CNS volumes to be deleted")
1150+
err = e2eVSphere.waitForCNSVolumeToBeDeleted(volHandle)
1151+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
11501152

1151-
}()
1153+
}()
1154+
1155+
}
11521156

11531157
ginkgo.By("Creating VM")
11541158
vm := createVmServiceVmWithPvcs(
@@ -1173,6 +1177,15 @@ func performVolumeLifecycleActionForVmServiceVM(ctx context.Context, client clie
11731177
gomega.Expect(err).NotTo(gomega.HaveOccurred())
11741178
}()
11751179

1180+
if latebinding {
1181+
ginkgo.By("Waiting for all claims to be in bound state")
1182+
pvs, err := fpv.WaitForPVClaimBoundPhase(ctx, client, []*v1.PersistentVolumeClaim{pvc}, pollTimeout)
1183+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
1184+
pv := pvs[0]
1185+
volHandle = pv.Spec.CSI.VolumeHandle
1186+
gomega.Expect(volHandle).NotTo(gomega.BeEmpty())
1187+
1188+
}
11761189
ginkgo.By("Wait and verify PVCs are attached to the VM")
11771190
gomega.Expect(waitNverifyPvcsAreAttachedToVmsvcVm(ctx, vmopC, cnsopC, vm,
11781191
[]*v1.PersistentVolumeClaim{pvc})).NotTo(gomega.HaveOccurred())

0 commit comments

Comments
 (0)