@@ -3152,7 +3152,7 @@ var _ bool = ginkgo.Describe("[snapshot-vmsvc] Snapshot VM Service VM", func() {
3152
3152
pvcSpec := getPersistentVolumeClaimSpecWithStorageClass (namespace , "" , storageclass , nil , "" )
3153
3153
pvcSpec .Annotations = pvcAnnotations
3154
3154
pvc , err := client .CoreV1 ().PersistentVolumeClaims (namespace ).Create (ctx , pvcSpec , metav1.CreateOptions {})
3155
- // gomega.Expect(err).NotTo (gomega.HaveOccurred())
3155
+ gomega .Expect (err ).To (gomega .HaveOccurred ())
3156
3156
3157
3157
if ! latebinding {
3158
3158
ginkgo .By ("Wait for SV PVC to come to bound state" )
@@ -3273,11 +3273,6 @@ var _ bool = ginkgo.Describe("[snapshot-vmsvc] Snapshot VM Service VM", func() {
3273
3273
gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3274
3274
}()
3275
3275
3276
- ginkgo .By ("Verify SV PV has has required PV node affinity details" )
3277
- _ , err = verifyVolumeTopologyForLevel5 (restorepv [0 ], allowedTopologyHAMap )
3278
- gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3279
- framework .Logf ("SVC PV: %s has required PV node affinity details" , restorepv [0 ].Name )
3280
-
3281
3276
ginkgo .By ("Creating VM" )
3282
3277
vm2 := createVmServiceVmWithPvcsWithZone (ctx , vmopC , namespace , vmClass ,
3283
3278
[]* v1.PersistentVolumeClaim {restorepvc }, vmi , storageClassName , secretName , topologykey )
@@ -3305,6 +3300,21 @@ var _ bool = ginkgo.Describe("[snapshot-vmsvc] Snapshot VM Service VM", func() {
3305
3300
vmIp2 , err := waitNgetVmsvcVmIp (ctx , vmopC , namespace , vm2 .Name )
3306
3301
gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3307
3302
3303
+ if latebinding {
3304
+ ginkgo .By ("Verify PVC bound state created with latebinding mode storage policy" )
3305
+ restorepvs , err := fpv .WaitForPVClaimBoundPhase (ctx , client , []* v1.PersistentVolumeClaim {restorepvc },
3306
+ pollTimeout )
3307
+ gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3308
+ restorepv := restorepvs [0 ]
3309
+ restorevolHandle = restorepv .Spec .CSI .VolumeHandle
3310
+ gomega .Expect (restorevolHandle ).NotTo (gomega .BeEmpty ())
3311
+ }
3312
+
3313
+ ginkgo .By ("Verify SV PV has has required PV node affinity details" )
3314
+ _ , err = verifyVolumeTopologyForLevel5 (restorepv [0 ], allowedTopologyHAMap )
3315
+ gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3316
+ framework .Logf ("SVC PV: %s has required PV node affinity details" , restorepv [0 ].Name )
3317
+
3308
3318
ginkgo .By ("Wait and verify PVCs are attached to the VM" )
3309
3319
gomega .Expect (waitNverifyPvcsAreAttachedToVmsvcVm (ctx , vmopC , cnsopC , vm2 ,
3310
3320
[]* v1.PersistentVolumeClaim {restorepvc })).NotTo (gomega .HaveOccurred ())
@@ -3370,6 +3380,10 @@ var _ bool = ginkgo.Describe("[snapshot-vmsvc] Snapshot VM Service VM", func() {
3370
3380
allowedTopologyHAMap := createAllowedTopologiesMap (allowedTopos )
3371
3381
pvcAnnotations := make (map [string ]string )
3372
3382
topoList := []string {}
3383
+ var topologykey string
3384
+ var volumeId string
3385
+ var pvs []* v1.PersistentVolume
3386
+ var restorevolHandle1 , restorevolHandle2 string
3373
3387
3374
3388
for key , val := range allowedTopologyHAMap {
3375
3389
for _ , topoVal := range val {
@@ -3382,20 +3396,22 @@ var _ bool = ginkgo.Describe("[snapshot-vmsvc] Snapshot VM Service VM", func() {
3382
3396
pvcAnnotations [tkgHARequestedAnnotationKey ] = annotationVal
3383
3397
framework .Logf ("annotationVal :%s, pvcAnnotations: %v" , annotationVal , pvcAnnotations )
3384
3398
3385
- ginkgo .By ("Creating Pvc with Immediate topology storageclass " )
3399
+ ginkgo .By ("Creating Pvc" )
3386
3400
storageclass , err := client .StorageV1 ().StorageClasses ().Get (ctx , storageClassName , metav1.GetOptions {})
3387
3401
gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3388
3402
pvcSpec := getPersistentVolumeClaimSpecWithStorageClass (namespace , "" , storageclass , nil , "" )
3389
3403
pvcSpec .Annotations = pvcAnnotations
3390
3404
pvc , err := client .CoreV1 ().PersistentVolumeClaims (namespace ).Create (ctx , pvcSpec , metav1.CreateOptions {})
3391
- gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3405
+ gomega .Expect (err ).To (gomega .HaveOccurred ())
3392
3406
3393
- ginkgo .By ("Wait for SV PVC to come to bound state" )
3394
- pvs , err := fpv .WaitForPVClaimBoundPhase (ctx , client , []* v1.PersistentVolumeClaim {pvc },
3395
- framework .ClaimProvisionTimeout )
3396
- gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3397
- topologykey := pvs [0 ].Spec .NodeAffinity .Required .NodeSelectorTerms [0 ].MatchExpressions [0 ].Values [0 ]
3398
- volumeId := pvs [0 ].Spec .CSI .VolumeHandle
3407
+ if ! latebinding {
3408
+ ginkgo .By ("Wait for SV PVC to come to bound state" )
3409
+ pvs , err = fpv .WaitForPVClaimBoundPhase (ctx , client , []* v1.PersistentVolumeClaim {pvc },
3410
+ framework .ClaimProvisionTimeout )
3411
+ gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3412
+ topologykey = pvs [0 ].Spec .NodeAffinity .Required .NodeSelectorTerms [0 ].MatchExpressions [0 ].Values [0 ]
3413
+ volumeId = pvs [0 ].Spec .CSI .VolumeHandle
3414
+ }
3399
3415
3400
3416
defer func () {
3401
3417
err := fpv .DeletePersistentVolumeClaim (ctx , client , pvc .Name , namespace )
@@ -3407,11 +3423,6 @@ var _ bool = ginkgo.Describe("[snapshot-vmsvc] Snapshot VM Service VM", func() {
3407
3423
"kubernetes" , volumeId ))
3408
3424
}()
3409
3425
3410
- ginkgo .By ("Verify SV PV has has required PV node affinity details" )
3411
- _ , err = verifyVolumeTopologyForLevel5 (pvs [0 ], allowedTopologyHAMap )
3412
- gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3413
- framework .Logf ("SVC PV: %s has required PV node affinity details" , pvs [0 ].Name )
3414
-
3415
3426
ginkgo .By ("Creating VM bootstrap data" )
3416
3427
secretName := createBootstrapSecretForVmsvcVms (ctx , client , namespace )
3417
3428
defer func () {
@@ -3447,6 +3458,20 @@ var _ bool = ginkgo.Describe("[snapshot-vmsvc] Snapshot VM Service VM", func() {
3447
3458
vmIp , err := waitNgetVmsvcVmIp (ctx , vmopC , namespace , vm .Name )
3448
3459
gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3449
3460
3461
+ if latebinding {
3462
+ ginkgo .By ("Wait for SV PVC to come to bound state" )
3463
+ pvs , err = fpv .WaitForPVClaimBoundPhase (ctx , client , []* v1.PersistentVolumeClaim {pvc },
3464
+ framework .ClaimProvisionTimeout )
3465
+ gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3466
+ topologykey = pvs [0 ].Spec .NodeAffinity .Required .NodeSelectorTerms [0 ].MatchExpressions [0 ].Values [0 ]
3467
+ volumeId = pvs [0 ].Spec .CSI .VolumeHandle
3468
+ }
3469
+
3470
+ ginkgo .By ("Verify SV PV has has required PV node affinity details" )
3471
+ _ , err = verifyVolumeTopologyForLevel5 (pvs [0 ], allowedTopologyHAMap )
3472
+ gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3473
+ framework .Logf ("SVC PV: %s has required PV node affinity details" , pvs [0 ].Name )
3474
+
3450
3475
ginkgo .By ("Wait and verify PVCs are attached to the VM" )
3451
3476
gomega .Expect (waitNverifyPvcsAreAttachedToVmsvcVm (ctx , vmopC , cnsopC , vm ,
3452
3477
[]* v1.PersistentVolumeClaim {pvc })).NotTo (gomega .HaveOccurred ())
@@ -3487,20 +3512,18 @@ var _ bool = ginkgo.Describe("[snapshot-vmsvc] Snapshot VM Service VM", func() {
3487
3512
ginkgo .By ("Restore volume from snapshot-1" )
3488
3513
restorepvc1 , restorepv1 , _ := verifyVolumeRestoreOperation (ctx , client , namespace , storageclass ,
3489
3514
volumeSnapshot1 , diskSize , false )
3490
- restorevolHandle1 := restorepv1 [0 ].Spec .CSI .VolumeHandle
3491
- gomega .Expect (restorevolHandle1 ).NotTo (gomega .BeEmpty ())
3515
+ if restorepv1 != nil && ! latebinding {
3516
+ restorevolHandle1 = restorepv1 [0 ].Spec .CSI .VolumeHandle
3517
+ gomega .Expect (restorevolHandle1 ).NotTo (gomega .BeEmpty ())
3518
+ }
3519
+
3492
3520
defer func () {
3493
3521
err := fpv .DeletePersistentVolumeClaim (ctx , client , restorepvc1 .Name , namespace )
3494
3522
gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3495
3523
err = e2eVSphere .waitForCNSVolumeToBeDeleted (restorevolHandle1 )
3496
3524
gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3497
3525
}()
3498
3526
3499
- ginkgo .By ("Verify SV PV has has required PV node affinity details" )
3500
- _ , err = verifyVolumeTopologyForLevel5 (restorepv1 [0 ], allowedTopologyHAMap )
3501
- gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3502
- framework .Logf ("SVC PV: %s has required PV node affinity details" , restorepv1 [0 ].Name )
3503
-
3504
3527
ginkgo .By ("Creating VM" )
3505
3528
vm2 := createVmServiceVmWithPvcsWithZone (ctx , vmopC , namespace , vmClass ,
3506
3529
[]* v1.PersistentVolumeClaim {restorepvc1 }, vmi , storageClassName , secretName , topologykey )
@@ -3528,6 +3551,21 @@ var _ bool = ginkgo.Describe("[snapshot-vmsvc] Snapshot VM Service VM", func() {
3528
3551
vmIp2 , err := waitNgetVmsvcVmIp (ctx , vmopC , namespace , vm2 .Name )
3529
3552
gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3530
3553
3554
+ if latebinding {
3555
+ ginkgo .By ("Verify PVC bound state created with latebinding mode storage policy" )
3556
+ restorepvs1 , err := fpv .WaitForPVClaimBoundPhase (ctx , client , []* v1.PersistentVolumeClaim {restorepvc1 },
3557
+ pollTimeout )
3558
+ gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3559
+ restorepv1 := restorepvs1 [0 ]
3560
+ restorevolHandle1 = restorepv1 .Spec .CSI .VolumeHandle
3561
+ gomega .Expect (restorevolHandle1 ).NotTo (gomega .BeEmpty ())
3562
+ }
3563
+
3564
+ ginkgo .By ("Verify SV PV has has required PV node affinity details" )
3565
+ _ , err = verifyVolumeTopologyForLevel5 (restorepv1 [0 ], allowedTopologyHAMap )
3566
+ gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3567
+ framework .Logf ("SVC PV: %s has required PV node affinity details" , restorepv1 [0 ].Name )
3568
+
3531
3569
ginkgo .By ("Wait and verify PVCs are attached to the VM" )
3532
3570
gomega .Expect (waitNverifyPvcsAreAttachedToVmsvcVm (ctx , vmopC , cnsopC , vm2 ,
3533
3571
[]* v1.PersistentVolumeClaim {restorepvc1 })).NotTo (gomega .HaveOccurred ())
@@ -3566,20 +3604,17 @@ var _ bool = ginkgo.Describe("[snapshot-vmsvc] Snapshot VM Service VM", func() {
3566
3604
ginkgo .By ("Restore volume from snapshot-2" )
3567
3605
restorepvc2 , restorepv2 , _ := verifyVolumeRestoreOperation (ctx , client , namespace , storageclass ,
3568
3606
volumeSnapshot2 , diskSize , false )
3569
- restorevolHandle2 := restorepv2 [0 ].Spec .CSI .VolumeHandle
3570
- gomega .Expect (restorevolHandle2 ).NotTo (gomega .BeEmpty ())
3607
+ if restorepv1 != nil && ! latebinding {
3608
+ restorevolHandle2 = restorepv2 [0 ].Spec .CSI .VolumeHandle
3609
+ gomega .Expect (restorevolHandle2 ).NotTo (gomega .BeEmpty ())
3610
+ }
3571
3611
defer func () {
3572
3612
err := fpv .DeletePersistentVolumeClaim (ctx , client , restorepvc2 .Name , namespace )
3573
3613
gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3574
3614
err = e2eVSphere .waitForCNSVolumeToBeDeleted (restorevolHandle2 )
3575
3615
gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3576
3616
}()
3577
3617
3578
- ginkgo .By ("Verify SV PV has has required PV node affinity details" )
3579
- _ , err = verifyVolumeTopologyForLevel5 (restorepv2 [0 ], allowedTopologyHAMap )
3580
- gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3581
- framework .Logf ("SVC PV: %s has required PV node affinity details" , restorepv2 [0 ].Name )
3582
-
3583
3618
ginkgo .By ("Creating VM" )
3584
3619
vm3 := createVmServiceVmWithPvcsWithZone (ctx , vmopC , namespace , vmClass ,
3585
3620
[]* v1.PersistentVolumeClaim {restorepvc2 }, vmi , storageClassName , secretName , topologykey )
@@ -3607,6 +3642,21 @@ var _ bool = ginkgo.Describe("[snapshot-vmsvc] Snapshot VM Service VM", func() {
3607
3642
vmIp3 , err := waitNgetVmsvcVmIp (ctx , vmopC , namespace , vm3 .Name )
3608
3643
gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3609
3644
3645
+ ginkgo .By ("Verify SV PV has has required PV node affinity details" )
3646
+ _ , err = verifyVolumeTopologyForLevel5 (restorepv2 [0 ], allowedTopologyHAMap )
3647
+ gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3648
+ framework .Logf ("SVC PV: %s has required PV node affinity details" , restorepv2 [0 ].Name )
3649
+
3650
+ if latebinding {
3651
+ ginkgo .By ("Verify PVC bound state created with latebinding mode storage policy" )
3652
+ restorepvs2 , err := fpv .WaitForPVClaimBoundPhase (ctx , client , []* v1.PersistentVolumeClaim {restorepvc2 },
3653
+ pollTimeout )
3654
+ gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3655
+ restorepv2 := restorepvs2 [0 ]
3656
+ restorevolHandle2 = restorepv2 .Spec .CSI .VolumeHandle
3657
+ gomega .Expect (restorevolHandle2 ).NotTo (gomega .BeEmpty ())
3658
+ }
3659
+
3610
3660
ginkgo .By ("Wait and verify PVCs are attached to the VM" )
3611
3661
gomega .Expect (waitNverifyPvcsAreAttachedToVmsvcVm (ctx , vmopC , cnsopC , vm3 ,
3612
3662
[]* v1.PersistentVolumeClaim {restorepvc2 })).NotTo (gomega .HaveOccurred ())
0 commit comments