@@ -371,26 +371,43 @@ var _ = Describe("NodeStageVolume [Node Server]", func() {
371
371
c csi.NodeClient
372
372
controllerPublishSupported bool
373
373
nodeStageSupported bool
374
+ device string
374
375
)
375
376
376
377
BeforeEach (func () {
377
378
s = csi .NewControllerClient (conn )
378
379
c = csi .NewNodeClient (conn )
380
+ device = "/dev/mock"
379
381
controllerPublishSupported = isControllerCapabilitySupported (
380
382
s ,
381
383
csi .ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME )
382
384
nodeStageSupported = isNodeCapabilitySupported (c , csi .NodeServiceCapability_RPC_STAGE_UNSTAGE_VOLUME )
383
385
if nodeStageSupported {
384
386
err := createMountTargetLocation (config .StagingPath )
385
387
Expect (err ).NotTo (HaveOccurred ())
388
+ } else {
389
+ Skip ("NodeStageVolume not supported" )
386
390
}
387
391
})
388
392
389
393
It ("should fail when no volume id is provided" , func () {
390
394
391
395
_ , err := c .NodeStageVolume (
392
396
context .Background (),
393
- & csi.NodeStageVolumeRequest {})
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
+ })
394
411
Expect (err ).To (HaveOccurred ())
395
412
396
413
serverError , ok := status .FromError (err )
@@ -404,6 +421,17 @@ var _ = Describe("NodeStageVolume [Node Server]", func() {
404
421
context .Background (),
405
422
& csi.NodeStageVolumeRequest {
406
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
+ },
407
435
})
408
436
Expect (err ).To (HaveOccurred ())
409
437
@@ -419,6 +447,9 @@ var _ = Describe("NodeStageVolume [Node Server]", func() {
419
447
& csi.NodeStageVolumeRequest {
420
448
VolumeId : "id" ,
421
449
StagingTargetPath : config .StagingPath ,
450
+ PublishInfo : map [string ]string {
451
+ "device" : device ,
452
+ },
422
453
})
423
454
Expect (err ).To (HaveOccurred ())
424
455
@@ -428,110 +459,7 @@ var _ = Describe("NodeStageVolume [Node Server]", func() {
428
459
})
429
460
430
461
It ("should return appropriate values (no optional values added)" , func () {
431
-
432
- // Create Volume First
433
- By ("creating a single node writer volume" )
434
- name := "sanity"
435
- vol , err := s .CreateVolume (
436
- context .Background (),
437
- & csi.CreateVolumeRequest {
438
- Name : name ,
439
- VolumeCapabilities : []* csi.VolumeCapability {
440
- {
441
- AccessType : & csi.VolumeCapability_Mount {
442
- Mount : & csi.VolumeCapability_MountVolume {},
443
- },
444
- AccessMode : & csi.VolumeCapability_AccessMode {
445
- Mode : csi .VolumeCapability_AccessMode_SINGLE_NODE_WRITER ,
446
- },
447
- },
448
- },
449
- })
450
- Expect (err ).NotTo (HaveOccurred ())
451
- Expect (vol ).NotTo (BeNil ())
452
- Expect (vol .GetVolume ()).NotTo (BeNil ())
453
- Expect (vol .GetVolume ().GetId ()).NotTo (BeEmpty ())
454
-
455
- By ("getting a node id" )
456
- nid , err := c .NodeGetId (
457
- context .Background (),
458
- & csi.NodeGetIdRequest {})
459
- Expect (err ).NotTo (HaveOccurred ())
460
- Expect (nid ).NotTo (BeNil ())
461
- Expect (nid .GetNodeId ()).NotTo (BeEmpty ())
462
- var conpubvol * csi.ControllerPublishVolumeResponse
463
- if controllerPublishSupported {
464
- By ("controller publishing volume" )
465
- conpubvol , err = s .ControllerPublishVolume (
466
- context .Background (),
467
- & csi.ControllerPublishVolumeRequest {
468
- VolumeId : vol .GetVolume ().GetId (),
469
- NodeId : nid .GetNodeId (),
470
- VolumeCapability : & csi.VolumeCapability {
471
- AccessType : & csi.VolumeCapability_Mount {
472
- Mount : & csi.VolumeCapability_MountVolume {},
473
- },
474
- AccessMode : & csi.VolumeCapability_AccessMode {
475
- Mode : csi .VolumeCapability_AccessMode_SINGLE_NODE_WRITER ,
476
- },
477
- },
478
- Readonly : false ,
479
- })
480
- Expect (err ).NotTo (HaveOccurred ())
481
- Expect (conpubvol ).NotTo (BeNil ())
482
- }
483
-
484
- By ("calling nodestage on that volume" )
485
- nodeStageVolReq := & csi.NodeStageVolumeRequest {
486
- VolumeId : vol .GetVolume ().GetId (),
487
- VolumeCapability : & csi.VolumeCapability {
488
- AccessType : & csi.VolumeCapability_Mount {
489
- Mount : & csi.VolumeCapability_MountVolume {},
490
- },
491
- AccessMode : & csi.VolumeCapability_AccessMode {
492
- Mode : csi .VolumeCapability_AccessMode_SINGLE_NODE_WRITER ,
493
- },
494
- },
495
- StagingTargetPath : config .StagingPath ,
496
- }
497
- if controllerPublishSupported {
498
- nodeStageVolReq .PublishInfo = conpubvol .GetPublishInfo ()
499
- }
500
- nodestagevol , err := c .NodeStageVolume (
501
- context .Background (), nodeStageVolReq )
502
- Expect (err ).NotTo (HaveOccurred ())
503
- Expect (nodestagevol ).NotTo (BeNil ())
504
-
505
- By ("cleaning up calling nodeunstage" )
506
- nodeunstagevol , err := c .NodeUnstageVolume (
507
- context .Background (),
508
- & csi.NodeUnstageVolumeRequest {
509
- VolumeId : vol .GetVolume ().GetId (),
510
- StagingTargetPath : config .StagingPath ,
511
- },
512
- )
513
- Expect (err ).NotTo (HaveOccurred ())
514
- Expect (nodeunstagevol ).NotTo (BeNil ())
515
-
516
- if controllerPublishSupported {
517
- By ("cleaning up calling controllerunpublishing" )
518
- controllerunpubvol , err := s .ControllerUnpublishVolume (
519
- context .Background (),
520
- & csi.ControllerUnpublishVolumeRequest {
521
- VolumeId : vol .GetVolume ().GetId (),
522
- NodeId : nid .GetNodeId (),
523
- })
524
- Expect (err ).NotTo (HaveOccurred ())
525
- Expect (controllerunpubvol ).NotTo (BeNil ())
526
- }
527
-
528
- By ("cleaning up deleting the volume" )
529
- _ , err = s .DeleteVolume (
530
- context .Background (),
531
- & csi.DeleteVolumeRequest {
532
- VolumeId : vol .GetVolume ().GetId (),
533
- })
534
- Expect (err ).NotTo (HaveOccurred ())
462
+ testFullWorkflowSuccess (s , c , controllerPublishSupported , nodeStageSupported )
535
463
})
536
464
})
537
465
@@ -553,14 +481,18 @@ var _ = Describe("NodeUnstageVolume [Node Server]", func() {
553
481
if nodeStageSupported {
554
482
err := createMountTargetLocation (config .StagingPath )
555
483
Expect (err ).NotTo (HaveOccurred ())
484
+ } else {
485
+ Skip ("NodeUnstageVolume not supported" )
556
486
}
557
487
})
558
488
559
489
It ("should fail when no volume id is provided" , func () {
560
490
561
491
_ , err := c .NodeUnstageVolume (
562
492
context .Background (),
563
- & csi.NodeUnstageVolumeRequest {})
493
+ & csi.NodeUnstageVolumeRequest {
494
+ StagingTargetPath : config .StagingPath ,
495
+ })
564
496
Expect (err ).To (HaveOccurred ())
565
497
566
498
serverError , ok := status .FromError (err )
@@ -583,109 +515,6 @@ var _ = Describe("NodeUnstageVolume [Node Server]", func() {
583
515
})
584
516
585
517
It ("should return appropriate values (no optional values added)" , func () {
586
-
587
- // Create Volume First
588
- By ("creating a single node writer volume" )
589
- name := "sanity"
590
- vol , err := s .CreateVolume (
591
- context .Background (),
592
- & csi.CreateVolumeRequest {
593
- Name : name ,
594
- VolumeCapabilities : []* csi.VolumeCapability {
595
- {
596
- AccessType : & csi.VolumeCapability_Mount {
597
- Mount : & csi.VolumeCapability_MountVolume {},
598
- },
599
- AccessMode : & csi.VolumeCapability_AccessMode {
600
- Mode : csi .VolumeCapability_AccessMode_SINGLE_NODE_WRITER ,
601
- },
602
- },
603
- },
604
- })
605
- Expect (err ).NotTo (HaveOccurred ())
606
- Expect (vol ).NotTo (BeNil ())
607
- Expect (vol .GetVolume ()).NotTo (BeNil ())
608
- Expect (vol .GetVolume ().GetId ()).NotTo (BeEmpty ())
609
-
610
- By ("getting a node id" )
611
- nid , err := c .NodeGetId (
612
- context .Background (),
613
- & csi.NodeGetIdRequest {})
614
- Expect (err ).NotTo (HaveOccurred ())
615
- Expect (nid ).NotTo (BeNil ())
616
- Expect (nid .GetNodeId ()).NotTo (BeEmpty ())
617
- var conpubvol * csi.ControllerPublishVolumeResponse
618
- if controllerPublishSupported {
619
- By ("controller publishing volume" )
620
- conpubvol , err = s .ControllerPublishVolume (
621
- context .Background (),
622
- & csi.ControllerPublishVolumeRequest {
623
- VolumeId : vol .GetVolume ().GetId (),
624
- NodeId : nid .GetNodeId (),
625
- VolumeCapability : & csi.VolumeCapability {
626
- AccessType : & csi.VolumeCapability_Mount {
627
- Mount : & csi.VolumeCapability_MountVolume {},
628
- },
629
- AccessMode : & csi.VolumeCapability_AccessMode {
630
- Mode : csi .VolumeCapability_AccessMode_SINGLE_NODE_WRITER ,
631
- },
632
- },
633
- Readonly : false ,
634
- })
635
- Expect (err ).NotTo (HaveOccurred ())
636
- Expect (conpubvol ).NotTo (BeNil ())
637
- }
638
-
639
- By ("calling nodestage on that volume" )
640
- nodeStageVolReq := & csi.NodeStageVolumeRequest {
641
- VolumeId : vol .GetVolume ().GetId (),
642
- VolumeCapability : & csi.VolumeCapability {
643
- AccessType : & csi.VolumeCapability_Mount {
644
- Mount : & csi.VolumeCapability_MountVolume {},
645
- },
646
- AccessMode : & csi.VolumeCapability_AccessMode {
647
- Mode : csi .VolumeCapability_AccessMode_SINGLE_NODE_WRITER ,
648
- },
649
- },
650
- StagingTargetPath : config .StagingPath ,
651
- }
652
- if controllerPublishSupported {
653
- nodeStageVolReq .PublishInfo = conpubvol .GetPublishInfo ()
654
- }
655
- nodestagevol , err := c .NodeStageVolume (
656
- context .Background (), nodeStageVolReq )
657
- Expect (err ).NotTo (HaveOccurred ())
658
- Expect (nodestagevol ).NotTo (BeNil ())
659
-
660
- By ("cleaning up calling nodeunstage" )
661
- nodeunstagevol , err := c .NodeUnstageVolume (
662
- context .Background (),
663
- & csi.NodeUnstageVolumeRequest {
664
- VolumeId : vol .GetVolume ().GetId (),
665
- StagingTargetPath : config .StagingPath ,
666
- },
667
- )
668
- Expect (err ).NotTo (HaveOccurred ())
669
- Expect (nodeunstagevol ).NotTo (BeNil ())
670
-
671
- if controllerPublishSupported {
672
- By ("cleaning up calling controllerunpublishing" )
673
- controllerunpubvol , err := s .ControllerUnpublishVolume (
674
- context .Background (),
675
- & csi.ControllerUnpublishVolumeRequest {
676
- VolumeId : vol .GetVolume ().GetId (),
677
- NodeId : nid .GetNodeId (),
678
- })
679
- Expect (err ).NotTo (HaveOccurred ())
680
- Expect (controllerunpubvol ).NotTo (BeNil ())
681
- }
682
-
683
- By ("cleaning up deleting the volume" )
684
- _ , err = s .DeleteVolume (
685
- context .Background (),
686
- & csi.DeleteVolumeRequest {
687
- VolumeId : vol .GetVolume ().GetId (),
688
- })
689
- Expect (err ).NotTo (HaveOccurred ())
518
+ testFullWorkflowSuccess (s , c , controllerPublishSupported , nodeStageSupported )
690
519
})
691
520
})
0 commit comments