From 887e4ff16809b268d5342e93f6d901cd424d6f43 Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Sun, 6 Sep 2020 08:03:32 +0000 Subject: [PATCH] test: add Windows unit test pipeline fix ut failure on Windows --- .github/workflows/{window => windows.yml} | 4 +++- pkg/azuredisk/azure_common_test.go | 7 ++++--- pkg/azuredisk/nodeserver_test.go | 7 ++++++- 3 files changed, 13 insertions(+), 5 deletions(-) rename .github/workflows/{window => windows.yml} (81%) diff --git a/.github/workflows/window b/.github/workflows/windows.yml similarity index 81% rename from .github/workflows/window rename to .github/workflows/windows.yml index 181520a25e..2930cbb58c 100644 --- a/.github/workflows/window +++ b/.github/workflows/windows.yml @@ -25,4 +25,6 @@ jobs: go build -a -o _output/azurediskplugin.exe ./pkg/azurediskplugin - name: Run Windows Unit Tests run: | - go test -v -race ./pkg/... ./test/utils/credentials + go test -v -race ./pkg/mounter/... + go test -v -race ./pkg/util/... + go test -v -race ./pkg/csi-common/... diff --git a/pkg/azuredisk/azure_common_test.go b/pkg/azuredisk/azure_common_test.go index 2e3403f374..138dee51af 100644 --- a/pkg/azuredisk/azure_common_test.go +++ b/pkg/azuredisk/azure_common_test.go @@ -18,13 +18,14 @@ package azuredisk import ( "fmt" - api "k8s.io/kubernetes/pkg/apis/core" "os" "runtime" "strings" "testing" "time" + api "k8s.io/kubernetes/pkg/apis/core" + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute" "github.com/stretchr/testify/assert" @@ -122,8 +123,8 @@ func (handler *fakeIOHandler) ReadFile(filename string) ([]byte, error) { } func TestIoHandler(t *testing.T) { - if runtime.GOOS != "windows" && runtime.GOOS != "linux" { - t.Skipf("TestIoHandler not supported on GOOS=%s", runtime.GOOS) + if runtime.GOOS == "windows" { + t.Skipf("skip test on GOOS=%s", runtime.GOOS) } disk, err := findDiskByLun(lun, &fakeIOHandler{}, nil) if runtime.GOOS == "windows" { diff --git a/pkg/azuredisk/nodeserver_test.go b/pkg/azuredisk/nodeserver_test.go index 6ec6cb10d3..06afa8061c 100644 --- a/pkg/azuredisk/nodeserver_test.go +++ b/pkg/azuredisk/nodeserver_test.go @@ -22,6 +22,7 @@ import ( "fmt" "os" "reflect" + "runtime" "syscall" "testing" @@ -30,7 +31,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "k8s.io/utils/exec/testing" + testingexec "k8s.io/utils/exec/testing" "k8s.io/utils/mount" "sigs.k8s.io/azuredisk-csi-driver/pkg/mounter" @@ -232,6 +233,10 @@ func TestNodeGetVolumeStats(t *testing.T) { } func TestNodeStageVolume(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skipf("skip test on GOOS=%s", runtime.GOOS) + } + stdVolCap := &csi.VolumeCapability_Mount{ Mount: &csi.VolumeCapability_MountVolume{ FsType: defaultLinuxFsType,