@@ -183,12 +183,13 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {
183
183
var (
184
184
r *Resources
185
185
186
- providesControllerService bool
187
- controllerPublishSupported bool
188
- nodeStageSupported bool
189
- nodeVolumeStatsSupported bool
190
- nodeExpansionSupported bool
191
- controllerExpansionSupported bool
186
+ providesControllerService bool
187
+ controllerPublishSupported bool
188
+ nodeStageSupported bool
189
+ nodeVolumeStatsSupported bool
190
+ nodeExpansionSupported bool
191
+ controllerExpansionSupported bool
192
+ singleNodeMultiWriterSupported bool
192
193
)
193
194
194
195
createVolumeWithCapability := func(volumeName string, cap *csi.VolumeCapability) *csi.CreateVolumeResponse {
@@ -319,6 +320,8 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {
319
320
nodeVolumeStatsSupported = isNodeCapabilitySupported(n, csi.NodeServiceCapability_RPC_GET_VOLUME_STATS)
320
321
nodeExpansionSupported = isNodeCapabilitySupported(n, csi.NodeServiceCapability_RPC_EXPAND_VOLUME)
321
322
controllerExpansionSupported = isControllerCapabilitySupported(cl, csi.ControllerServiceCapability_RPC_EXPAND_VOLUME)
323
+ singleNodeMultiWriterSupported = isNodeCapabilitySupported(n, csi.NodeServiceCapability_RPC_SINGLE_NODE_MULTI_WRITER)
324
+
322
325
r = &Resources{
323
326
Context: sc,
324
327
ControllerClient: cl,
@@ -431,6 +434,55 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {
431
434
Expect(ok).To(BeTrue())
432
435
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
433
436
})
437
+
438
+ Describe("with single node multi writer capability", func() {
439
+ BeforeEach(func() {
440
+ if !singleNodeMultiWriterSupported {
441
+ Skip("Service does not have single node multi writer capability")
442
+ }
443
+ })
444
+
445
+ It("should fail when volume with single node single writer access mode is already mounted at a different target path", func() {
446
+ By("creating a single node single writer volume")
447
+ name := UniqueString("sanity-node-publish-single-node-single-writer")
448
+ cap := TestVolumeCapabilityWithAccessType(sc, csi.VolumeCapability_AccessMode_SINGLE_NODE_SINGLE_WRITER)
449
+ vol := createVolumeWithCapability(name, cap)
450
+
451
+ By("Getting a node id")
452
+ nid, err := r.NodeGetInfo(
453
+ context.Background(),
454
+ &csi.NodeGetInfoRequest{})
455
+ Expect(err).NotTo(HaveOccurred())
456
+ Expect(nid).NotTo(BeNil())
457
+ Expect(nid.GetNodeId()).NotTo(BeEmpty())
458
+
459
+ By("Staging and publishing a volume")
460
+ conpubvol := controllerPublishVolumeWithCapability(name, vol, nid, cap)
461
+ _ = nodeStageVolumeWithCapability(name, vol, conpubvol, cap)
462
+ _ = nodePublishVolumeWithCapability(name, vol, conpubvol, cap)
463
+
464
+ var stagingPath string
465
+ if nodeStageSupported {
466
+ stagingPath = sc.StagingPath
467
+ }
468
+ _, err = r.NodePublishVolume(
469
+ context.Background(),
470
+ &csi.NodePublishVolumeRequest{
471
+ VolumeId: vol.GetVolume().GetVolumeId(),
472
+ TargetPath: sc.TargetPath + "/other_target",
473
+ StagingTargetPath: stagingPath,
474
+ VolumeCapability: cap,
475
+ VolumeContext: vol.GetVolume().GetVolumeContext(),
476
+ Secrets: sc.Secrets.NodePublishVolumeSecret,
477
+ },
478
+ )
479
+ Expect(err).To(HaveOccurred())
480
+
481
+ serverError, ok := status.FromError(err)
482
+ Expect(ok).To(BeTrue())
483
+ Expect(serverError.Code()).To(Equal(codes.FailedPrecondition), "unexpected error: %s", serverError.Message())
484
+ })
485
+ })
434
486
})
435
487
436
488
Describe("NodeUnpublishVolume", func() {
0 commit comments