Skip to content

Commit 8e223cb

Browse files
committed
sanity: allow Volume capacity_bytes to be zero
From the CSI spec: > The capacity of the volume in bytes. This field is OPTIONAL. If not > set (value of 0), it indicates that the capacity of the volume is > unknown (e.g., NFS share). > The value of this field MUST NOT be negative. As such, the tests that validate the result of a `CreateVolume` operation shall accept zero as the `capacity_bytes` of the returned `Volume` object, when validating this value against the requested capacity. See: #94 See: https://github.com/container-storage-interface/spec/blob/e129a75169c13bade7c7336afe21f259740ba679/spec.md#createvolume
1 parent b91f254 commit 8e223cb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pkg/sanity/controller.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo
482482
Expect(vol.GetVolume()).NotTo(BeNil())
483483
Expect(vol.GetVolume().GetVolumeId()).NotTo(BeEmpty())
484484
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId()})
485-
Expect(vol.GetVolume().GetCapacityBytes()).To(BeNumerically(">=", TestVolumeSize(sc)))
485+
Expect(vol.GetVolume().GetCapacityBytes()).To(Or(BeNumerically(">=", TestVolumeSize(sc)), BeZero()))
486486

487487
By("cleaning up deleting the volume")
488488

@@ -521,7 +521,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo
521521
Expect(vol1.GetVolume()).NotTo(BeNil())
522522
Expect(vol1.GetVolume().GetVolumeId()).NotTo(BeEmpty())
523523
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol1.GetVolume().GetVolumeId()})
524-
Expect(vol1.GetVolume().GetCapacityBytes()).To(BeNumerically(">=", size))
524+
Expect(vol1.GetVolume().GetCapacityBytes()).To(Or(BeNumerically(">=", size), BeZero()))
525525

526526
vol2, err := c.CreateVolume(
527527
context.Background(),
@@ -541,7 +541,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo
541541
Expect(vol2).NotTo(BeNil())
542542
Expect(vol2.GetVolume()).NotTo(BeNil())
543543
Expect(vol2.GetVolume().GetVolumeId()).NotTo(BeEmpty())
544-
Expect(vol2.GetVolume().GetCapacityBytes()).To(BeNumerically(">=", size))
544+
Expect(vol2.GetVolume().GetCapacityBytes()).To(Or(BeNumerically(">=", size), BeZero()))
545545
Expect(vol1.GetVolume().GetVolumeId()).To(Equal(vol2.GetVolume().GetVolumeId()))
546546

547547
By("cleaning up deleting the volume")
@@ -646,7 +646,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo
646646
Expect(vol.GetVolume()).NotTo(BeNil())
647647
Expect(vol.GetVolume().GetVolumeId()).NotTo(BeEmpty())
648648
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId()})
649-
Expect(vol.GetVolume().GetCapacityBytes()).To(BeNumerically(">=", size))
649+
Expect(vol.GetVolume().GetCapacityBytes()).To(Or(BeNumerically(">=", size), BeZero()))
650650

651651
By("cleaning up deleting the volume")
652652

0 commit comments

Comments
 (0)