Skip to content

Commit a528961

Browse files
fix: enable unit tests on Windows with CSI Proxy mount
Signed-off-by: Mayank Shah <[email protected]>
1 parent 0dc7e9f commit a528961

File tree

5 files changed

+183
-108
lines changed

5 files changed

+183
-108
lines changed

.github/workflows/windows.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,15 @@ jobs:
2525
- name: Run Windows Unit Tests
2626
run: |
2727
# start the CSI Proxy before running tests on windows
28-
Start-Job -Name CSIProx -ScriptBlock {
28+
Start-Job -Name CSIProxy -ScriptBlock {
2929
Invoke-WebRequest https://kubernetesartifacts.azureedge.net/csi-proxy/v0.2.1/binaries/csi-proxy.tar.gz -OutFile csi-proxy.tar.gz;
3030
tar -xvf csi-proxy.tar.gz
3131
.\bin\csi-proxy.exe --kubelet-csi-plugins-path $pwd --kubelet-pod-path $pwd
3232
};
3333
34-
# Wait for the CSI Proxy to come up
3534
Start-Sleep -Seconds 30;
3635
37-
# Print all the named pipes to make sure that CSI-Proxy's named-pipes are created.
38-
Write-Output "Getting named pipes"
36+
Write-Output "getting named pipes"
3937
[System.IO.Directory]::GetFiles("\\.\\pipe\\")
4038
41-
# Start the tests
4239
go test -v -race ./pkg/...

pkg/smb/fake_mounter.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ package smb
1818

1919
import (
2020
"fmt"
21+
"github.com/kubernetes-csi/csi-driver-smb/pkg/mounter"
22+
"runtime"
2123
"strings"
2224

2325
"k8s.io/utils/mount"
@@ -59,3 +61,12 @@ func (f *fakeMounter) IsLikelyNotMountPoint(file string) (bool, error) {
5961
}
6062
return true, nil
6163
}
64+
65+
func NewFakeMounter() (*mount.SafeFormatAndMount, error) {
66+
if runtime.GOOS == "windows" {
67+
return mounter.NewSafeMounter()
68+
}
69+
return &mount.SafeFormatAndMount{
70+
Interface: &fakeMounter{},
71+
}, nil
72+
}

0 commit comments

Comments
 (0)