@@ -44,7 +44,7 @@ func getTestGCEDriverWithCustomMounter(t *testing.T, mounter *mount.SafeFormatAn
44
44
45
45
func getCustomTestGCEDriver (t * testing.T , mounter * mount.SafeFormatAndMount , deviceUtils mountmanager.DeviceUtils , metaService metadataservice.MetadataService ) * GCEDriver {
46
46
gceDriver := GetGCEDriver ()
47
- err := gceDriver .SetupGCEDriver (nil , mounter , deviceUtils , metaService , driver , "test-vendor" )
47
+ err := gceDriver .SetupGCEDriver (nil , mounter , deviceUtils , metaService , mountmanager . NewFakeStatter (), driver , "test-vendor" )
48
48
if err != nil {
49
49
t .Fatalf ("Failed to setup GCE Driver: %v" , err )
50
50
}
@@ -53,13 +53,76 @@ func getCustomTestGCEDriver(t *testing.T, mounter *mount.SafeFormatAndMount, dev
53
53
54
54
func getTestBlockingGCEDriver (t * testing.T , readyToExecute chan chan struct {}) * GCEDriver {
55
55
gceDriver := GetGCEDriver ()
56
- err := gceDriver .SetupGCEDriver (nil , mountmanager .NewFakeSafeBlockingMounter (readyToExecute ), mountmanager .NewFakeDeviceUtils (), metadataservice .NewFakeService (), driver , "test-vendor" )
56
+ err := gceDriver .SetupGCEDriver (nil , mountmanager .NewFakeSafeBlockingMounter (readyToExecute ), mountmanager .NewFakeDeviceUtils (), metadataservice .NewFakeService (), nil , driver , "test-vendor" )
57
57
if err != nil {
58
58
t .Fatalf ("Failed to setup GCE Driver: %v" , err )
59
59
}
60
60
return gceDriver
61
61
}
62
62
63
+ func TestNodeGetVolumeStats (t * testing.T ) {
64
+ gceDriver := getTestGCEDriver (t )
65
+ ns := gceDriver .ns
66
+
67
+ req := & csi.NodePublishVolumeRequest {
68
+ VolumeId : defaultVolumeID ,
69
+ TargetPath : defaultTargetPath ,
70
+ StagingTargetPath : defaultStagingPath ,
71
+ Readonly : false ,
72
+ VolumeCapability : stdVolCap ,
73
+ }
74
+ _ , err := ns .NodePublishVolume (context .Background (), req )
75
+ if err != nil {
76
+ t .Fatalf ("Failed to set up test by publishing default vol: %v" , err )
77
+ }
78
+
79
+ testCases := []struct {
80
+ name string
81
+ volumeID string
82
+ volumePath string
83
+ expectErr bool
84
+ }{
85
+ {
86
+ name : "normal" ,
87
+ volumeID : defaultVolumeID ,
88
+ volumePath : defaultTargetPath ,
89
+ },
90
+ {
91
+ name : "no vol id" ,
92
+ volumePath : defaultTargetPath ,
93
+ expectErr : true ,
94
+ },
95
+ {
96
+ name : "no vol path" ,
97
+ volumeID : defaultVolumeID ,
98
+ expectErr : true ,
99
+ },
100
+ {
101
+ name : "bad vol path" ,
102
+ volumeID : defaultVolumeID ,
103
+ volumePath : "/mnt/fake" ,
104
+ expectErr : true ,
105
+ },
106
+ }
107
+
108
+ for _ , tc := range testCases {
109
+ t .Run (tc .name , func (t * testing.T ) {
110
+
111
+ req := & csi.NodeGetVolumeStatsRequest {
112
+ VolumeId : tc .volumeID ,
113
+ VolumePath : tc .volumePath ,
114
+ }
115
+ _ , err := ns .NodeGetVolumeStats (context .Background (), req )
116
+ if err != nil && ! tc .expectErr {
117
+ t .Fatalf ("Got unexpected err: %v" , err )
118
+ }
119
+ if err == nil && tc .expectErr {
120
+ t .Fatal ("Did not get error but expected one" )
121
+ }
122
+ })
123
+ }
124
+ }
125
+
63
126
func TestNodeGetVolumeLimits (t * testing.T ) {
64
127
65
128
gceDriver := getTestGCEDriver (t )
0 commit comments