Skip to content

Commit a5f3d6f

Browse files
committed
Test use of CapacityRange limit instead of required
The CSI spec says the user can request a maximum rather than minimum volume size. Test that this is honored. Signed-off-by: Eric Blake <[email protected]>
1 parent 70e0e18 commit a5f3d6f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

pkg/sanity/controller.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,36 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo
446446
Expect(vol.GetVolume().GetCapacityBytes()).To(Or(BeNumerically(">=", TestVolumeSize(sc)), BeZero()))
447447
})
448448

449+
It("should return appropriate values SingleNodeWriter WithCapacity Limit", func() {
450+
451+
By("creating a volume")
452+
name := UniqueString("sanity-controller-create-single-with-capacity-limit")
453+
454+
vol, err := r.CreateVolume(
455+
context.Background(),
456+
&csi.CreateVolumeRequest{
457+
Name: name,
458+
VolumeCapabilities: []*csi.VolumeCapability{
459+
TestVolumeCapabilityWithAccessType(sc, csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER),
460+
},
461+
CapacityRange: &csi.CapacityRange{
462+
LimitBytes: TestVolumeSize(sc),
463+
},
464+
Secrets: sc.Secrets.CreateVolumeSecret,
465+
Parameters: sc.Config.TestVolumeParameters,
466+
},
467+
)
468+
if serverError, ok := status.FromError(err); ok &&
469+
(serverError.Code() == codes.OutOfRange || serverError.Code() == codes.Unimplemented) {
470+
Skip("Required bytes not supported")
471+
}
472+
Expect(err).NotTo(HaveOccurred())
473+
Expect(vol).NotTo(BeNil())
474+
Expect(vol.GetVolume()).NotTo(BeNil())
475+
Expect(vol.GetVolume().GetVolumeId()).NotTo(BeEmpty())
476+
Expect(vol.GetVolume().GetCapacityBytes()).To(BeNumerically("<=", TestVolumeSize(sc)))
477+
})
478+
449479
It("should not fail when requesting to create a volume with already existing name and same capacity", func() {
450480

451481
By("creating a volume")

0 commit comments

Comments
 (0)