Skip to content

Commit a7e8665

Browse files
committed
sanity: test NOT_FOUND on Node(Un)StageVolume
According to the CSI spec, a plugin must return a `NOT_FOUND` error when `NodeStageVolume` or `NodeUnstageVolume` is called with a `volume_id` of a volume that does not (or no longer?) exist. The `sanity` package has tests asserting these `NOT_FOUND` reports for various RPC calls, including `NodePublishVolume` and `NodeUnpublishVolume`, but not for `NodeStageVolume` and `NodeUnstageVolume`. This patch adds them for completeness. See: https://github.com/container-storage-interface/spec/blob/87a27a2496565857ed564284eaa762587feb9453/spec.md#nodestagevolume-errors See: https://github.com/container-storage-interface/spec/blob/87a27a2496565857ed564284eaa762587feb9453/spec.md#nodeunstagevolume-errors
1 parent 99b7db9 commit a7e8665

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

pkg/sanity/node.go

+33
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,25 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {
487487
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
488488
})
489489

490+
It("should fail when the volume is missing", func() {
491+
_, err := c.NodeStageVolume(
492+
context.Background(),
493+
&csi.NodeStageVolumeRequest{
494+
VolumeId: sc.Config.IDGen.GenerateUniqueValidVolumeID(),
495+
VolumeCapability: TestVolumeCapabilityWithAccessType(sc, csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER),
496+
PublishContext: map[string]string{
497+
"device": device,
498+
},
499+
StagingTargetPath: sc.StagingPath,
500+
})
501+
Expect(err).To(HaveOccurred())
502+
503+
serverError, ok := status.FromError(err)
504+
Expect(ok).To(BeTrue())
505+
Expect(serverError.Code()).To(Equal(codes.NotFound))
506+
507+
})
508+
490509
It("should fail when no volume capability is provided", func() {
491510

492511
// Create Volume First
@@ -582,6 +601,20 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {
582601
Expect(ok).To(BeTrue())
583602
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
584603
})
604+
605+
It("should fail when the volume is missing", func() {
606+
_, err := c.NodeUnstageVolume(
607+
context.Background(),
608+
&csi.NodeUnstageVolumeRequest{
609+
VolumeId: sc.Config.IDGen.GenerateUniqueValidVolumeID(),
610+
StagingTargetPath: sc.StagingPath,
611+
})
612+
Expect(err).To(HaveOccurred())
613+
614+
serverError, ok := status.FromError(err)
615+
Expect(ok).To(BeTrue())
616+
Expect(serverError.Code()).To(Equal(codes.NotFound))
617+
})
585618
})
586619

587620
Describe("NodeGetVolumeStats", func() {

0 commit comments

Comments
 (0)