From 8e223cb4dd2f6e55a60123769da7ef33fa87a019 Mon Sep 17 00:00:00 2001 From: Nicolas Trangez Date: Tue, 28 Apr 2020 16:24:53 +0000 Subject: [PATCH] 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: https://github.com/kubernetes-csi/csi-test/issues/94 See: https://github.com/container-storage-interface/spec/blob/e129a75169c13bade7c7336afe21f259740ba679/spec.md#createvolume --- pkg/sanity/controller.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/sanity/controller.go b/pkg/sanity/controller.go index 8fb208b7..65ff0104 100644 --- a/pkg/sanity/controller.go +++ b/pkg/sanity/controller.go @@ -482,7 +482,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo Expect(vol.GetVolume()).NotTo(BeNil()) Expect(vol.GetVolume().GetVolumeId()).NotTo(BeEmpty()) cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId()}) - Expect(vol.GetVolume().GetCapacityBytes()).To(BeNumerically(">=", TestVolumeSize(sc))) + Expect(vol.GetVolume().GetCapacityBytes()).To(Or(BeNumerically(">=", TestVolumeSize(sc)), BeZero())) By("cleaning up deleting the volume") @@ -521,7 +521,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo Expect(vol1.GetVolume()).NotTo(BeNil()) Expect(vol1.GetVolume().GetVolumeId()).NotTo(BeEmpty()) cl.RegisterVolume(name, VolumeInfo{VolumeID: vol1.GetVolume().GetVolumeId()}) - Expect(vol1.GetVolume().GetCapacityBytes()).To(BeNumerically(">=", size)) + Expect(vol1.GetVolume().GetCapacityBytes()).To(Or(BeNumerically(">=", size), BeZero())) vol2, err := c.CreateVolume( context.Background(), @@ -541,7 +541,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo Expect(vol2).NotTo(BeNil()) Expect(vol2.GetVolume()).NotTo(BeNil()) Expect(vol2.GetVolume().GetVolumeId()).NotTo(BeEmpty()) - Expect(vol2.GetVolume().GetCapacityBytes()).To(BeNumerically(">=", size)) + Expect(vol2.GetVolume().GetCapacityBytes()).To(Or(BeNumerically(">=", size), BeZero())) Expect(vol1.GetVolume().GetVolumeId()).To(Equal(vol2.GetVolume().GetVolumeId())) By("cleaning up deleting the volume") @@ -646,7 +646,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo Expect(vol.GetVolume()).NotTo(BeNil()) Expect(vol.GetVolume().GetVolumeId()).NotTo(BeEmpty()) cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId()}) - Expect(vol.GetVolume().GetCapacityBytes()).To(BeNumerically(">=", size)) + Expect(vol.GetVolume().GetCapacityBytes()).To(Or(BeNumerically(">=", size), BeZero())) By("cleaning up deleting the volume")