Skip to content

Commit 0d8f988

Browse files
author
Matthew Wong
committed
Expect an Lstat call looking for nvme device in successful block NodePublish cases
1 parent 9ea0250 commit 0d8f988

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/driver/node_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,7 @@ func TestNodePublishVolume(t *testing.T) {
904904
mockMounter.EXPECT().MakeFile(targetPath).Return(nil)
905905
mockMounter.EXPECT().Mount(gomock.Eq(devicePath), gomock.Eq(targetPath), gomock.Eq(""), gomock.Eq([]string{"bind"})).Return(nil)
906906
mockMounter.EXPECT().IsLikelyNotMountPoint(gomock.Eq(targetPath)).Return(true, nil)
907+
mockDeviceIdentifier.EXPECT().Lstat(gomock.Eq(nvmeName)).Return(nil, os.ErrNotExist)
907908

908909
req := &csi.NodePublishVolumeRequest{
909910
PublishContext: map[string]string{DevicePathKey: "/dev/fake"},
@@ -950,6 +951,7 @@ func TestNodePublishVolume(t *testing.T) {
950951
mockMounter.EXPECT().MakeDir(gomock.Eq("/test")).Return(nil)
951952
mockMounter.EXPECT().MakeFile(targetPath).Return(nil)
952953
mockMounter.EXPECT().IsLikelyNotMountPoint(gomock.Eq(targetPath)).Return(false, nil)
954+
mockDeviceIdentifier.EXPECT().Lstat(gomock.Eq(nvmeName)).Return(nil, os.ErrNotExist)
953955

954956
req := &csi.NodePublishVolumeRequest{
955957
PublishContext: map[string]string{DevicePathKey: "/dev/fake"},
@@ -998,6 +1000,7 @@ func TestNodePublishVolume(t *testing.T) {
9981000
mockMounter.EXPECT().MakeDir(gomock.Eq("/test")).Return(nil)
9991001
mockMounter.EXPECT().MakeFile(targetPath).Return(nil)
10001002
mockMounter.EXPECT().IsLikelyNotMountPoint(gomock.Eq(targetPath)).Return(true, errors.New("Internal System Error"))
1003+
mockDeviceIdentifier.EXPECT().Lstat(gomock.Eq(nvmeName)).Return(nil, os.ErrNotExist)
10011004

10021005
req := &csi.NodePublishVolumeRequest{
10031006
PublishContext: map[string]string{DevicePathKey: "/dev/fake"},
@@ -1048,6 +1051,7 @@ func TestNodePublishVolume(t *testing.T) {
10481051
mockMounter.EXPECT().Unmount(gomock.Eq(targetPath)).Return(nil)
10491052
mockMounter.EXPECT().IsLikelyNotMountPoint(gomock.Eq(targetPath)).Return(true, errors.New("Internal System Error"))
10501053
mockMounter.EXPECT().Mount(gomock.Eq(devicePath), gomock.Eq(targetPath), gomock.Any(), gomock.Any()).Return(nil)
1054+
mockDeviceIdentifier.EXPECT().Lstat(gomock.Eq(nvmeName)).Return(nil, os.ErrNotExist)
10511055

10521056
req := &csi.NodePublishVolumeRequest{
10531057
PublishContext: map[string]string{DevicePathKey: "/dev/fake"},
@@ -1095,6 +1099,7 @@ func TestNodePublishVolume(t *testing.T) {
10951099
mockMounter.EXPECT().MakeFile(targetPath).Return(nil)
10961100
mockMounter.EXPECT().Mount(gomock.Eq(devicePathWithPartition), gomock.Eq(targetPath), gomock.Eq(""), gomock.Eq([]string{"bind"})).Return(nil)
10971101
mockMounter.EXPECT().IsLikelyNotMountPoint(gomock.Eq(targetPath)).Return(true, nil)
1102+
mockDeviceIdentifier.EXPECT().Lstat(gomock.Eq(nvmeName)).Return(nil, os.ErrNotExist)
10981103

10991104
req := &csi.NodePublishVolumeRequest{
11001105
PublishContext: map[string]string{DevicePathKey: "/dev/fake"},
@@ -1143,6 +1148,7 @@ func TestNodePublishVolume(t *testing.T) {
11431148
mockMounter.EXPECT().MakeFile(targetPath).Return(nil)
11441149
mockMounter.EXPECT().Mount(gomock.Eq(devicePath), gomock.Eq(targetPath), gomock.Eq(""), gomock.Eq([]string{"bind"})).Return(nil)
11451150
mockMounter.EXPECT().IsLikelyNotMountPoint(gomock.Eq(targetPath)).Return(true, nil)
1151+
mockDeviceIdentifier.EXPECT().Lstat(gomock.Eq(nvmeName)).Return(nil, os.ErrNotExist)
11461152

11471153
req := &csi.NodePublishVolumeRequest{
11481154
PublishContext: map[string]string{DevicePathKey: "/dev/fake"},

0 commit comments

Comments
 (0)