Unverified Commit 54cf942a authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #63399 from andyzhangx/mount-windows-test-fix

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. use TempDir func in mount_windows_test.go **What this PR does / why we need it**: Use `c:\tmp` dir is not correct in windows test, this PR use `ioutil.TempDir("", xx)` to create temp dir instead. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: **Release note**: ``` none ``` /assign @jsafrane @msau42
parents 194e640b 3db442bc
...@@ -139,7 +139,14 @@ func TestGetMountRefs(t *testing.T) { ...@@ -139,7 +139,14 @@ func TestGetMountRefs(t *testing.T) {
} }
func TestDoSafeMakeDir(t *testing.T) { func TestDoSafeMakeDir(t *testing.T) {
const testingVolumePath = `c:\tmp\DoSafeMakeDirTest` base, err := ioutil.TempDir("", "TestDoSafeMakeDir")
if err != nil {
t.Fatalf(err.Error())
}
defer os.RemoveAll(base)
testingVolumePath := filepath.Join(base, "testingVolumePath")
os.MkdirAll(testingVolumePath, 0755) os.MkdirAll(testingVolumePath, 0755)
defer os.RemoveAll(testingVolumePath) defer os.RemoveAll(testingVolumePath)
...@@ -171,7 +178,7 @@ func TestDoSafeMakeDir(t *testing.T) { ...@@ -171,7 +178,7 @@ func TestDoSafeMakeDir(t *testing.T) {
volumePath: testingVolumePath, volumePath: testingVolumePath,
subPath: filepath.Join(testingVolumePath, `symlink`), subPath: filepath.Join(testingVolumePath, `symlink`),
expectError: false, expectError: false,
symlinkTarget: `c:\tmp`, symlinkTarget: base,
}, },
{ {
volumePath: testingVolumePath, volumePath: testingVolumePath,
...@@ -189,7 +196,7 @@ func TestDoSafeMakeDir(t *testing.T) { ...@@ -189,7 +196,7 @@ func TestDoSafeMakeDir(t *testing.T) {
volumePath: testingVolumePath, volumePath: testingVolumePath,
subPath: filepath.Join(testingVolumePath, `a\b\symlink`), subPath: filepath.Join(testingVolumePath, `a\b\symlink`),
expectError: false, expectError: false,
symlinkTarget: `c:\tmp`, symlinkTarget: base,
}, },
{ {
volumePath: testingVolumePath, volumePath: testingVolumePath,
...@@ -228,7 +235,14 @@ func TestDoSafeMakeDir(t *testing.T) { ...@@ -228,7 +235,14 @@ func TestDoSafeMakeDir(t *testing.T) {
} }
func TestLockAndCheckSubPath(t *testing.T) { func TestLockAndCheckSubPath(t *testing.T) {
const testingVolumePath = `c:\tmp\LockAndCheckSubPathTest` base, err := ioutil.TempDir("", "TestLockAndCheckSubPath")
if err != nil {
t.Fatalf(err.Error())
}
defer os.RemoveAll(base)
testingVolumePath := filepath.Join(base, "testingVolumePath")
tests := []struct { tests := []struct {
volumePath string volumePath string
...@@ -270,14 +284,14 @@ func TestLockAndCheckSubPath(t *testing.T) { ...@@ -270,14 +284,14 @@ func TestLockAndCheckSubPath(t *testing.T) {
subPath: filepath.Join(testingVolumePath, `symlink`), subPath: filepath.Join(testingVolumePath, `symlink`),
expectedHandleCount: 0, expectedHandleCount: 0,
expectError: true, expectError: true,
symlinkTarget: `c:\tmp`, symlinkTarget: base,
}, },
{ {
volumePath: testingVolumePath, volumePath: testingVolumePath,
subPath: filepath.Join(testingVolumePath, `a\b\c\symlink`), subPath: filepath.Join(testingVolumePath, `a\b\c\symlink`),
expectedHandleCount: 0, expectedHandleCount: 0,
expectError: true, expectError: true,
symlinkTarget: `c:\tmp`, symlinkTarget: base,
}, },
{ {
volumePath: testingVolumePath, volumePath: testingVolumePath,
...@@ -325,7 +339,14 @@ func TestLockAndCheckSubPath(t *testing.T) { ...@@ -325,7 +339,14 @@ func TestLockAndCheckSubPath(t *testing.T) {
} }
func TestLockAndCheckSubPathWithoutSymlink(t *testing.T) { func TestLockAndCheckSubPathWithoutSymlink(t *testing.T) {
const testingVolumePath = `c:\tmp\LockAndCheckSubPathWithoutSymlinkTest` base, err := ioutil.TempDir("", "TestLockAndCheckSubPathWithoutSymlink")
if err != nil {
t.Fatalf(err.Error())
}
defer os.RemoveAll(base)
testingVolumePath := filepath.Join(base, "testingVolumePath")
tests := []struct { tests := []struct {
volumePath string volumePath string
...@@ -367,14 +388,14 @@ func TestLockAndCheckSubPathWithoutSymlink(t *testing.T) { ...@@ -367,14 +388,14 @@ func TestLockAndCheckSubPathWithoutSymlink(t *testing.T) {
subPath: filepath.Join(testingVolumePath, `symlink`), subPath: filepath.Join(testingVolumePath, `symlink`),
expectedHandleCount: 1, expectedHandleCount: 1,
expectError: true, expectError: true,
symlinkTarget: `c:\tmp`, symlinkTarget: base,
}, },
{ {
volumePath: testingVolumePath, volumePath: testingVolumePath,
subPath: filepath.Join(testingVolumePath, `a\b\c\symlink`), subPath: filepath.Join(testingVolumePath, `a\b\c\symlink`),
expectedHandleCount: 4, expectedHandleCount: 4,
expectError: true, expectError: true,
symlinkTarget: `c:\tmp`, symlinkTarget: base,
}, },
{ {
volumePath: testingVolumePath, volumePath: testingVolumePath,
...@@ -422,7 +443,14 @@ func TestLockAndCheckSubPathWithoutSymlink(t *testing.T) { ...@@ -422,7 +443,14 @@ func TestLockAndCheckSubPathWithoutSymlink(t *testing.T) {
} }
func TestFindExistingPrefix(t *testing.T) { func TestFindExistingPrefix(t *testing.T) {
const testingVolumePath = `c:\tmp\FindExistingPrefixTest` base, err := ioutil.TempDir("", "TestFindExistingPrefix")
if err != nil {
t.Fatalf(err.Error())
}
defer os.RemoveAll(base)
testingVolumePath := filepath.Join(base, "testingVolumePath")
tests := []struct { tests := []struct {
base string base string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment