feat: add step field and clarify comment for volume expansion

This commit is contained in:
Rishita Golla 2025-10-21 21:24:45 +00:00
parent 81affffa1b
commit 448584e1c8
2 changed files with 16 additions and 6 deletions

View file

@ -90,8 +90,8 @@ const (
PodCleanupTimeout = 20 * time.Second
)
// SizeRange encapsulates a range of sizes specified as minimum and maximum quantity strings
// Both values are optional.
// SizeRange encapsulates a range of sizes specified as minimum, maximum, and step size quantity strings
// All values are optional.
// If size is not set, it will assume there's not limitation and it may set a very small size (E.g. 1ki)
// as Min and set a considerable big size(E.g. 10Ei) as Max, which make it possible to calculate
// the intersection of given intervals (if it exists)
@ -104,6 +104,10 @@ type SizeRange struct {
// If the Min size is unset, It will be assign a default valid minimum size 1Ki,
// which is defined in test/e2e/storage/testsuites/base.go
Min string
// Step quantity specified as a string including units. E.g "1Gi".
// This represents the increment by which the volume size can be expanded.
// If the Step size is unset, it will not be assigned a default value.
Step string
}
// TestConfig is a struct for configuration of one tests. The test consist of:

View file

@ -117,6 +117,12 @@ func (v *volumeExpandTestSuite) DefineTests(driver storageframework.TestDriver,
f := framework.NewFrameworkWithCustomTimeouts("volume-expand", storageframework.GetDriverTimeouts(driver))
f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
driverSizeRange := driver.GetDriverInfo().SupportedSizeRange
expandSize := resource.MustParse("1Gi")
if driverSizeRange.Step != "" {
expandSize = resource.MustParse(driverSizeRange.Step)
}
init := func(ctx context.Context) {
l = local{}
@ -182,7 +188,7 @@ func (v *volumeExpandTestSuite) DefineTests(driver storageframework.TestDriver,
ginkgo.By("Expanding non-expandable pvc")
currentPvcSize := l.resource.Pvc.Spec.Resources.Requests[v1.ResourceStorage]
newSize := currentPvcSize.DeepCopy()
newSize.Add(resource.MustParse("1Gi"))
newSize.Add(expandSize)
framework.Logf("currentPvcSize %v, newSize %v", currentPvcSize, newSize)
_, err = ExpandPVCSizeToError(ctx, l.resource.Pvc, newSize, f.ClientSet)
gomega.Expect(err).To(gomega.MatchError(apierrors.IsForbidden, "While updating non-expandable PVC"))
@ -217,7 +223,7 @@ func (v *volumeExpandTestSuite) DefineTests(driver storageframework.TestDriver,
ginkgo.By("Expanding current pvc")
currentPvcSize := l.resource.Pvc.Spec.Resources.Requests[v1.ResourceStorage]
newSize := currentPvcSize.DeepCopy()
newSize.Add(resource.MustParse("1Gi"))
newSize.Add(expandSize)
framework.Logf("currentPvcSize %v, newSize %v", currentPvcSize, newSize)
newPVC, err := ExpandPVCSize(ctx, l.resource.Pvc, newSize, f.ClientSet)
framework.ExpectNoError(err, "While updating pvc for more size")
@ -289,7 +295,7 @@ func (v *volumeExpandTestSuite) DefineTests(driver storageframework.TestDriver,
ginkgo.By("Expanding current pvc")
currentPvcSize := l.resource.Pvc.Spec.Resources.Requests[v1.ResourceStorage]
newSize := currentPvcSize.DeepCopy()
newSize.Add(resource.MustParse("1Gi"))
newSize.Add(expandSize)
framework.Logf("currentPvcSize %v, newSize %v", currentPvcSize, newSize)
newPVC, err := ExpandPVCSize(ctx, l.resource.Pvc, newSize, f.ClientSet)
framework.ExpectNoError(err, "While updating pvc for more size")
@ -341,7 +347,7 @@ func (v *volumeExpandTestSuite) DefineTests(driver storageframework.TestDriver,
ginkgo.By("Expanding current pvc")
currentPvcSize := l.resource.Pvc.Spec.Resources.Requests[v1.ResourceStorage]
newSize := currentPvcSize.DeepCopy()
newSize.Add(resource.MustParse("1Gi"))
newSize.Add(expandSize)
framework.Logf("currentPvcSize %v, newSize %v", currentPvcSize, newSize)
newPVC, err := ExpandPVCSize(ctx, l.resource.Pvc, newSize, f.ClientSet)
framework.ExpectNoError(err, "While updating pvc for more size")