Skip to content

Commit a5b8eac

Browse files
committed
Actually test CreateVolume with no capacity
The TODO comment is valid: the CSI spec says capacity is optional, but that behavior when omitting it is up to the implementation. However, the code for "NoCapacity" was testing the same thing as "WithCapacity 1Gi" (the default csi-sanity size if the user didn't specify differently), rather than matching the stated test of no capacity. Allow for failures that depend on the implementation (we may need to widen the list of allowable failures in the future). Signed-off-by: Eric Blake <[email protected]>
1 parent a5f3d6f commit a5b8eac

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

pkg/sanity/controller.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,26 +394,35 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo
394394
ExpectErrorCode(rsp, err, codes.InvalidArgument)
395395
})
396396

397-
// TODO: whether CreateVolume request with no capacity should fail or not depends on driver implementation
397+
// whether CreateVolume request with no capacity should fail or not depends on driver implementation
398398
It("should return appropriate values SingleNodeWriter NoCapacity", func() {
399399

400400
By("creating a volume")
401401
name := UniqueString("sanity-controller-create-single-no-capacity")
402402

403-
r.MustCreateVolume(
403+
vol, err := r.CreateVolume(
404404
context.Background(),
405405
&csi.CreateVolumeRequest{
406406
Name: name,
407407
VolumeCapabilities: []*csi.VolumeCapability{
408408
TestVolumeCapabilityWithAccessType(sc, csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER),
409409
},
410-
CapacityRange: &csi.CapacityRange{
411-
RequiredBytes: TestVolumeSize(sc),
412-
},
413410
Secrets: sc.Secrets.CreateVolumeSecret,
414411
Parameters: sc.Config.TestVolumeParameters,
415412
},
416413
)
414+
if err != nil {
415+
serverError, ok := status.FromError(err)
416+
Expect(ok).To(BeTrue())
417+
Expect(vol).To(BeNil())
418+
Expect(serverError.Code() == codes.InvalidArgument || serverError.Code() == codes.Unimplemented)
419+
} else {
420+
Expect(err).NotTo(HaveOccurred())
421+
Expect(vol).NotTo(BeNil())
422+
Expect(vol.GetVolume()).NotTo(BeNil())
423+
Expect(vol.GetVolume().GetVolumeId()).NotTo(BeEmpty())
424+
Expect(vol.GetVolume().GetCapacityBytes()).To(BeNumerically(">=", 0))
425+
}
417426
})
418427

419428
It("should return appropriate values SingleNodeWriter WithCapacity 1Gi", func() {

0 commit comments

Comments
 (0)