Skip to content

Commit 53e8f9d

Browse files
Merge pull request #4434 from medyagh/4433_filepath
Fixing file path for windows
2 parents ed5e342 + c58a3b6 commit 53e8f9d

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
lines changed

test/integration/addons_test.go

+17-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"net"
2626
"net/http"
2727
"net/url"
28+
"path"
2829
"path/filepath"
2930
"strings"
3031
"testing"
@@ -131,12 +132,16 @@ func testIngressController(t *testing.T) {
131132
t.Fatalf("waiting for default-http-backend to be up: %v", err)
132133
}
133134

134-
ingressPath, _ := filepath.Abs("testdata/nginx-ing.yaml")
135+
curdir, err := filepath.Abs("")
136+
if err != nil {
137+
t.Errorf("Error getting the file path for current directory: %s", curdir)
138+
}
139+
ingressPath := path.Join(curdir, "testdata", "nginx-ing.yaml")
135140
if _, err := kubectlRunner.RunCommand([]string{"create", "-f", ingressPath}); err != nil {
136141
t.Fatalf("creating nginx ingress resource: %v", err)
137142
}
138143

139-
podPath, _ := filepath.Abs("testdata/nginx-pod-svc.yaml")
144+
podPath := path.Join(curdir, "testdata", "nginx-pod-svc.yaml")
140145
if _, err := kubectlRunner.RunCommand([]string{"create", "-f", podPath}); err != nil {
141146
t.Fatalf("creating nginx ingress resource: %v", err)
142147
}
@@ -248,7 +253,11 @@ func testGvisorRestart(t *testing.T) {
248253

249254
func createUntrustedWorkload(t *testing.T) {
250255
kubectlRunner := util.NewKubectlRunner(t)
251-
untrustedPath, _ := filepath.Abs("testdata/nginx-untrusted.yaml")
256+
curdir, err := filepath.Abs("")
257+
if err != nil {
258+
t.Errorf("Error getting the file path for current directory: %s", curdir)
259+
}
260+
untrustedPath := path.Join(curdir, "testdata", "nginx-untrusted.yaml")
252261
t.Log("creating pod with untrusted workload annotation")
253262
if _, err := kubectlRunner.RunCommand([]string{"replace", "-f", untrustedPath, "--force"}); err != nil {
254263
t.Fatalf("creating untrusted nginx resource: %v", err)
@@ -257,7 +266,11 @@ func createUntrustedWorkload(t *testing.T) {
257266

258267
func deleteUntrustedWorkload(t *testing.T) {
259268
kubectlRunner := util.NewKubectlRunner(t)
260-
untrustedPath, _ := filepath.Abs("testdata/nginx-untrusted.yaml")
269+
curdir, err := filepath.Abs("")
270+
if err != nil {
271+
t.Errorf("Error getting the file path for current directory: %s", curdir)
272+
}
273+
untrustedPath := path.Join(curdir, "testdata", "nginx-untrusted.yaml")
261274
if _, err := kubectlRunner.RunCommand([]string{"delete", "-f", untrustedPath}); err != nil {
262275
t.Logf("error deleting untrusted nginx resource: %v", err)
263276
}

test/integration/mount_test.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"fmt"
2323
"io/ioutil"
2424
"os"
25+
"path"
2526
"path/filepath"
2627
"runtime"
2728
"strings"
@@ -61,7 +62,11 @@ func testMounting(t *testing.T) {
6162

6263
kubectlRunner := util.NewKubectlRunner(t)
6364
podName := "busybox-mount"
64-
podPath, _ := filepath.Abs("testdata/busybox-mount-test.yaml")
65+
curdir, err := filepath.Abs("")
66+
if err != nil {
67+
t.Errorf("Error getting the file path for current directory: %s", curdir)
68+
}
69+
podPath := path.Join(curdir, "testdata", "busybox-mount-test.yaml")
6570

6671
// Write file in mounted dir from host
6772
expected := "test\n"

test/integration/persistence_test.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ limitations under the License.
1919
package integration
2020

2121
import (
22+
"path"
2223
"path/filepath"
2324
"strings"
2425
"testing"
@@ -36,7 +37,11 @@ func TestPersistence(t *testing.T) {
3637
minikubeRunner.EnsureRunning()
3738

3839
kubectlRunner := util.NewKubectlRunner(t)
39-
podPath, _ := filepath.Abs("testdata/busybox.yaml")
40+
curdir, err := filepath.Abs("")
41+
if err != nil {
42+
t.Errorf("Error getting the file path for current directory: %s", curdir)
43+
}
44+
podPath := path.Join(curdir, "testdata", "busybox.yaml")
4045

4146
// Create a pod and wait for it to be running.
4247
if _, err := kubectlRunner.RunCommand([]string{"create", "-f", podPath}); err != nil {

test/integration/tunnel_test.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"io/ioutil"
2222
"net/http"
2323
"os/exec"
24+
"path"
2425
"path/filepath"
2526
"runtime"
2627
"strings"
@@ -62,7 +63,11 @@ func testTunnel(t *testing.T) {
6263
kubectlRunner := util.NewKubectlRunner(t)
6364

6465
t.Log("deploying nginx...")
65-
podPath, _ := filepath.Abs("testdata/testsvc.yaml")
66+
curdir, err := filepath.Abs("")
67+
if err != nil {
68+
t.Errorf("Error getting the file path for current directory: %s", curdir)
69+
}
70+
podPath := path.Join(curdir, "testdata", "testsvc.yaml")
6671
if _, err := kubectlRunner.RunCommand([]string{"apply", "-f", podPath}); err != nil {
6772
t.Fatalf("creating nginx ingress resource: %s", err)
6873
}

0 commit comments

Comments
 (0)