Skip to content

Commit

Permalink
test: enable csi-proxy.exe in workflow and enable windows unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Mayank Shah <[email protected]>
  • Loading branch information
mayankshah1607 committed Sep 29, 2020
1 parent 523f08e commit 631ce7e
Show file tree
Hide file tree
Showing 7 changed files with 326 additions and 146 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/...
3 changes: 2 additions & 1 deletion pkg/azuredisk/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"fmt"
"io/ioutil"
"os"
"reflect"
"runtime"
"sigs.k8s.io/azuredisk-csi-driver/test/utils/testutil"
"testing"
)

Expand All @@ -32,6 +32,7 @@ func skipIfTestingOnWindows(t *testing.T) {
}

func TestGetCloudProvider(t *testing.T) {
// skip on Windows for now as it gets very flaky
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 for now, due to issues related to admin privileges on Windows
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
}
9 changes: 9 additions & 0 deletions pkg/azuredisk/fake_mounter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ package azuredisk
import (
"fmt"
"reflect"
"sigs.k8s.io/azuredisk-csi-driver/test/utils/testutil"
"testing"

"k8s.io/utils/mount"
)

func TestMount(t *testing.T) {
targetTest := testutil.GetWorkDirPath("target_test", t)
sourceTest := testutil.GetWorkDirPath("source_test", t)

tests := []struct {
desc string
source string
Expand Down Expand Up @@ -65,6 +69,9 @@ func TestMount(t *testing.T) {
}

func TestMountSensitive(t *testing.T) {
targetTest := testutil.GetWorkDirPath("target_test", t)
sourceTest := testutil.GetWorkDirPath("source_test", t)

tests := []struct {
desc string
source string
Expand Down Expand Up @@ -105,6 +112,8 @@ func TestMountSensitive(t *testing.T) {
}

func TestIsLikelyNotMountPoint(t *testing.T) {
targetTest := testutil.GetWorkDirPath("target_test", t)

tests := []struct {
desc string
file string
Expand Down
Loading

0 comments on commit 631ce7e

Please sign in to comment.