Skip to content

Commit ae0d21a

Browse files
committed
sanity: test FAILED_PRECONDITION on NodePublishVolume
According to the CSI spec, a `NodePublishVolume` RPC must return a `FAILED_PRECONDITION` error when invoked with no `staging_target_path` set, if `STAGE_UNSTAGE_VOLUME` is supported by the driver. This patch adds a test to assert this. See: https://github.com/container-storage-interface/spec/blob/87a27a2496565857ed564284eaa762587feb9453/spec.md#nodepublishvolume-errors
1 parent 08cdd2e commit ae0d21a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pkg/sanity/node.go

+15
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,21 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {
392392
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
393393
})
394394

395+
It("should fail when no staging target path is provided", func() {
396+
if !nodeStageSupported {
397+
Skip("STAGE_UNSTAGE_VOLUME not supported")
398+
}
399+
400+
req.StagingTargetPath = ""
401+
402+
_, err := c.NodePublishVolume(context.Background(), req)
403+
Expect(err).To(HaveOccurred())
404+
405+
serverError, ok := status.FromError(err)
406+
Expect(ok).To(BeTrue())
407+
Expect(serverError.Code()).To(Equal(codes.FailedPrecondition))
408+
})
409+
395410
It("should fail when no volume capability is provided", func() {
396411
req.VolumeCapability = nil
397412

0 commit comments

Comments
 (0)