1
1
/*
2
- Copyright 2019 The OpenEBS Authors
2
+ Copyright 2021 The OpenEBS Authors
3
3
4
4
Licensed under the Apache License, Version 2.0 (the "License");
5
5
you may not use this file except in compliance with the License.
@@ -50,11 +50,16 @@ func IsPVCBoundEventually(pvcName string) bool {
50
50
}
51
51
52
52
// IsPVCResizedEventually checks if the pvc is bound or not eventually
53
- func IsPVCResizedEventually (pvcName string , newCapacity string ) bool {
53
+ func IsPVCResizedEventually (pvcName string , newCapacity string , shouldPass bool ) bool {
54
54
newStorage , err := resource .ParseQuantity (newCapacity )
55
55
if err != nil {
56
56
return false
57
57
}
58
+ status := gomega .BeFalse ()
59
+ if shouldPass {
60
+ status = gomega .BeTrue ()
61
+ }
62
+
58
63
return gomega .Eventually (func () bool {
59
64
volume , err := PVCClient .
60
65
Get (pvcName , metav1.GetOptions {})
@@ -63,7 +68,7 @@ func IsPVCResizedEventually(pvcName string, newCapacity string) bool {
63
68
return pvcStorage == newStorage
64
69
},
65
70
120 , 5 ).
66
- Should (gomega . BeTrue () )
71
+ Should (status )
67
72
}
68
73
69
74
// IsPodRunningEventually return true if the pod comes to running state
@@ -247,15 +252,15 @@ func createAndVerifyBlockPVC() {
247
252
)
248
253
}
249
254
250
- func resizeAndVerifyPVC () {
255
+ func resizeAndVerifyPVC (shouldPass bool , size string ) {
251
256
var (
252
257
err error
253
258
pvcName = "lvmpv-pvc"
254
259
)
255
260
ginkgo .By ("updating the pvc with new size" )
256
261
pvcObj , err = PVCClient .WithNamespace (OpenEBSNamespace ).Get (pvcObj .Name , metav1.GetOptions {})
257
262
pvcObj , err = pvc .BuildFrom (pvcObj ).
258
- WithCapacity (NewCapacity ).Build ()
263
+ WithCapacity (size ).Build ()
259
264
gomega .Expect (err ).To (
260
265
gomega .BeNil (),
261
266
"while building pvc {%s} in namespace {%s}" ,
@@ -272,9 +277,7 @@ func resizeAndVerifyPVC() {
272
277
273
278
ginkgo .By ("verifying pvc size to be updated" )
274
279
275
- status := IsPVCResizedEventually (pvcName , NewCapacity )
276
- gomega .Expect (status ).To (gomega .Equal (true ),
277
- "while checking pvc resize" )
280
+ IsPVCResizedEventually (pvcName , size , shouldPass )
278
281
279
282
pvcObj , err = PVCClient .WithNamespace (OpenEBSNamespace ).Get (pvcObj .Name , metav1.GetOptions {})
280
283
gomega .Expect (err ).To (
0 commit comments