From b9ecd558e836ef1d3c6c40096b5fa0ee7c761aaa Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 5 Jun 2019 16:58:52 -0700 Subject: [PATCH 1/2] fixing file path for windows --- test/integration/tunnel_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/integration/tunnel_test.go b/test/integration/tunnel_test.go index 3a487d1df492..8051049be3cd 100644 --- a/test/integration/tunnel_test.go +++ b/test/integration/tunnel_test.go @@ -21,6 +21,7 @@ import ( "io/ioutil" "net/http" "os/exec" + "path" "path/filepath" "runtime" "strings" @@ -62,7 +63,11 @@ func testTunnel(t *testing.T) { kubectlRunner := util.NewKubectlRunner(t) t.Log("deploying nginx...") - podPath, _ := filepath.Abs("testdata/testsvc.yaml") + curdir, err := filepath.Abs("") + if err != nil { + t.Errorf("Error getting the file path for current directory: %s", curdir) + } + podPath := path.Join(curdir, "testdata/testsvc.yaml") if _, err := kubectlRunner.RunCommand([]string{"apply", "-f", podPath}); err != nil { t.Fatalf("creating nginx ingress resource: %s", err) } From c58a3b63db0095ce807bf7e011581f3db8790b1c Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 5 Jun 2019 17:15:35 -0700 Subject: [PATCH 2/2] Fixing filepath to be os agnostic --- test/integration/addons_test.go | 21 +++++++++++++++++---- test/integration/mount_test.go | 7 ++++++- test/integration/persistence_test.go | 7 ++++++- test/integration/tunnel_test.go | 2 +- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/test/integration/addons_test.go b/test/integration/addons_test.go index 748894f2e0ba..682cffdc2f2c 100644 --- a/test/integration/addons_test.go +++ b/test/integration/addons_test.go @@ -25,6 +25,7 @@ import ( "net" "net/http" "net/url" + "path" "path/filepath" "strings" "testing" @@ -131,12 +132,16 @@ func testIngressController(t *testing.T) { t.Fatalf("waiting for default-http-backend to be up: %v", err) } - ingressPath, _ := filepath.Abs("testdata/nginx-ing.yaml") + curdir, err := filepath.Abs("") + if err != nil { + t.Errorf("Error getting the file path for current directory: %s", curdir) + } + ingressPath := path.Join(curdir, "testdata", "nginx-ing.yaml") if _, err := kubectlRunner.RunCommand([]string{"create", "-f", ingressPath}); err != nil { t.Fatalf("creating nginx ingress resource: %v", err) } - podPath, _ := filepath.Abs("testdata/nginx-pod-svc.yaml") + podPath := path.Join(curdir, "testdata", "nginx-pod-svc.yaml") if _, err := kubectlRunner.RunCommand([]string{"create", "-f", podPath}); err != nil { t.Fatalf("creating nginx ingress resource: %v", err) } @@ -248,7 +253,11 @@ func testGvisorRestart(t *testing.T) { func createUntrustedWorkload(t *testing.T) { kubectlRunner := util.NewKubectlRunner(t) - untrustedPath, _ := filepath.Abs("testdata/nginx-untrusted.yaml") + curdir, err := filepath.Abs("") + if err != nil { + t.Errorf("Error getting the file path for current directory: %s", curdir) + } + untrustedPath := path.Join(curdir, "testdata", "nginx-untrusted.yaml") t.Log("creating pod with untrusted workload annotation") if _, err := kubectlRunner.RunCommand([]string{"replace", "-f", untrustedPath, "--force"}); err != nil { t.Fatalf("creating untrusted nginx resource: %v", err) @@ -257,7 +266,11 @@ func createUntrustedWorkload(t *testing.T) { func deleteUntrustedWorkload(t *testing.T) { kubectlRunner := util.NewKubectlRunner(t) - untrustedPath, _ := filepath.Abs("testdata/nginx-untrusted.yaml") + curdir, err := filepath.Abs("") + if err != nil { + t.Errorf("Error getting the file path for current directory: %s", curdir) + } + untrustedPath := path.Join(curdir, "testdata", "nginx-untrusted.yaml") if _, err := kubectlRunner.RunCommand([]string{"delete", "-f", untrustedPath}); err != nil { t.Logf("error deleting untrusted nginx resource: %v", err) } diff --git a/test/integration/mount_test.go b/test/integration/mount_test.go index 156e44e6cd0a..a55d04e41700 100644 --- a/test/integration/mount_test.go +++ b/test/integration/mount_test.go @@ -22,6 +22,7 @@ import ( "fmt" "io/ioutil" "os" + "path" "path/filepath" "runtime" "strings" @@ -61,7 +62,11 @@ func testMounting(t *testing.T) { kubectlRunner := util.NewKubectlRunner(t) podName := "busybox-mount" - podPath, _ := filepath.Abs("testdata/busybox-mount-test.yaml") + curdir, err := filepath.Abs("") + if err != nil { + t.Errorf("Error getting the file path for current directory: %s", curdir) + } + podPath := path.Join(curdir, "testdata", "busybox-mount-test.yaml") // Write file in mounted dir from host expected := "test\n" diff --git a/test/integration/persistence_test.go b/test/integration/persistence_test.go index 0d889ee9dd9e..158c70668d49 100644 --- a/test/integration/persistence_test.go +++ b/test/integration/persistence_test.go @@ -19,6 +19,7 @@ limitations under the License. package integration import ( + "path" "path/filepath" "strings" "testing" @@ -36,7 +37,11 @@ func TestPersistence(t *testing.T) { minikubeRunner.EnsureRunning() kubectlRunner := util.NewKubectlRunner(t) - podPath, _ := filepath.Abs("testdata/busybox.yaml") + curdir, err := filepath.Abs("") + if err != nil { + t.Errorf("Error getting the file path for current directory: %s", curdir) + } + podPath := path.Join(curdir, "testdata", "busybox.yaml") // Create a pod and wait for it to be running. if _, err := kubectlRunner.RunCommand([]string{"create", "-f", podPath}); err != nil { diff --git a/test/integration/tunnel_test.go b/test/integration/tunnel_test.go index 8051049be3cd..d869938f1820 100644 --- a/test/integration/tunnel_test.go +++ b/test/integration/tunnel_test.go @@ -67,7 +67,7 @@ func testTunnel(t *testing.T) { if err != nil { t.Errorf("Error getting the file path for current directory: %s", curdir) } - podPath := path.Join(curdir, "testdata/testsvc.yaml") + podPath := path.Join(curdir, "testdata", "testsvc.yaml") if _, err := kubectlRunner.RunCommand([]string{"apply", "-f", podPath}); err != nil { t.Fatalf("creating nginx ingress resource: %s", err) }