@@ -28,6 +28,8 @@ func pathExists(path string) (bool, error) {
28
28
29
29
func TestFilesystemAPIGroup (t * testing.T ) {
30
30
t .Run ("PathExists positive" , func (t * testing.T ) {
31
+ skipTestIfRunningOnWindows (t )
32
+
31
33
client , err := v1beta1client .NewClient ()
32
34
require .Nil (t , err )
33
35
defer client .Close ()
@@ -36,7 +38,7 @@ func TestFilesystemAPIGroup(t *testing.T) {
36
38
r1 := rand .New (s1 )
37
39
38
40
// simulate FS operations around staging a volume on a node
39
- stagepath := fmt .Sprintf ("C: \\ var \\ lib \\ kubelet \\ plugins \\ testplugin-%d.csi.io\\ volume%d" , r1 .Intn (100 ), r1 .Intn (100 ))
41
+ stagepath := getWorkDirPath ( fmt .Sprintf ("testplugin-%d.csi.io\\ volume%d" , r1 .Intn (100 ), r1 .Intn (100 )), t )
40
42
mkdirReq := & v1beta1.MkdirRequest {
41
43
Path : stagepath ,
42
44
Context : v1beta1 .PathContext_PLUGIN ,
@@ -50,7 +52,7 @@ func TestFilesystemAPIGroup(t *testing.T) {
50
52
assert .True (t , exists , err )
51
53
52
54
// simulate operations around publishing a volume to a pod
53
- podpath := fmt .Sprintf ("C: \\ var \\ lib \\ kubelet \\ pods \\ test-pod-id\\ volumes\\ kubernetes.io~csi\\ pvc-test%d" , r1 .Intn (100 ))
55
+ podpath := getWorkDirPath ( fmt .Sprintf ("test-pod-id\\ volumes\\ kubernetes.io~csi\\ pvc-test%d" , r1 .Intn (100 )), t )
54
56
mkdirReq = & v1beta1.MkdirRequest {
55
57
Path : podpath ,
56
58
Context : v1beta1 .PathContext_POD ,
@@ -109,18 +111,18 @@ func TestFilesystemAPIGroup(t *testing.T) {
109
111
rand1 := r1 .Intn (100 )
110
112
rand2 := r1 .Intn (100 )
111
113
112
- testDir := fmt .Sprintf ("C: \\ var \\ lib \\ kubelet \\ plugins \\ testplugin-%d.csi.io" , rand1 )
114
+ testDir := getWorkDirPath ( fmt .Sprintf ("testplugin-%d.csi.io" , rand1 ), t )
113
115
err = os .MkdirAll (testDir , os .ModeDir )
114
116
require .Nil (t , err )
115
117
defer os .RemoveAll (testDir )
116
118
117
119
// 1. Check the isMount on a path which does not exist. Failure scenario.
118
- stagepath := fmt .Sprintf ("C: \\ var \\ lib \\ kubelet \\ plugins \\ testplugin-%d.csi.io\\ volume%d" , rand1 , rand2 )
120
+ stagepath := getWorkDirPath ( fmt .Sprintf ("testplugin-%d.csi.io\\ volume%d" , rand1 , rand2 ), t )
119
121
isMountRequest := & v1beta1.IsMountPointRequest {
120
122
Path : stagepath ,
121
123
}
122
124
isMountResponse , err := client .IsMountPoint (context .Background (), isMountRequest )
123
- require .Nil (t , err )
125
+ require .NotNil (t , err )
124
126
125
127
// 2. Create the directory. This time its not a mount point. Failure scenario.
126
128
err = os .Mkdir (stagepath , os .ModeDir )
@@ -135,8 +137,8 @@ func TestFilesystemAPIGroup(t *testing.T) {
135
137
136
138
err = os .Remove (stagepath )
137
139
require .Nil (t , err )
138
- targetStagePath := fmt .Sprintf ("C: \\ var \\ lib \\ kubelet \\ plugins \\ testplugin-%d.csi.io\\ volume%d-tgt" , rand1 , rand2 )
139
- lnTargetStagePath := fmt .Sprintf ("C: \\ var \\ lib \\ kubelet \\ plugins \\ testplugin-%d.csi.io\\ volume%d-tgt-ln" , rand1 , rand2 )
140
+ targetStagePath := getWorkDirPath ( fmt .Sprintf ("testplugin-%d.csi.io\\ volume%d-tgt" , rand1 , rand2 ), t )
141
+ lnTargetStagePath := getWorkDirPath ( fmt .Sprintf ("testplugin-%d.csi.io\\ volume%d-tgt-ln" , rand1 , rand2 ), t )
140
142
141
143
// 3. Create soft link to the directory and make sure target exists. Success scenario.
142
144
err = os .Mkdir (targetStagePath , os .ModeDir )
0 commit comments