Skip to content

Commit

Permalink
fix: Windows unit tests and enable csi-proxy.exe in workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Mayank Shah <[email protected]>
  • Loading branch information
mayankshah1607 committed Oct 2, 2020
1 parent 523f08e commit 14b2fa1
Show file tree
Hide file tree
Showing 6 changed files with 317 additions and 143 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,13 @@ jobs:
go build -a -o _output/azurediskplugin.exe ./pkg/azurediskplugin
- name: Run Windows Unit Tests
run: |
# start the CSI Proxy before running tests on windows
Start-Job -Name CSIProxy -ScriptBlock {
Invoke-WebRequest https://kubernetesartifacts.azureedge.net/csi-proxy/v0.2.1/binaries/csi-proxy.tar.gz -OutFile csi-proxy.tar.gz;
tar -xvf csi-proxy.tar.gz
.\bin\csi-proxy.exe --kubelet-csi-plugins-path $pwd --kubelet-pod-path $pwd
};
Start-Sleep -Seconds 30;
Write-Output "getting named pipes"
[System.IO.Directory]::GetFiles("\\.\\pipe\\")
go test -v -race ./pkg/...
1 change: 1 addition & 0 deletions pkg/azuredisk/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func skipIfTestingOnWindows(t *testing.T) {
}

func TestGetCloudProvider(t *testing.T) {
// skip for now as this is very flaky on Windows
skipIfTestingOnWindows(t)
fakeCredFile := "fake-cred-file.json"
fakeKubeConfig := "fake-kube-config"
Expand Down
1 change: 1 addition & 0 deletions pkg/azuredisk/azuredisk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ func TestIsAvailabilityZone(t *testing.T) {
}

func TestIsCorruptedDir(t *testing.T) {
// skip due to permission issues
skipIfTestingOnWindows(t)
existingMountPath, err := ioutil.TempDir(os.TempDir(), "csi-mount-test")
if err != nil {
Expand Down
13 changes: 13 additions & 0 deletions pkg/azuredisk/fake_mounter.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ package azuredisk

import (
"fmt"
testingexec "k8s.io/utils/exec/testing"
"runtime"
"sigs.k8s.io/azuredisk-csi-driver/pkg/mounter"
"strings"

"k8s.io/utils/mount"
Expand Down Expand Up @@ -59,3 +62,13 @@ func (f *fakeMounter) IsLikelyNotMountPoint(file string) (bool, error) {
}
return true, nil
}

func NewFakeMounter() (*mount.SafeFormatAndMount, error) {
if runtime.GOOS == "windows" {
return mounter.NewSafeMounter()
}
return &mount.SafeFormatAndMount{
Interface: &fakeMounter{},
Exec: &testingexec.FakeExec{ExactOrder: true},
}, nil
}
Loading

0 comments on commit 14b2fa1

Please sign in to comment.