Skip to content

Commit

Permalink
Merge pull request #4434 from medyagh/4433_filepath
Browse files Browse the repository at this point in the history
Fixing file path for windows
  • Loading branch information
sharifelgamal committed Jun 6, 2019
2 parents ed5e342 + c58a3b6 commit 53e8f9d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
21 changes: 17 additions & 4 deletions test/integration/addons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"net"
"net/http"
"net/url"
"path"
"path/filepath"
"strings"
"testing"
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down
7 changes: 6 additions & 1 deletion test/integration/mount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"runtime"
"strings"
Expand Down Expand Up @@ -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"
Expand Down
7 changes: 6 additions & 1 deletion test/integration/persistence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ limitations under the License.
package integration

import (
"path"
"path/filepath"
"strings"
"testing"
Expand All @@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion test/integration/tunnel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"io/ioutil"
"net/http"
"os/exec"
"path"
"path/filepath"
"runtime"
"strings"
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 53e8f9d

Please sign in to comment.