Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unit tests on windows and add to pipeline #406

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -25,6 +25,4 @@ jobs:
go build -a -o _output/azurefileplugin.exe ./pkg/azurefileplugin
- name: Run Windows Unit Tests
run: |
go test -v -race ./pkg/mounter/...
go test -v -race ./pkg/util/...
go test -v -race ./pkg/csi-common/...
go test -v -race ./pkg/...
8 changes: 8 additions & 0 deletions pkg/azurefile/azure_test.go
Original file line number Diff line number Diff line change
@@ -21,12 +21,20 @@ import (
"io/ioutil"
"os"
"reflect"
"runtime"
"testing"
)

func skipIfTestingOnWindows(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("Skipping test on Windows")
}
}

// TestGetCloudProvider tests the func GetCloudProvider().
// To run this unit test successfully, need to ensure /etc/kubernetes/azure.json nonexistent.
func TestGetCloudProvider(t *testing.T) {
skipIfTestingOnWindows(t)
fakeCredFile := "fake-cred-file.json"
fakeKubeConfig := "fake-kube-config"
emptyKubeConfig := "empty-kube-config"
1 change: 1 addition & 0 deletions pkg/azurefile/azurefile_test.go
Original file line number Diff line number Diff line change
@@ -590,6 +590,7 @@ func TestGetAccountInfo(t *testing.T) {
}

func TestCreateDisk(t *testing.T) {
skipIfTestingOnWindows(t)
d := NewFakeDriver()
d.cloud = &azure.Cloud{}
tests := []struct {
1 change: 1 addition & 0 deletions pkg/azurefile/controllerserver_test.go
Original file line number Diff line number Diff line change
@@ -473,6 +473,7 @@ func TestCreateVolume(t *testing.T) {
{
name: "Create disk returns error",
testFunc: func(t *testing.T) {
skipIfTestingOnWindows(t)
name := "baz"
sku := "sku"
kind := "StorageV2"
4 changes: 4 additions & 0 deletions pkg/azurefile/nodeserver_test.go
Original file line number Diff line number Diff line change
@@ -78,6 +78,7 @@ func TestNodeGetCapabilities(t *testing.T) {
}

func TestNodePublishVolume(t *testing.T) {
skipIfTestingOnWindows(t)
volumeCap := csi.VolumeCapability_AccessMode{Mode: csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER}
errorMountSource := "./error_mount_source"
alreadyMountedTarget := "./false_is_likely_exist_target"
@@ -183,6 +184,7 @@ func TestNodePublishVolume(t *testing.T) {
}

func TestNodeUnpublishVolume(t *testing.T) {
skipIfTestingOnWindows(t)
errorTarget := "./error_is_likely_target"
targetFile := "./abc.go"

@@ -236,6 +238,7 @@ func TestNodeUnpublishVolume(t *testing.T) {
}

func TestNodeStageVolume(t *testing.T) {
skipIfTestingOnWindows(t)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls re-enable this unit test on Windows later, thanks.

stdVolCap := csi.VolumeCapability{
AccessType: &csi.VolumeCapability_Mount{
Mount: &csi.VolumeCapability_MountVolume{},
@@ -421,6 +424,7 @@ func TestNodeStageVolume(t *testing.T) {
}

func TestNodeUnstageVolume(t *testing.T) {
skipIfTestingOnWindows(t)
errorTarget := "./error_is_likely_target"
targetFile := "./abc.go"