@@ -40,10 +40,11 @@ var (
40
40
func TestNodePublishVolume (t * testing.T ) {
41
41
42
42
var (
43
- dnsname = "fs-0a2d0632b5ff567e9.fsx.us-west-2.amazonaws.com"
44
- mountname = "random"
45
- targetPath = "/target/path"
46
- stdVolCap = & csi.VolumeCapability {
43
+ dnsname = "fs-0a2d0632b5ff567e9.fsx.us-west-2.amazonaws.com"
44
+ mountname = "random"
45
+ targetPath = "/target/path"
46
+ targetPathAlt = "/target/alt_path"
47
+ stdVolCap = & csi.VolumeCapability {
47
48
AccessType : & csi.VolumeCapability_Mount {
48
49
Mount : & csi.VolumeCapability_MountVolume {},
49
50
},
@@ -438,7 +439,7 @@ func TestNodePublishVolume(t *testing.T) {
438
439
},
439
440
},
440
441
{
441
- name : "fail another operation in-flight on given volumeId" ,
442
+ name : "fail another operation in-flight on given volumeId-targetPath " ,
442
443
testFunc : func (t * testing.T ) {
443
444
mockCtl := gomock .NewController (t )
444
445
defer mockCtl .Finish ()
@@ -462,11 +463,56 @@ func TestNodePublishVolume(t *testing.T) {
462
463
TargetPath : targetPath ,
463
464
}
464
465
465
- awsDriver .inFlight .Insert (volumeID )
466
+ rpcKey := fmt .Sprintf ("%s-%s" , volumeID , targetPath )
467
+
468
+ awsDriver .inFlight .Insert (rpcKey )
466
469
_ , err := awsDriver .NodePublishVolume (context .TODO (), req )
467
470
expectErr (t , err , codes .Aborted )
468
471
},
469
472
},
473
+ {
474
+ name : "success: operation in-flight with different volumeId-targetPath" ,
475
+ testFunc : func (t * testing.T ) {
476
+ mockCtl := gomock .NewController (t )
477
+ defer mockCtl .Finish ()
478
+
479
+ mockMetadata := cloudMock .NewMockMetadataService (mockCtl )
480
+ mockMounter := driverMocks .NewMockMounter (mockCtl )
481
+
482
+ awsDriver := & nodeService {
483
+ metadata : mockMetadata ,
484
+ mounter : mockMounter ,
485
+ inFlight : internal .NewInFlight (),
486
+ }
487
+
488
+ source := dnsname + "@tcp:/" + mountname
489
+
490
+ ctx := context .Background ()
491
+ req := & csi.NodePublishVolumeRequest {
492
+ VolumeId : "volumeId" ,
493
+ VolumeContext : map [string ]string {
494
+ volumeContextDnsName : dnsname ,
495
+ volumeContextMountName : mountname ,
496
+ },
497
+ VolumeCapability : stdVolCap ,
498
+ TargetPath : targetPath ,
499
+ }
500
+
501
+ rpcKeyAlt := fmt .Sprintf ("%s-%s" , volumeID , targetPathAlt )
502
+
503
+ awsDriver .inFlight .Insert (rpcKeyAlt )
504
+
505
+ mockMounter .EXPECT ().MakeDir (gomock .Eq (targetPath )).Return (nil )
506
+ mockMounter .EXPECT ().IsLikelyNotMountPoint (gomock .Eq (targetPath )).Return (true , nil )
507
+ mockMounter .EXPECT ().Mount (gomock .Eq (source ), gomock .Eq (targetPath ), gomock .Eq ("lustre" ), gomock .Any ()).Return (nil )
508
+ _ , err := awsDriver .NodePublishVolume (ctx , req )
509
+ if err != nil {
510
+ t .Fatalf ("NodePublishVolume is failed: %v" , err )
511
+ }
512
+
513
+ mockCtl .Finish ()
514
+ },
515
+ },
470
516
}
471
517
472
518
for _ , tc := range testCases {
@@ -477,7 +523,8 @@ func TestNodePublishVolume(t *testing.T) {
477
523
func TestNodeUnpublishVolume (t * testing.T ) {
478
524
479
525
var (
480
- targetPath = "/target/path"
526
+ targetPath = "/target/path"
527
+ targetPathAlt = "/target/alt_path"
481
528
)
482
529
483
530
testCases := []struct {
@@ -601,7 +648,7 @@ func TestNodeUnpublishVolume(t *testing.T) {
601
648
},
602
649
},
603
650
{
604
- name : "fail another operation in-flight on given volumeId" ,
651
+ name : "fail another operation in-flight on given volumeId-targetPath " ,
605
652
testFunc : func (t * testing.T ) {
606
653
mockCtl := gomock .NewController (t )
607
654
defer mockCtl .Finish ()
@@ -620,11 +667,46 @@ func TestNodeUnpublishVolume(t *testing.T) {
620
667
TargetPath : targetPath ,
621
668
}
622
669
623
- awsDriver .inFlight .Insert (volumeID )
670
+ rpcKey := fmt .Sprintf ("%s-%s" , volumeID , targetPath )
671
+
672
+ awsDriver .inFlight .Insert (rpcKey )
624
673
_ , err := awsDriver .NodeUnpublishVolume (context .TODO (), req )
625
674
expectErr (t , err , codes .Aborted )
626
675
},
627
676
},
677
+ {
678
+ name : "success: operation in-flight with different volumeId-targetPath" ,
679
+ testFunc : func (t * testing.T ) {
680
+ mockCtl := gomock .NewController (t )
681
+ defer mockCtl .Finish ()
682
+
683
+ mockMetadata := cloudMock .NewMockMetadataService (mockCtl )
684
+ mockMounter := driverMocks .NewMockMounter (mockCtl )
685
+
686
+ awsDriver := & nodeService {
687
+ metadata : mockMetadata ,
688
+ mounter : mockMounter ,
689
+ inFlight : internal .NewInFlight (),
690
+ }
691
+
692
+ ctx := context .Background ()
693
+ req := & csi.NodeUnpublishVolumeRequest {
694
+ VolumeId : "volumeId" ,
695
+ TargetPath : targetPath ,
696
+ }
697
+
698
+ rpcKeyAlt := fmt .Sprintf ("%s-%s" , volumeID , targetPathAlt )
699
+ awsDriver .inFlight .Insert (rpcKeyAlt )
700
+
701
+ mockMounter .EXPECT ().IsLikelyNotMountPoint (gomock .Eq (targetPath )).Return (false , nil )
702
+ mockMounter .EXPECT ().Unmount (gomock .Eq (targetPath )).Return (nil )
703
+
704
+ _ , err := awsDriver .NodeUnpublishVolume (ctx , req )
705
+ if err != nil {
706
+ t .Fatalf ("NodeUnpublishVolume is failed: %v" , err )
707
+ }
708
+ },
709
+ },
628
710
}
629
711
for _ , tc := range testCases {
630
712
t .Run (tc .name , tc .testFunc )
0 commit comments