Skip to content

Commit 71f0fc6

Browse files
authored
Merge pull request kubernetes#131593 from gnufied/check-for-recovery-related-fields
Check for newer resizing related fields after expansion is successful
2 parents 3f80863 + 36685c6 commit 71f0fc6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/e2e/storage/testsuites/volume_expand.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ func (v *volumeExpandTestSuite) DefineTests(driver storageframework.TestDriver,
256256

257257
pvcConditions := l.resource.Pvc.Status.Conditions
258258
gomega.Expect(pvcConditions).To(gomega.BeEmpty(), "pvc should not have conditions")
259+
err = VerifyRecoveryRelatedFields(l.resource.Pvc)
260+
framework.ExpectNoError(err, "while verifying recovery related fields")
259261
})
260262

261263
ginkgo.It("should resize volume when PVC is edited while pod is using it", func(ctx context.Context) {
@@ -305,6 +307,9 @@ func (v *volumeExpandTestSuite) DefineTests(driver storageframework.TestDriver,
305307

306308
pvcConditions := l.resource.Pvc.Status.Conditions
307309
gomega.Expect(pvcConditions).To(gomega.BeEmpty(), "pvc should not have conditions")
310+
311+
err = VerifyRecoveryRelatedFields(l.resource.Pvc)
312+
framework.ExpectNoError(err, "while verifying recovery related fields")
308313
})
309314

310315
}
@@ -483,3 +488,18 @@ func WaitForFSResize(ctx context.Context, pvc *v1.PersistentVolumeClaim, c clien
483488
}
484489
return updatedPVC, nil
485490
}
491+
492+
func VerifyRecoveryRelatedFields(pvc *v1.PersistentVolumeClaim) error {
493+
resizeStatus := pvc.Status.AllocatedResourceStatuses[v1.ResourceStorage]
494+
if resizeStatus != "" {
495+
return fmt.Errorf("pvc %q had %s resize status, expected none", pvc.Name, resizeStatus)
496+
}
497+
498+
allocatedSize := pvc.Status.AllocatedResources[v1.ResourceStorage]
499+
requestedSize := pvc.Spec.Resources.Requests[v1.ResourceStorage]
500+
// at this point allocatedSize should be greater than pvc resource request
501+
if allocatedSize.Cmp(requestedSize) < 0 {
502+
return fmt.Errorf("pvc %q had %s allocated size, expected %s", pvc.Name, allocatedSize.String(), requestedSize.String())
503+
}
504+
return nil
505+
}

0 commit comments

Comments
 (0)