@@ -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,57 @@ 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
+ nodePublishRequest := & csi.NodePublishVolumeRequest {
465
+ VolumeId : vol .GetVolume ().GetVolumeId (),
466
+ TargetPath : sc .TargetPath + "/other_target" ,
467
+ VolumeCapability : cap ,
468
+ VolumeContext : vol .GetVolume ().GetVolumeContext (),
469
+ Secrets : sc .Secrets .NodePublishVolumeSecret ,
470
+ }
471
+ if conpubvol != nil {
472
+ nodePublishRequest .PublishContext = conpubvol .GetPublishContext ()
473
+ }
474
+ if nodeStageSupported {
475
+ nodePublishRequest .StagingTargetPath = sc .StagingPath
476
+ }
477
+
478
+ _ , err = r .NodePublishVolume (
479
+ context .Background (),
480
+ nodePublishRequest )
481
+ Expect (err ).To (HaveOccurred ())
482
+
483
+ serverError , ok := status .FromError (err )
484
+ Expect (ok ).To (BeTrue ())
485
+ Expect (serverError .Code ()).To (Equal (codes .FailedPrecondition ), "unexpected error: %s" , serverError .Message ())
486
+ })
487
+ })
434
488
})
435
489
436
490
Describe ("NodeUnpublishVolume" , func () {
0 commit comments