@@ -55,6 +55,7 @@ func backupTestSuite() {
55
55
Describe ("setup environment" , test .setupEnv )
56
56
Describe ("test case 1" , test .testCase1 )
57
57
Describe ("test case 2" , test .testCase2 )
58
+ Describe ("make sure resizing PV(C)s is not supported" , test .testResizingNotSupported )
58
59
Describe ("teardown environment" , test .teardownEnv )
59
60
}
60
61
@@ -364,3 +365,66 @@ func (test *backupTest) testCase2() {
364
365
}).Should (Succeed ())
365
366
})
366
367
}
368
+
369
+ func (test * backupTest ) testResizingNotSupported () {
370
+ var err error
371
+
372
+ waitMantleBackupReadyToUse := func (ctx SpecContext , namespace , name string ) {
373
+ GinkgoHelper ()
374
+ Eventually (ctx , func (g Gomega ) {
375
+ ready , err := isMantleBackupReady (namespace , name )
376
+ g .Expect (err ).NotTo (HaveOccurred ())
377
+ g .Expect (ready ).To (BeTrue ())
378
+ }).Should (Succeed ())
379
+ }
380
+
381
+ It ("should not perform an incremental backup for a PV(C) resized after a previous backup" , func (ctx SpecContext ) {
382
+ namespace := util .GetUniqueName ("ns-" )
383
+ pvcName1 := util .GetUniqueName ("pvc-" )
384
+ mantleBackupName1 := util .GetUniqueName ("mb-" )
385
+ mantleBackupName2 := util .GetUniqueName ("mb-" )
386
+
387
+ By ("setting up the environment" )
388
+ err = createNamespace (namespace )
389
+ Expect (err ).NotTo (HaveOccurred ())
390
+
391
+ By ("creating PVC" )
392
+ err = applyPVCTemplate (namespace , pvcName1 , test .storageClassName )
393
+ Expect (err ).NotTo (HaveOccurred ())
394
+
395
+ By ("creating MantleBackup1 for a PVC1" )
396
+ err = applyMantleBackupTemplate (namespace , pvcName1 , mantleBackupName1 )
397
+ Expect (err ).NotTo (HaveOccurred ())
398
+ waitMantleBackupReadyToUse (ctx , namespace , mantleBackupName1 )
399
+
400
+ By ("resizing PVC1" )
401
+ _ , _ , err = kubectl ("patch" , "-n" , namespace , "pvc" , pvcName1 ,
402
+ "--type=json" , `-p=[{"op": "replace", "path": "/spec/resources/requests/storage", "value":"2Gi"}]` )
403
+ Expect (err ).NotTo (HaveOccurred ())
404
+
405
+ By ("making sure PVC1 is resized" )
406
+ Eventually (ctx , func (g Gomega ) {
407
+ pvName , err := getPVFromPVC (namespace , pvcName1 )
408
+ g .Expect (err ).NotTo (HaveOccurred ())
409
+ stdout , _ , err := kubectl ("get" , "pv" , pvName , "-o" , "json" )
410
+ g .Expect (err ).NotTo (HaveOccurred ())
411
+ pv := corev1.PersistentVolume {}
412
+ err = json .Unmarshal (stdout , & pv )
413
+ g .Expect (err ).NotTo (HaveOccurred ())
414
+ capacity , ok := pv .Spec .Capacity .Storage ().AsInt64 ()
415
+ g .Expect (ok ).To (BeTrue ())
416
+ g .Expect (capacity ).To (Equal (int64 (2 * 1024 * 1024 * 1024 )))
417
+ }).Should (Succeed ())
418
+
419
+ By ("creating MantleBackup2 for a PVC1" )
420
+ err = applyMantleBackupTemplate (namespace , pvcName1 , mantleBackupName2 )
421
+ Expect (err ).NotTo (HaveOccurred ())
422
+
423
+ By ("confirming MantleBackup2 is not ReadyToUse==True" )
424
+ Consistently (ctx , func (g Gomega ) {
425
+ ready , err := isMantleBackupReady (namespace , mantleBackupName2 )
426
+ g .Expect (err ).NotTo (HaveOccurred ())
427
+ g .Expect (ready ).To (BeFalse ())
428
+ }, "10s" , "1s" ).Should (Succeed ())
429
+ })
430
+ }
0 commit comments