Skip to content

Commit 31dedc6

Browse files
committed
Add more unit-tests for NodeStageVolume()
1 parent 932c718 commit 31dedc6

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

pkg/smb/nodeserver_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,21 @@ func TestNodeStageVolume(t *testing.T) {
5757
Mount: &csi.VolumeCapability_MountVolume{},
5858
},
5959
}
60+
mountGroupVolCap := csi.VolumeCapability{
61+
AccessType: &csi.VolumeCapability_Mount{
62+
Mount: &csi.VolumeCapability_MountVolume{
63+
VolumeMountGroup: "1000",
64+
},
65+
},
66+
}
67+
mountGroupWithModesVolCap := csi.VolumeCapability{
68+
AccessType: &csi.VolumeCapability_Mount{
69+
Mount: &csi.VolumeCapability_MountVolume{
70+
VolumeMountGroup: "1000",
71+
MountFlags: []string{"file_mode=0111", "dir_mode=0111"},
72+
},
73+
},
74+
}
6075

6176
errorMountSensSource := testutil.GetWorkDirPath("error_mount_sens_source", t)
6277
smbFile := testutil.GetWorkDirPath("smb.go", t)
@@ -191,6 +206,30 @@ func TestNodeStageVolume(t *testing.T) {
191206
strings.Replace(testSource, "\\", "\\\\", -1), sourceTest, testSource, sourceTest),
192207
expectedErr: testutil.TestError{},
193208
},
209+
{
210+
desc: "[Success] Valid request with VolumeMountGroup",
211+
req: csi.NodeStageVolumeRequest{VolumeId: "vol_1##", StagingTargetPath: sourceTest,
212+
VolumeCapability: &mountGroupVolCap,
213+
VolumeContext: volContext,
214+
Secrets: secrets},
215+
skipOnWindows: true,
216+
flakyWindowsErrorMessage: fmt.Sprintf("rpc error: code = Internal desc = volume(vol_1##) mount \"%s\" on %#v failed with "+
217+
"NewSmbGlobalMapping(%s, %s) failed with error: rpc error: code = Unknown desc = NewSmbGlobalMapping failed.",
218+
strings.Replace(testSource, "\\", "\\\\", -1), sourceTest, testSource, sourceTest),
219+
expectedErr: testutil.TestError{},
220+
},
221+
{
222+
desc: "[Success] Valid request with VolumeMountGroup and file/dir modes",
223+
req: csi.NodeStageVolumeRequest{VolumeId: "vol_1##", StagingTargetPath: sourceTest,
224+
VolumeCapability: &mountGroupWithModesVolCap,
225+
VolumeContext: volContext,
226+
Secrets: secrets},
227+
skipOnWindows: true,
228+
flakyWindowsErrorMessage: fmt.Sprintf("rpc error: code = Internal desc = volume(vol_1##) mount \"%s\" on %#v failed with "+
229+
"NewSmbGlobalMapping(%s, %s) failed with error: rpc error: code = Unknown desc = NewSmbGlobalMapping failed.",
230+
strings.Replace(testSource, "\\", "\\\\", -1), sourceTest, testSource, sourceTest),
231+
expectedErr: testutil.TestError{},
232+
},
194233
}
195234

196235
// Setup

0 commit comments

Comments
 (0)