@@ -364,3 +364,157 @@ func testFullWorkflowSuccess(s csi.ControllerClient, c csi.NodeClient, controlle
364
364
})
365
365
Expect (err ).NotTo (HaveOccurred ())
366
366
}
367
+
368
+ var _ = Describe ("NodeStageVolume [Node Server]" , func () {
369
+ var (
370
+ s csi.ControllerClient
371
+ c csi.NodeClient
372
+ controllerPublishSupported bool
373
+ nodeStageSupported bool
374
+ device string
375
+ )
376
+
377
+ BeforeEach (func () {
378
+ s = csi .NewControllerClient (conn )
379
+ c = csi .NewNodeClient (conn )
380
+ device = "/dev/mock"
381
+ controllerPublishSupported = isControllerCapabilitySupported (
382
+ s ,
383
+ csi .ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME )
384
+ nodeStageSupported = isNodeCapabilitySupported (c , csi .NodeServiceCapability_RPC_STAGE_UNSTAGE_VOLUME )
385
+ if nodeStageSupported {
386
+ err := createMountTargetLocation (config .StagingPath )
387
+ Expect (err ).NotTo (HaveOccurred ())
388
+ } else {
389
+ Skip ("NodeStageVolume not supported" )
390
+ }
391
+ })
392
+
393
+ It ("should fail when no volume id is provided" , func () {
394
+
395
+ _ , err := c .NodeStageVolume (
396
+ context .Background (),
397
+ & csi.NodeStageVolumeRequest {
398
+ StagingTargetPath : config .StagingPath ,
399
+ VolumeCapability : & csi.VolumeCapability {
400
+ AccessType : & csi.VolumeCapability_Mount {
401
+ Mount : & csi.VolumeCapability_MountVolume {},
402
+ },
403
+ AccessMode : & csi.VolumeCapability_AccessMode {
404
+ Mode : csi .VolumeCapability_AccessMode_SINGLE_NODE_WRITER ,
405
+ },
406
+ },
407
+ PublishInfo : map [string ]string {
408
+ "device" : device ,
409
+ },
410
+ })
411
+ Expect (err ).To (HaveOccurred ())
412
+
413
+ serverError , ok := status .FromError (err )
414
+ Expect (ok ).To (BeTrue ())
415
+ Expect (serverError .Code ()).To (Equal (codes .InvalidArgument ))
416
+ })
417
+
418
+ It ("should fail when no staging target path is provided" , func () {
419
+
420
+ _ , err := c .NodeStageVolume (
421
+ context .Background (),
422
+ & csi.NodeStageVolumeRequest {
423
+ VolumeId : "id" ,
424
+ VolumeCapability : & csi.VolumeCapability {
425
+ AccessType : & csi.VolumeCapability_Mount {
426
+ Mount : & csi.VolumeCapability_MountVolume {},
427
+ },
428
+ AccessMode : & csi.VolumeCapability_AccessMode {
429
+ Mode : csi .VolumeCapability_AccessMode_SINGLE_NODE_WRITER ,
430
+ },
431
+ },
432
+ PublishInfo : map [string ]string {
433
+ "device" : device ,
434
+ },
435
+ })
436
+ Expect (err ).To (HaveOccurred ())
437
+
438
+ serverError , ok := status .FromError (err )
439
+ Expect (ok ).To (BeTrue ())
440
+ Expect (serverError .Code ()).To (Equal (codes .InvalidArgument ))
441
+ })
442
+
443
+ It ("should fail when no volume capability is provided" , func () {
444
+
445
+ _ , err := c .NodeStageVolume (
446
+ context .Background (),
447
+ & csi.NodeStageVolumeRequest {
448
+ VolumeId : "id" ,
449
+ StagingTargetPath : config .StagingPath ,
450
+ PublishInfo : map [string ]string {
451
+ "device" : device ,
452
+ },
453
+ })
454
+ Expect (err ).To (HaveOccurred ())
455
+
456
+ serverError , ok := status .FromError (err )
457
+ Expect (ok ).To (BeTrue ())
458
+ Expect (serverError .Code ()).To (Equal (codes .InvalidArgument ))
459
+ })
460
+
461
+ It ("should return appropriate values (no optional values added)" , func () {
462
+ testFullWorkflowSuccess (s , c , controllerPublishSupported , nodeStageSupported )
463
+ })
464
+ })
465
+
466
+ var _ = Describe ("NodeUnstageVolume [Node Server]" , func () {
467
+ var (
468
+ s csi.ControllerClient
469
+ c csi.NodeClient
470
+ controllerPublishSupported bool
471
+ nodeStageSupported bool
472
+ )
473
+
474
+ BeforeEach (func () {
475
+ s = csi .NewControllerClient (conn )
476
+ c = csi .NewNodeClient (conn )
477
+ controllerPublishSupported = isControllerCapabilitySupported (
478
+ s ,
479
+ csi .ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME )
480
+ nodeStageSupported = isNodeCapabilitySupported (c , csi .NodeServiceCapability_RPC_STAGE_UNSTAGE_VOLUME )
481
+ if nodeStageSupported {
482
+ err := createMountTargetLocation (config .StagingPath )
483
+ Expect (err ).NotTo (HaveOccurred ())
484
+ } else {
485
+ Skip ("NodeUnstageVolume not supported" )
486
+ }
487
+ })
488
+
489
+ It ("should fail when no volume id is provided" , func () {
490
+
491
+ _ , err := c .NodeUnstageVolume (
492
+ context .Background (),
493
+ & csi.NodeUnstageVolumeRequest {
494
+ StagingTargetPath : config .StagingPath ,
495
+ })
496
+ Expect (err ).To (HaveOccurred ())
497
+
498
+ serverError , ok := status .FromError (err )
499
+ Expect (ok ).To (BeTrue ())
500
+ Expect (serverError .Code ()).To (Equal (codes .InvalidArgument ))
501
+ })
502
+
503
+ It ("should fail when no staging target path is provided" , func () {
504
+
505
+ _ , err := c .NodeUnstageVolume (
506
+ context .Background (),
507
+ & csi.NodeUnstageVolumeRequest {
508
+ VolumeId : "id" ,
509
+ })
510
+ Expect (err ).To (HaveOccurred ())
511
+
512
+ serverError , ok := status .FromError (err )
513
+ Expect (ok ).To (BeTrue ())
514
+ Expect (serverError .Code ()).To (Equal (codes .InvalidArgument ))
515
+ })
516
+
517
+ It ("should return appropriate values (no optional values added)" , func () {
518
+ testFullWorkflowSuccess (s , c , controllerPublishSupported , nodeStageSupported )
519
+ })
520
+ })
0 commit comments