From 7b81e8068f5a388c299bcf7aabe937ba7a0c788e Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Sun, 24 May 2020 04:46:35 -0700 Subject: [PATCH 01/51] add powershell run helper --- test/integration/functional_test.go | 10 ++++++-- test/integration/helpers.go | 38 +++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 60b3011377..6fe65b8ea5 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -170,8 +170,14 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { mctx, cancel = context.WithTimeout(ctx, Seconds(13)) defer cancel() // do a eval $(minikube -p profile docker-env) and check if we are point to docker inside minikube - c = exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" docker-env) && docker images") - rr, err = Run(t, c) + if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! + c = exec.CommandContext(mctx, Target(), "-p "+profile+" docker-env | Invoke-Expression ; docker images") + rr, err = Run(t, c, true) + } else { + c = exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" docker-env) && docker images") + rr, err = Run(t, c) + } + if err != nil { t.Fatalf("failed to run minikube docker-env. args %q : %v ", rr.Command(), err) } diff --git a/test/integration/helpers.go b/test/integration/helpers.go index cc3036a7e9..a432d5fe47 100644 --- a/test/integration/helpers.go +++ b/test/integration/helpers.go @@ -86,16 +86,33 @@ func (rr RunResult) Output() string { } // Run is a test helper to log a command being executed \_(ツ)_/¯ -func Run(t *testing.T, cmd *exec.Cmd) (*RunResult, error) { +func Run(t *testing.T, cmd *exec.Cmd, powershell ...bool) (*RunResult, error) { t.Helper() - rr := &RunResult{Args: cmd.Args} + isPowershell := false + if len(powershell) > 0 { + isPowershell = powershell[0] + } + + newCmd := cmd + if isPowershell { + psBin, err := exec.LookPath("powershell.exe") + if err != nil { + return &RunResult{}, err + } + args := append([]string{"-NoProfile", "-NonInteractive"}, cmd.Args...) + newCmd = exec.Command(psBin, args...) + + } + + rr := &RunResult{Args: newCmd.Args} + t.Logf("(dbg) Run: %v", rr.Command()) var outb, errb bytes.Buffer - cmd.Stdout, rr.Stdout = &outb, &outb - cmd.Stderr, rr.Stderr = &errb, &errb + newCmd.Stdout, rr.Stdout = &outb, &outb + newCmd.Stderr, rr.Stderr = &errb, &errb start := time.Now() - err := cmd.Run() + err := newCmd.Run() elapsed := time.Since(start) if err == nil { // Reduce log spam @@ -447,3 +464,14 @@ func killProcessFamily(t *testing.T, pid int) { } } } + +func RunPowershellCmd(args ...string) (string, error) { + psBin, err := exec.LookPath("powershell.exe") + if err != nil { + return "", err + } + args = append([]string{"-NoProfile", "-NonInteractive"}, args...) + cmd := exec.Command(psBin, args...) + out, err := cmd.CombinedOutput() + return string(out), err +} From ed9950efc5a0dc22606ffbb3e21c71d00da7dd54 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Sun, 24 May 2020 04:52:22 -0700 Subject: [PATCH 02/51] increase time for docker-env test --- test/integration/functional_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 6fe65b8ea5..b8c868f6b3 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -155,7 +155,7 @@ func validateNodeLabels(ctx context.Context, t *testing.T, profile string) { func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { defer PostMortemLogs(t, profile) - mctx, cancel := context.WithTimeout(ctx, Seconds(13)) + mctx, cancel := context.WithTimeout(ctx, Minutes(1)) defer cancel() // we should be able to get minikube status with a bash which evaled docker-env c := exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" docker-env) && "+Target()+" status -p "+profile) From d4e4bbb17022921d8280aa5b211fa0e1fabaebc8 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Sun, 24 May 2020 14:55:38 -0700 Subject: [PATCH 03/51] add powershell to both commands --- test/integration/functional_test.go | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index b8c868f6b3..23b9e04812 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -157,11 +157,18 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { mctx, cancel := context.WithTimeout(ctx, Minutes(1)) defer cancel() - // we should be able to get minikube status with a bash which evaled docker-env - c := exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" docker-env) && "+Target()+" status -p "+profile) - rr, err := Run(t, c) + var rr *RunResult + var err error + if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! + c := exec.CommandContext(mctx, Target(), "-p "+profile+" docker-env | Invoke-Expression ;"+Target()+" status -p "+profile) + rr, err = Run(t, c, true) // golang exec powershell needs some tricks ! + } else { + c := exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" docker-env) && "+Target()+" status -p "+profile) + // we should be able to get minikube status with a bash which evaled docker-env + rr, err = Run(t, c) + } if err != nil { - t.Fatalf("failed to do minikube status after eval-ing docker-env %s", err) + t.Fatalf("failed to do status after eval-ing docker-env. error: %v", err) } if !strings.Contains(rr.Output(), "Running") { t.Fatalf("expected status output to include 'Running' after eval docker-env but got: *%s*", rr.Output()) @@ -170,11 +177,11 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { mctx, cancel = context.WithTimeout(ctx, Seconds(13)) defer cancel() // do a eval $(minikube -p profile docker-env) and check if we are point to docker inside minikube - if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! - c = exec.CommandContext(mctx, Target(), "-p "+profile+" docker-env | Invoke-Expression ; docker images") - rr, err = Run(t, c, true) + if runtime.GOOS == "windows" { // testing docker-env eval in powershell + c := exec.CommandContext(mctx, Target(), "-p "+profile+" docker-env | Invoke-Expression ; docker images") + rr, err = Run(t, c, true) // golang exec powershell needs some tricks ! } else { - c = exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" docker-env) && docker images") + c := exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" docker-env) && docker images") rr, err = Run(t, c) } From 2cf49def091bce8e04f9a1089f7d0855bea4f360 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Sun, 24 May 2020 15:20:58 -0700 Subject: [PATCH 04/51] lower the timeout --- test/integration/functional_test.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 23b9e04812..db0e942d12 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -155,7 +155,7 @@ func validateNodeLabels(ctx context.Context, t *testing.T, profile string) { func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { defer PostMortemLogs(t, profile) - mctx, cancel := context.WithTimeout(ctx, Minutes(1)) + mctx, cancel := context.WithTimeout(ctx, Seconds(30)) defer cancel() var rr *RunResult var err error @@ -167,6 +167,9 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { // we should be able to get minikube status with a bash which evaled docker-env rr, err = Run(t, c) } + if ctx.Err() == context.DeadlineExceeded { + t.Logf("failed to run the command in 30 seconds. exceeded 30s timeout. %s", rr.Command()) + } if err != nil { t.Fatalf("failed to do status after eval-ing docker-env. error: %v", err) } @@ -174,7 +177,7 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { t.Fatalf("expected status output to include 'Running' after eval docker-env but got: *%s*", rr.Output()) } - mctx, cancel = context.WithTimeout(ctx, Seconds(13)) + mctx, cancel = context.WithTimeout(ctx, Seconds(30)) defer cancel() // do a eval $(minikube -p profile docker-env) and check if we are point to docker inside minikube if runtime.GOOS == "windows" { // testing docker-env eval in powershell @@ -185,6 +188,10 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { rr, err = Run(t, c) } + if ctx.Err() == context.DeadlineExceeded { + t.Logf("failed to run the command in 30 seconds. exceeded 30s timeout. %s", rr.Command()) + } + if err != nil { t.Fatalf("failed to run minikube docker-env. args %q : %v ", rr.Command(), err) } From e2d4290800b843ad0dec78875918260942c82fad Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 25 May 2020 15:55:54 -0700 Subject: [PATCH 05/51] functional test --- test/integration/functional_test.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index db0e942d12..a16f7c087f 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -837,7 +837,17 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { t.Skipf("skipping: ssh unsupported by none") } want := "hello\n" - rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", fmt.Sprintf("echo hello"))) + var rr *RunResult + var err error + if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", fmt.Sprintf("echo hello")), true) + } else { + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", fmt.Sprintf("echo hello"))) + } + if ctx.Err() == context.DeadlineExceeded { + t.Logf("failed to run command by deadline. exceeded timeout : %s", rr.Command()) + } + if err != nil { t.Errorf("failed to run an ssh command. args %q : %v", rr.Command(), err) } From 1881032044f7ab5b39a42a8af40c06d740d660ea Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 25 May 2020 16:30:04 -0700 Subject: [PATCH 06/51] fix ssh test --- test/integration/functional_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index a16f7c087f..ec0538c513 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -836,13 +836,14 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { if NoneDriver() { t.Skipf("skipping: ssh unsupported by none") } - want := "hello\n" + want := profile+"\n" var rr *RunResult var err error if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", fmt.Sprintf("echo hello")), true) + minikube ssh --% "echo $(pwd)" + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "--%", "cat /etc/hostname", true) } else { - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", fmt.Sprintf("echo hello"))) + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/hostname")) } if ctx.Err() == context.DeadlineExceeded { t.Logf("failed to run command by deadline. exceeded timeout : %s", rr.Command()) From 7d78e01fb8b15a582bb4b9744aafb948a219f6c8 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 25 May 2020 16:40:07 -0700 Subject: [PATCH 07/51] fix ssh test --- test/integration/functional_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index ec0538c513..644cad72f2 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -836,12 +836,11 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { if NoneDriver() { t.Skipf("skipping: ssh unsupported by none") } - want := profile+"\n" + want := profile + "\n" var rr *RunResult var err error if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! - minikube ssh --% "echo $(pwd)" - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "--%", "cat /etc/hostname", true) + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "--%", "cat /etc/hostname"), true) } else { rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/hostname")) } From 65bc343990df1baec8db12fa652943308cf1ea61 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 25 May 2020 16:58:50 -0700 Subject: [PATCH 08/51] try again --- test/integration/functional_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 644cad72f2..7fead16a52 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -840,7 +840,11 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { var rr *RunResult var err error if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "--%", "cat /etc/hostname"), true) + cmd := exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "--%", "cat /etc/hostname") + t.Logf("about to run %s: ", cmd.Args) + rr, err = Run(t, cmd, true) + t.Logf("rr is %+v: \n", rr) + t.Logf("err is %v: \n", err) } else { rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/hostname")) } From 8a425f85db7dc645f4b240b7f4bf04a73ebed7ab Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 25 May 2020 17:33:54 -0700 Subject: [PATCH 09/51] try again --- test/integration/functional_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 7fead16a52..2317499bc4 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -840,7 +840,7 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { var rr *RunResult var err error if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! - cmd := exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "--%", "cat /etc/hostname") + cmd := exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/hostname") t.Logf("about to run %s: ", cmd.Args) rr, err = Run(t, cmd, true) t.Logf("rr is %+v: \n", rr) From 73150f9fdfabf0af49e40c5ddab3cf0a3b0f978e Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 25 May 2020 17:38:33 -0700 Subject: [PATCH 10/51] try all args in one string for powershell --- test/integration/functional_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 2317499bc4..e435dba850 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -840,7 +840,7 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { var rr *RunResult var err error if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! - cmd := exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/hostname") + cmd := exec.CommandContext(ctx, Target(), "-p profile ssh cat /etc/hostname") t.Logf("about to run %s: ", cmd.Args) rr, err = Run(t, cmd, true) t.Logf("rr is %+v: \n", rr) From 7109ef5f5b7963963091c60feaddb9b2f0ea6c7a Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 25 May 2020 17:56:15 -0700 Subject: [PATCH 11/51] try again --- test/integration/functional_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index e435dba850..9c84c1cab5 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -840,7 +840,7 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { var rr *RunResult var err error if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! - cmd := exec.CommandContext(ctx, Target(), "-p profile ssh cat /etc/hostname") + cmd := exec.CommandContext(ctx, Target(), " -p "+profile+" ssh cat /etc/hostname") t.Logf("about to run %s: ", cmd.Args) rr, err = Run(t, cmd, true) t.Logf("rr is %+v: \n", rr) From 502c79be45a6c5671669b4b74e1ca49f895a09eb Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 25 May 2020 19:53:41 -0700 Subject: [PATCH 12/51] fix mount test for powershell --- test/integration/fn_mount_cmd.go | 22 +++++++++++++++++++--- test/integration/functional_test.go | 2 +- test/integration/helpers.go | 27 +++++++++++++++++++++------ 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/test/integration/fn_mount_cmd.go b/test/integration/fn_mount_cmd.go index f6e218d8a4..3cfa797c28 100644 --- a/test/integration/fn_mount_cmd.go +++ b/test/integration/fn_mount_cmd.go @@ -65,15 +65,27 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { ctx, cancel := context.WithTimeout(ctx, Minutes(10)) args := []string{"mount", "-p", profile, fmt.Sprintf("%s:%s", tempDir, guestMount), "--alsologtostderr", "-v=1"} - ss, err := Start(t, exec.CommandContext(ctx, Target(), args...)) + var ss *StartSession + var err error + if runtime.GOOS == "windows" { + ss, err = Start(t, exec.CommandContext(ctx, Target(), args...), true) + } else { + ss, err = Start(t, exec.CommandContext(ctx, Target(), args...)) + } if err != nil { t.Fatalf("%v failed: %v", args, err) } defer func() { + var rr *RunResult + var err error if t.Failed() { t.Logf("%q failed, getting debug info...", t.Name()) - rr, err := Run(t, exec.Command(Target(), "-p", profile, "ssh", "mount | grep 9p; ls -la /mount-9p; cat /mount-9p/pod-dates")) + if runtime.GOOS == "windows" { + rr, err = Run(t, exec.Command(Target(), "-p", profile, "ssh", "mount | grep 9p; ls -la /mount-9p; cat /mount-9p/pod-dates"), true) + } else { + rr, err = Run(t, exec.Command(Target(), "-p", profile, "ssh", "mount | grep 9p; ls -la /mount-9p; cat /mount-9p/pod-dates")) + } if err != nil { t.Logf("debugging command %q failed : %v", rr.Command(), err) } else { @@ -82,7 +94,11 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { } // Cleanup in advance of future tests - rr, err := Run(t, exec.Command(Target(), "-p", profile, "ssh", "sudo umount -f /mount-9p")) + if runtime.GOOS == "windows" { + rr, err = Run(t, exec.Command(Target(), "-p", profile, "ssh", "sudo umount -f /mount-9p"), true) + } else { + rr, err = Run(t, exec.Command(Target(), "-p", profile, "ssh", "sudo umount -f /mount-9p")) + } if err != nil { t.Logf("%q: %v", rr.Command(), err) } diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 9c84c1cab5..638b690fe3 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -840,7 +840,7 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { var rr *RunResult var err error if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! - cmd := exec.CommandContext(ctx, Target(), " -p "+profile+" ssh cat /etc/hostname") + cmd := exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat", "/etc/hostname") t.Logf("about to run %s: ", cmd.Args) rr, err = Run(t, cmd, true) t.Logf("rr is %+v: \n", rr) diff --git a/test/integration/helpers.go b/test/integration/helpers.go index a432d5fe47..9edce41451 100644 --- a/test/integration/helpers.go +++ b/test/integration/helpers.go @@ -136,21 +136,36 @@ type StartSession struct { } // Start starts a process in the background, streaming output -func Start(t *testing.T, cmd *exec.Cmd) (*StartSession, error) { +func Start(t *testing.T, cmd *exec.Cmd, powershell ...bool) (*StartSession, error) { t.Helper() t.Logf("(dbg) daemon: %v", cmd.Args) - stdoutPipe, err := cmd.StdoutPipe() + isPowershell := false + if len(powershell) > 0 { + isPowershell = powershell[0] + } + + newCmd := cmd + if isPowershell { + psBin, err := exec.LookPath("powershell.exe") + if err != nil { + return nil, err + } + args := append([]string{"-NoProfile", "-NonInteractive"}, cmd.Args...) + newCmd = exec.Command(psBin, args...) + } + + stdoutPipe, err := newCmd.StdoutPipe() if err != nil { - t.Fatalf("stdout pipe failed: %v %v", cmd.Args, err) + t.Fatalf("stdout pipe failed: %v %v", newCmd.Args, err) } stderrPipe, err := cmd.StderrPipe() if err != nil { - t.Fatalf("stderr pipe failed: %v %v", cmd.Args, err) + t.Fatalf("stderr pipe failed: %v %v", newCmd.Args, err) } - sr := &StartSession{Stdout: bufio.NewReader(stdoutPipe), Stderr: bufio.NewReader(stderrPipe), cmd: cmd} - return sr, cmd.Start() + sr := &StartSession{Stdout: bufio.NewReader(stdoutPipe), Stderr: bufio.NewReader(stderrPipe), cmd: newCmd} + return sr, newCmd.Start() } // Stop stops the started process From 978fceb63b99188f9ff34aad02eb0aa27915be6c Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 25 May 2020 19:58:28 -0700 Subject: [PATCH 13/51] fix cache_reload test --- test/integration/functional_test.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 638b690fe3..7afb607cfc 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -514,7 +514,14 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) { }) t.Run("verify_cache_inside_node", func(t *testing.T) { - rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo", "crictl", "images")) + var rr *RunResult + var err error + if runtime.GOOS == "windows" { + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo", "crictl", "images"), true) + } else { + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo", "crictl", "images")) + } + if err != nil { t.Errorf("failed to get images by %q ssh %v", rr.Command(), err) } @@ -527,7 +534,14 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) { t.Run("cache_reload", func(t *testing.T) { // deleting image inside minikube node manually and expecting reload to bring it back img := "busybox:latest" // deleting image inside minikube node manually - rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo", "docker", "rmi", img)) // for some reason crictl rmi doesn't work + var rr *RunResult + var err error + if runtime.GOOS == "windows" { + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo", "docker", "rmi", img), true) // for some reason crictl rmi doesn't work + } else { + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo", "docker", "rmi", img)) + } + if err != nil { t.Errorf("failed to delete inside the node %q : %v", rr.Command(), err) } From 8ef8cad40e1f9761132abc661f593ee534544640 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 25 May 2020 20:16:56 -0700 Subject: [PATCH 14/51] fix mount cmd powershell test --- test/integration/fn_mount_cmd.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/integration/fn_mount_cmd.go b/test/integration/fn_mount_cmd.go index 3cfa797c28..08c8b3d3c5 100644 --- a/test/integration/fn_mount_cmd.go +++ b/test/integration/fn_mount_cmd.go @@ -43,7 +43,7 @@ const ( createdByPodRemovedByTest = "created-by-pod-removed-by-test" ) -func validateMountCmd(ctx context.Context, t *testing.T, profile string) { +func validateMountCmd(ctx context.Context, t *testing.T, profile string) { //nolint cyclomatic complexity 33 of func `validateMountCmd` is high (> 30 if NoneDriver() { t.Skip("skipping: none driver does not support mount") } @@ -66,7 +66,6 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { args := []string{"mount", "-p", profile, fmt.Sprintf("%s:%s", tempDir, guestMount), "--alsologtostderr", "-v=1"} var ss *StartSession - var err error if runtime.GOOS == "windows" { ss, err = Start(t, exec.CommandContext(ctx, Target(), args...), true) } else { From b773fb4a4be8e57bb47fe10effd00022571686ec Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 25 May 2020 21:03:44 -0700 Subject: [PATCH 15/51] skip mount test on windows --- test/integration/fn_mount_cmd.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/integration/fn_mount_cmd.go b/test/integration/fn_mount_cmd.go index 08c8b3d3c5..3fe7ae60d1 100644 --- a/test/integration/fn_mount_cmd.go +++ b/test/integration/fn_mount_cmd.go @@ -51,6 +51,10 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { //nol t.Skip("skipping: mount broken on hyperv: https://github.com/kubernetes/minikube/issues/5029") } + if runtime.GOOS == "windows" { + t.Skip("skipping: mount broken on windows: https://github.com/kubernetes/minikube/issues/8271") + } + tempDir, err := ioutil.TempDir("", "mounttest") defer func() { //clean up tempdir err := os.RemoveAll(tempDir) @@ -62,14 +66,14 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { //nol t.Fatalf("Unexpected error while creating tempDir: %v", err) } - ctx, cancel := context.WithTimeout(ctx, Minutes(10)) + mctx, cancel := context.WithTimeout(ctx, Minutes(10)) args := []string{"mount", "-p", profile, fmt.Sprintf("%s:%s", tempDir, guestMount), "--alsologtostderr", "-v=1"} var ss *StartSession if runtime.GOOS == "windows" { - ss, err = Start(t, exec.CommandContext(ctx, Target(), args...), true) + ss, err = Start(t, exec.CommandContext(mctx, Target(), args...), true) } else { - ss, err = Start(t, exec.CommandContext(ctx, Target(), args...)) + ss, err = Start(t, exec.CommandContext(mctx, Target(), args...)) } if err != nil { t.Fatalf("%v failed: %v", args, err) From e9e53745de3fea33b6b91bfbf251616afd2001ac Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 25 May 2020 21:11:52 -0700 Subject: [PATCH 16/51] skipping for now --- test/integration/functional_test.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 7afb607cfc..7c98d73bcb 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -517,7 +517,7 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) { var rr *RunResult var err error if runtime.GOOS == "windows" { - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo", "crictl", "images"), true) + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo crictl images"), true) } else { rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo", "crictl", "images")) } @@ -537,7 +537,7 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) { var rr *RunResult var err error if runtime.GOOS == "windows" { - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo", "docker", "rmi", img), true) // for some reason crictl rmi doesn't work + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo docker rmi "+img), true) // for some reason crictl rmi doesn't work } else { rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo", "docker", "rmi", img)) } @@ -972,6 +972,10 @@ func validateFileSync(ctx context.Context, t *testing.T, profile string) { t.Skipf("skipping: ssh unsupported by none") } + if runtime.GOOS == "windows" { + t.Skipf("skipping for windows for now :(") + } + vp := vmSyncTestPath() t.Logf("Checking for existence of %s within VM", vp) rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", fmt.Sprintf("sudo cat %s", vp))) @@ -999,6 +1003,10 @@ func validateCertSync(ctx context.Context, t *testing.T, profile string) { t.Skipf("skipping: ssh unsupported by none") } + if runtime.GOOS == "windows" { + t.Skipf("skipping for windows for now :(") + } + want, err := ioutil.ReadFile("./testdata/minikube_test.pem") if err != nil { t.Errorf("test file not found: %v", err) From fad43627ad6b3e160fe0f20bdf5bf1c2ea26f05c Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 25 May 2020 21:47:54 -0700 Subject: [PATCH 17/51] skipping more tests for now --- test/integration/functional_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 7c98d73bcb..d18bc3595d 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -514,6 +514,10 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) { }) t.Run("verify_cache_inside_node", func(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skipf("skipping: skipping for now") + } + var rr *RunResult var err error if runtime.GOOS == "windows" { @@ -532,6 +536,10 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) { }) t.Run("cache_reload", func(t *testing.T) { // deleting image inside minikube node manually and expecting reload to bring it back + if runtime.GOOS == "windows" { + t.Skipf("skipping: skipping for now") + } + img := "busybox:latest" // deleting image inside minikube node manually var rr *RunResult From a4d9a5bc051347924c8694a17b3e523dfabe7693 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 25 May 2020 21:51:06 -0700 Subject: [PATCH 18/51] try --- test/integration/functional_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index d18bc3595d..e91a24b217 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -862,13 +862,13 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { var rr *RunResult var err error if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! - cmd := exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat", "/etc/hostname") + cmd := exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/hostname") t.Logf("about to run %s: ", cmd.Args) rr, err = Run(t, cmd, true) t.Logf("rr is %+v: \n", rr) t.Logf("err is %v: \n", err) } else { - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/hostname")) + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "\"cat /etc/hostname\"")) } if ctx.Err() == context.DeadlineExceeded { t.Logf("failed to run command by deadline. exceeded timeout : %s", rr.Command()) From 7ab632a0406947214d1c5526db5dde37e581b2d2 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 May 2020 14:47:21 -0700 Subject: [PATCH 19/51] add qutation mark --- test/integration/functional_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index e91a24b217..9a6dddaf75 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -862,13 +862,13 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { var rr *RunResult var err error if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! - cmd := exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/hostname") + cmd := exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "\"cat /etc/hostname\"") t.Logf("about to run %s: ", cmd.Args) rr, err = Run(t, cmd, true) t.Logf("rr is %+v: \n", rr) t.Logf("err is %v: \n", err) } else { - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "\"cat /etc/hostname\"")) + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/hostname")) } if ctx.Err() == context.DeadlineExceeded { t.Logf("failed to run command by deadline. exceeded timeout : %s", rr.Command()) From 56d11a907ed6a79edf7b8209fcaeed77e76fee37 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 May 2020 15:31:34 -0700 Subject: [PATCH 20/51] refactor --- test/integration/fn_mount_cmd.go | 18 +++------------ test/integration/functional_test.go | 19 ++++----------- test/integration/helpers.go | 36 +++++++++++++---------------- 3 files changed, 24 insertions(+), 49 deletions(-) diff --git a/test/integration/fn_mount_cmd.go b/test/integration/fn_mount_cmd.go index 3fe7ae60d1..8fb9d1cc9c 100644 --- a/test/integration/fn_mount_cmd.go +++ b/test/integration/fn_mount_cmd.go @@ -70,11 +70,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { //nol args := []string{"mount", "-p", profile, fmt.Sprintf("%s:%s", tempDir, guestMount), "--alsologtostderr", "-v=1"} var ss *StartSession - if runtime.GOOS == "windows" { - ss, err = Start(t, exec.CommandContext(mctx, Target(), args...), true) - } else { - ss, err = Start(t, exec.CommandContext(mctx, Target(), args...)) - } + ss, err = Start(t, exec.CommandContext(mctx, Target(), args...)) if err != nil { t.Fatalf("%v failed: %v", args, err) } @@ -84,11 +80,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { //nol var err error if t.Failed() { t.Logf("%q failed, getting debug info...", t.Name()) - if runtime.GOOS == "windows" { - rr, err = Run(t, exec.Command(Target(), "-p", profile, "ssh", "mount | grep 9p; ls -la /mount-9p; cat /mount-9p/pod-dates"), true) - } else { - rr, err = Run(t, exec.Command(Target(), "-p", profile, "ssh", "mount | grep 9p; ls -la /mount-9p; cat /mount-9p/pod-dates")) - } + rr, err = Run(t, exec.Command(Target(), "-p", profile, "ssh", "mount | grep 9p; ls -la /mount-9p; cat /mount-9p/pod-dates")) if err != nil { t.Logf("debugging command %q failed : %v", rr.Command(), err) } else { @@ -97,11 +89,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { //nol } // Cleanup in advance of future tests - if runtime.GOOS == "windows" { - rr, err = Run(t, exec.Command(Target(), "-p", profile, "ssh", "sudo umount -f /mount-9p"), true) - } else { - rr, err = Run(t, exec.Command(Target(), "-p", profile, "ssh", "sudo umount -f /mount-9p")) - } + rr, err = Run(t, exec.Command(Target(), "-p", profile, "ssh", "sudo umount -f /mount-9p")) if err != nil { t.Logf("%q: %v", rr.Command(), err) } diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 9a6dddaf75..9705b95d65 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -161,7 +161,7 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { var err error if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! c := exec.CommandContext(mctx, Target(), "-p "+profile+" docker-env | Invoke-Expression ;"+Target()+" status -p "+profile) - rr, err = Run(t, c, true) // golang exec powershell needs some tricks ! + rr, err = Run(t, c) // golang exec powershell needs some tricks ! } else { c := exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" docker-env) && "+Target()+" status -p "+profile) // we should be able to get minikube status with a bash which evaled docker-env @@ -182,7 +182,7 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { // do a eval $(minikube -p profile docker-env) and check if we are point to docker inside minikube if runtime.GOOS == "windows" { // testing docker-env eval in powershell c := exec.CommandContext(mctx, Target(), "-p "+profile+" docker-env | Invoke-Expression ; docker images") - rr, err = Run(t, c, true) // golang exec powershell needs some tricks ! + rr, err = Run(t, c) // golang exec powershell needs some tricks ! } else { c := exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" docker-env) && docker images") rr, err = Run(t, c) @@ -520,12 +520,7 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) { var rr *RunResult var err error - if runtime.GOOS == "windows" { - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo crictl images"), true) - } else { - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo", "crictl", "images")) - } - + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo", "crictl", "images")) if err != nil { t.Errorf("failed to get images by %q ssh %v", rr.Command(), err) } @@ -544,11 +539,7 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) { // deleting image inside minikube node manually var rr *RunResult var err error - if runtime.GOOS == "windows" { - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo docker rmi "+img), true) // for some reason crictl rmi doesn't work - } else { - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo", "docker", "rmi", img)) - } + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo", "docker", "rmi", img)) if err != nil { t.Errorf("failed to delete inside the node %q : %v", rr.Command(), err) @@ -864,7 +855,7 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! cmd := exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "\"cat /etc/hostname\"") t.Logf("about to run %s: ", cmd.Args) - rr, err = Run(t, cmd, true) + rr, err = Run(t, cmd) t.Logf("rr is %+v: \n", rr) t.Logf("err is %v: \n", err) } else { diff --git a/test/integration/helpers.go b/test/integration/helpers.go index 9edce41451..5940301f9f 100644 --- a/test/integration/helpers.go +++ b/test/integration/helpers.go @@ -29,11 +29,13 @@ import ( "fmt" "io/ioutil" "os/exec" + "runtime" "strings" "testing" "time" "github.com/docker/machine/libmachine/state" + "github.com/pkg/errors" "github.com/shirou/gopsutil/process" core "k8s.io/api/core/v1" meta "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -86,25 +88,22 @@ func (rr RunResult) Output() string { } // Run is a test helper to log a command being executed \_(ツ)_/¯ -func Run(t *testing.T, cmd *exec.Cmd, powershell ...bool) (*RunResult, error) { +func Run(t *testing.T, cmd *exec.Cmd) (*RunResult, error) { t.Helper() - isPowershell := false - if len(powershell) > 0 { - isPowershell = powershell[0] - } - newCmd := cmd - if isPowershell { + var newCmd *exec.Cmd + if runtime.GOOS == "windows" { psBin, err := exec.LookPath("powershell.exe") if err != nil { - return &RunResult{}, err + return &RunResult{}, errors.Wrapf(err, "lookup powershell") } args := append([]string{"-NoProfile", "-NonInteractive"}, cmd.Args...) newCmd = exec.Command(psBin, args...) - + } else { + newCmd = cmd } - rr := &RunResult{Args: newCmd.Args} + rr := &RunResult{Args: cmd.Args} t.Logf("(dbg) Run: %v", rr.Command()) @@ -136,30 +135,27 @@ type StartSession struct { } // Start starts a process in the background, streaming output -func Start(t *testing.T, cmd *exec.Cmd, powershell ...bool) (*StartSession, error) { +func Start(t *testing.T, cmd *exec.Cmd) (*StartSession, error) { t.Helper() t.Logf("(dbg) daemon: %v", cmd.Args) - isPowershell := false - if len(powershell) > 0 { - isPowershell = powershell[0] - } - - newCmd := cmd - if isPowershell { + var newCmd *exec.Cmd + if runtime.GOOS == "windows" { psBin, err := exec.LookPath("powershell.exe") if err != nil { - return nil, err + return &StartSession{}, errors.Wrapf(err, "lookup powershell") } args := append([]string{"-NoProfile", "-NonInteractive"}, cmd.Args...) newCmd = exec.Command(psBin, args...) + } else { + newCmd = cmd } stdoutPipe, err := newCmd.StdoutPipe() if err != nil { t.Fatalf("stdout pipe failed: %v %v", newCmd.Args, err) } - stderrPipe, err := cmd.StderrPipe() + stderrPipe, err := newCmd.StderrPipe() if err != nil { t.Fatalf("stderr pipe failed: %v %v", newCmd.Args, err) } From f16ed7c650f9f2639e6bcd007057b07ee4b3ea85 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 May 2020 16:52:34 -0700 Subject: [PATCH 21/51] pass env to run cnmd --- test/integration/helpers.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/integration/helpers.go b/test/integration/helpers.go index 5940301f9f..ff2cc82498 100644 --- a/test/integration/helpers.go +++ b/test/integration/helpers.go @@ -99,6 +99,9 @@ func Run(t *testing.T, cmd *exec.Cmd) (*RunResult, error) { } args := append([]string{"-NoProfile", "-NonInteractive"}, cmd.Args...) newCmd = exec.Command(psBin, args...) + newCmd.Stdout = cmd.Stdout + newCmd.Stderr = cmd.Stderr + newCmd.Env = cmd.Env } else { newCmd = cmd } @@ -147,6 +150,9 @@ func Start(t *testing.T, cmd *exec.Cmd) (*StartSession, error) { } args := append([]string{"-NoProfile", "-NonInteractive"}, cmd.Args...) newCmd = exec.Command(psBin, args...) + newCmd.Stdout = cmd.Stdout + newCmd.Stderr = cmd.Stderr + newCmd.Env = cmd.Env } else { newCmd = cmd } From 1924599bbe31a0d7ac9e617e7947f4e0419fd279 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 May 2020 17:16:26 -0700 Subject: [PATCH 22/51] fix the test for none --- test/integration/addons_test.go | 46 ++------------------------------- 1 file changed, 2 insertions(+), 44 deletions(-) diff --git a/test/integration/addons_test.go b/test/integration/addons_test.go index d7f39ee001..d05fbd1a3c 100644 --- a/test/integration/addons_test.go +++ b/test/integration/addons_test.go @@ -40,7 +40,7 @@ func TestAddons(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), Minutes(40)) defer Cleanup(t, profile, cancel) - args := append([]string{"start", "-p", profile, "--wait=false", "--memory=2600", "--alsologtostderr", "--addons=ingress", "--addons=registry", "--addons=metrics-server", "--addons=helm-tiller"}, StartArgs()...) + args := append([]string{"start", "-p", profile, "--wait=false", "--memory=2600", "--alsologtostderr", "--addons=ingress", "--addons=registry", "--addons=metrics-server", "--addons=helm-tiller", "--addons=olm"}, StartArgs()...) rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) if err != nil { t.Fatalf("%s failed: %v", rr.Command(), err) @@ -56,6 +56,7 @@ func TestAddons(t *testing.T) { {"Ingress", validateIngressAddon}, {"MetricsServer", validateMetricsServerAddon}, {"HelmTiller", validateHelmTillerAddon}, + {"Olm", validateOlmAddon} } for _, tc := range tests { tc := tc @@ -329,49 +330,6 @@ func validateHelmTillerAddon(ctx context.Context, t *testing.T, profile string) } } -func TestOlmAddon(t *testing.T) { - profile := UniqueProfileName("addons") - ctx, cancel := context.WithTimeout(context.Background(), Minutes(40)) - defer Cleanup(t, profile, cancel) - - args := append([]string{"start", "-p", profile, "--wait=false", "--memory=2600", "--alsologtostderr", "--addons=olm"}, StartArgs()...) - rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) - if err != nil { - t.Fatalf("%s failed: %v", rr.Command(), err) - } - - // Parallelized tests - t.Run("parallel", func(t *testing.T) { - tests := []struct { - name string - validator validateFunc - }{ - {"Olm", validateOlmAddon}, - } - for _, tc := range tests { - tc := tc - t.Run(tc.name, func(t *testing.T) { - MaybeParallel(t) - tc.validator(ctx, t, profile) - }) - } - }) - - // Assert that disable/enable works offline - rr, err = Run(t, exec.CommandContext(ctx, Target(), "stop", "-p", profile)) - if err != nil { - t.Errorf("failed to stop minikube. args %q : %v", rr.Command(), err) - } - rr, err = Run(t, exec.CommandContext(ctx, Target(), "addons", "enable", "dashboard", "-p", profile)) - if err != nil { - t.Errorf("failed to enable dashboard addon: args %q : %v", rr.Command(), err) - } - rr, err = Run(t, exec.CommandContext(ctx, Target(), "addons", "disable", "dashboard", "-p", profile)) - if err != nil { - t.Errorf("failed to disable dashboard addon: args %q : %v", rr.Command(), err) - } -} - func validateOlmAddon(ctx context.Context, t *testing.T, profile string) { defer PostMortemLogs(t, profile) From 2b37774587a44aa9e29eb6d54684d7aff4360f58 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 May 2020 17:25:27 -0700 Subject: [PATCH 23/51] missing comma --- test/integration/addons_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/addons_test.go b/test/integration/addons_test.go index d05fbd1a3c..0fdaae895d 100644 --- a/test/integration/addons_test.go +++ b/test/integration/addons_test.go @@ -56,7 +56,7 @@ func TestAddons(t *testing.T) { {"Ingress", validateIngressAddon}, {"MetricsServer", validateMetricsServerAddon}, {"HelmTiller", validateHelmTillerAddon}, - {"Olm", validateOlmAddon} + {"Olm", validateOlmAddon}, } for _, tc := range tests { tc := tc From 122fcf1d6f730cb6abc23f3ee975bbc05a8f065a Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 May 2020 18:03:37 -0700 Subject: [PATCH 24/51] revert unrelated changes --- test/integration/fn_mount_cmd.go | 13 ++++++------- test/integration/helpers.go | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/test/integration/fn_mount_cmd.go b/test/integration/fn_mount_cmd.go index 8fb9d1cc9c..86e1de1339 100644 --- a/test/integration/fn_mount_cmd.go +++ b/test/integration/fn_mount_cmd.go @@ -51,6 +51,8 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { //nol t.Skip("skipping: mount broken on hyperv: https://github.com/kubernetes/minikube/issues/5029") } + t.Logf("runtime is %q", runtime.GOOS) + if runtime.GOOS == "windows" { t.Skip("skipping: mount broken on windows: https://github.com/kubernetes/minikube/issues/8271") } @@ -66,21 +68,18 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { //nol t.Fatalf("Unexpected error while creating tempDir: %v", err) } - mctx, cancel := context.WithTimeout(ctx, Minutes(10)) + mctx, cancel := context.WithTimeout(ctx, Minutes(3)) args := []string{"mount", "-p", profile, fmt.Sprintf("%s:%s", tempDir, guestMount), "--alsologtostderr", "-v=1"} - var ss *StartSession - ss, err = Start(t, exec.CommandContext(mctx, Target(), args...)) + ss, err := Start(t, exec.CommandContext(mctx, Target(), args...)) if err != nil { t.Fatalf("%v failed: %v", args, err) } defer func() { - var rr *RunResult - var err error if t.Failed() { t.Logf("%q failed, getting debug info...", t.Name()) - rr, err = Run(t, exec.Command(Target(), "-p", profile, "ssh", "mount | grep 9p; ls -la /mount-9p; cat /mount-9p/pod-dates")) + rr, err := Run(t, exec.Command(Target(), "-p", profile, "ssh", "mount | grep 9p; ls -la /mount-9p; cat /mount-9p/pod-dates")) if err != nil { t.Logf("debugging command %q failed : %v", rr.Command(), err) } else { @@ -89,7 +88,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { //nol } // Cleanup in advance of future tests - rr, err = Run(t, exec.Command(Target(), "-p", profile, "ssh", "sudo umount -f /mount-9p")) + rr, err := Run(t, exec.Command(Target(), "-p", profile, "ssh", "sudo umount -f /mount-9p")) if err != nil { t.Logf("%q: %v", rr.Command(), err) } diff --git a/test/integration/helpers.go b/test/integration/helpers.go index ff2cc82498..ae135409e1 100644 --- a/test/integration/helpers.go +++ b/test/integration/helpers.go @@ -97,7 +97,7 @@ func Run(t *testing.T, cmd *exec.Cmd) (*RunResult, error) { if err != nil { return &RunResult{}, errors.Wrapf(err, "lookup powershell") } - args := append([]string{"-NoProfile", "-NonInteractive"}, cmd.Args...) + args := append([]string{"-NoProfile", "-NonInteractive", "--%"}, cmd.Args...) newCmd = exec.Command(psBin, args...) newCmd.Stdout = cmd.Stdout newCmd.Stderr = cmd.Stderr @@ -106,7 +106,7 @@ func Run(t *testing.T, cmd *exec.Cmd) (*RunResult, error) { newCmd = cmd } - rr := &RunResult{Args: cmd.Args} + rr := &RunResult{Args: newCmd.Args} t.Logf("(dbg) Run: %v", rr.Command()) @@ -148,7 +148,7 @@ func Start(t *testing.T, cmd *exec.Cmd) (*StartSession, error) { if err != nil { return &StartSession{}, errors.Wrapf(err, "lookup powershell") } - args := append([]string{"-NoProfile", "-NonInteractive"}, cmd.Args...) + args := append([]string{"-NoProfile", "-NonInteractive", "--%"}, cmd.Args...) newCmd = exec.Command(psBin, args...) newCmd.Stdout = cmd.Stdout newCmd.Stderr = cmd.Stderr From 88b67202493175f75f60ede87b98ab6dd979db9d Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 May 2020 18:04:03 -0700 Subject: [PATCH 25/51] log --- test/integration/fn_mount_cmd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/fn_mount_cmd.go b/test/integration/fn_mount_cmd.go index 86e1de1339..178fa9c5aa 100644 --- a/test/integration/fn_mount_cmd.go +++ b/test/integration/fn_mount_cmd.go @@ -51,7 +51,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { //nol t.Skip("skipping: mount broken on hyperv: https://github.com/kubernetes/minikube/issues/5029") } - t.Logf("runtime is %q", runtime.GOOS) + t.Logf("runtime is %q\n", runtime.GOOS) if runtime.GOOS == "windows" { t.Skip("skipping: mount broken on windows: https://github.com/kubernetes/minikube/issues/8271") From 4fa66132f29287e269e88a7d1ab4968e2eac9f26 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 May 2020 18:21:40 -0700 Subject: [PATCH 26/51] fix all contexts --- test/integration/fn_mount_cmd.go | 12 ++++++------ test/integration/fn_pvc.go | 10 +++++----- test/integration/fn_tunnel_cmd.go | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/test/integration/fn_mount_cmd.go b/test/integration/fn_mount_cmd.go index 178fa9c5aa..48671a0be3 100644 --- a/test/integration/fn_mount_cmd.go +++ b/test/integration/fn_mount_cmd.go @@ -113,7 +113,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { //nol // Block until the mount succeeds to avoid file race checkMount := func() error { - _, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "findmnt -T /mount-9p | grep 9p")) + _, err := Run(t, exec.CommandContext(mctx, Target(), "-p", profile, "ssh", "findmnt -T /mount-9p | grep 9p")) return err } @@ -127,7 +127,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { //nol } // Assert that we can access the mount without an error. Display for debugging. - rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "--", "ls", "-la", guestMount)) + rr, err := Run(t, exec.CommandContext(mctx, Target(), "-p", profile, "ssh", "--", "ls", "-la", guestMount)) if err != nil { t.Fatalf("failed verifying accessing to the mount. args %q : %v", rr.Command(), err) } @@ -135,7 +135,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { //nol // Assert that the mount contains our unique test marker, as opposed to a stale mount tp := filepath.Join("/mount-9p", testMarker) - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat", tp)) + rr, err = Run(t, exec.CommandContext(mctx, Target(), "-p", profile, "ssh", "cat", tp)) if err != nil { t.Fatalf("failed to verify the mount contains unique test marked: args %q: %v", rr.Command(), err) } @@ -146,12 +146,12 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { //nol } // Start the "busybox-mount" pod. - rr, err = Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "replace", "--force", "-f", filepath.Join(*testdataDir, "busybox-mount-test.yaml"))) + rr, err = Run(t, exec.CommandContext(mctx, "kubectl", "--context", profile, "replace", "--force", "-f", filepath.Join(*testdataDir, "busybox-mount-test.yaml"))) if err != nil { t.Fatalf("failed to 'kubectl replace' for busybox-mount-test. args %q : %v", rr.Command(), err) } - if _, err := PodWait(ctx, t, profile, "default", "integration-test=busybox-mount", Minutes(4)); err != nil { + if _, err := PodWait(mctx, t, profile, "default", "integration-test=busybox-mount", Minutes(4)); err != nil { t.Fatalf("failed waiting for busybox-mount pod: %v", err) } @@ -167,7 +167,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { //nol } // test that file written from host was read in by the pod via cat /mount-9p/written-by-host; - rr, err = Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "logs", "busybox-mount")) + rr, err = Run(t, exec.CommandContext(mctx, "kubectl", "--context", profile, "logs", "busybox-mount")) if err != nil { t.Errorf("failed to get kubectl logs for busybox-mount. args %q : %v", rr.Command(), err) } diff --git a/test/integration/fn_pvc.go b/test/integration/fn_pvc.go index 18f573d3bd..5e6421d4fe 100644 --- a/test/integration/fn_pvc.go +++ b/test/integration/fn_pvc.go @@ -36,15 +36,15 @@ import ( func validatePersistentVolumeClaim(ctx context.Context, t *testing.T, profile string) { defer PostMortemLogs(t, profile) - ctx, cancel := context.WithTimeout(ctx, Minutes(10)) + mctx, cancel := context.WithTimeout(ctx, Minutes(10)) defer cancel() - if _, err := PodWait(ctx, t, profile, "kube-system", "integration-test=storage-provisioner", Minutes(4)); err != nil { + if _, err := PodWait(mctx, t, profile, "kube-system", "integration-test=storage-provisioner", Minutes(4)); err != nil { t.Fatalf("failed waiting for storage-provisioner: %v", err) } checkStorageClass := func() error { - rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "get", "storageclass", "-o=json")) + rr, err := Run(t, exec.CommandContext(mctx, "kubectl", "--context", profile, "get", "storageclass", "-o=json")) if err != nil { return err } @@ -64,13 +64,13 @@ func validatePersistentVolumeClaim(ctx context.Context, t *testing.T, profile st } // Now create a testpvc - rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "apply", "-f", filepath.Join(*testdataDir, "pvc.yaml"))) + rr, err := Run(t, exec.CommandContext(mctx, "kubectl", "--context", profile, "apply", "-f", filepath.Join(*testdataDir, "pvc.yaml"))) if err != nil { t.Fatalf("kubectl apply pvc.yaml failed: args %q: %v", rr.Command(), err) } checkStoragePhase := func() error { - rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "get", "pvc", "testpvc", "-o=json")) + rr, err := Run(t, exec.CommandContext(mctx, "kubectl", "--context", profile, "get", "pvc", "testpvc", "-o=json")) if err != nil { return err } diff --git a/test/integration/fn_tunnel_cmd.go b/test/integration/fn_tunnel_cmd.go index e990b02778..8ea153fd10 100644 --- a/test/integration/fn_tunnel_cmd.go +++ b/test/integration/fn_tunnel_cmd.go @@ -49,7 +49,7 @@ var ( ) func validateTunnelCmd(ctx context.Context, t *testing.T, profile string) { - ctx, cancel := context.WithTimeout(ctx, Minutes(20)) + mctx, cancel := context.WithTimeout(ctx, Minutes(5)) type validateFunc func(context.Context, *testing.T, string) defer cancel() @@ -70,7 +70,7 @@ func validateTunnelCmd(ctx context.Context, t *testing.T, profile string) { for _, tc := range tests { tc := tc t.Run(tc.name, func(t *testing.T) { - tc.validator(ctx, t, profile) + tc.validator(mctx, t, profile) }) } }) From a98bdd5d60efc598bddca8c389a3af5e1d62ddf1 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 May 2020 18:38:14 -0700 Subject: [PATCH 27/51] try without %-- --- test/integration/fn_tunnel_cmd.go | 1 - test/integration/functional_test.go | 4 ++-- test/integration/helpers.go | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/test/integration/fn_tunnel_cmd.go b/test/integration/fn_tunnel_cmd.go index 8ea153fd10..1efe109b0c 100644 --- a/test/integration/fn_tunnel_cmd.go +++ b/test/integration/fn_tunnel_cmd.go @@ -117,7 +117,6 @@ func getKubeDNSIP(t *testing.T, profile string) string { // validateTunnelStart starts `minikube tunnel` func validateTunnelStart(ctx context.Context, t *testing.T, profile string) { checkRoutePassword(t) - args := []string{"-p", profile, "tunnel", "--alsologtostderr"} ss, err := Start(t, exec.CommandContext(ctx, Target(), args...)) if err != nil { diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 9705b95d65..2606d5881a 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -160,7 +160,7 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { var rr *RunResult var err error if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! - c := exec.CommandContext(mctx, Target(), "-p "+profile+" docker-env | Invoke-Expression ;"+Target()+" status -p "+profile) + c := exec.CommandContext(mctx, Target()+" -p "+profile+" docker-env | Invoke-Expression ;"+Target()+" status -p "+profile) rr, err = Run(t, c) // golang exec powershell needs some tricks ! } else { c := exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" docker-env) && "+Target()+" status -p "+profile) @@ -853,7 +853,7 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { var rr *RunResult var err error if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! - cmd := exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "\"cat /etc/hostname\"") + cmd := exec.CommandContext(ctx, Target()+" -p "+profile+" ssh \"cat /etc/hostname\"") t.Logf("about to run %s: ", cmd.Args) rr, err = Run(t, cmd) t.Logf("rr is %+v: \n", rr) diff --git a/test/integration/helpers.go b/test/integration/helpers.go index ae135409e1..f4e112a151 100644 --- a/test/integration/helpers.go +++ b/test/integration/helpers.go @@ -97,7 +97,7 @@ func Run(t *testing.T, cmd *exec.Cmd) (*RunResult, error) { if err != nil { return &RunResult{}, errors.Wrapf(err, "lookup powershell") } - args := append([]string{"-NoProfile", "-NonInteractive", "--%"}, cmd.Args...) + args := append([]string{"-NoProfile", "-NonInteractive"}, cmd.Args...) newCmd = exec.Command(psBin, args...) newCmd.Stdout = cmd.Stdout newCmd.Stderr = cmd.Stderr @@ -148,7 +148,7 @@ func Start(t *testing.T, cmd *exec.Cmd) (*StartSession, error) { if err != nil { return &StartSession{}, errors.Wrapf(err, "lookup powershell") } - args := append([]string{"-NoProfile", "-NonInteractive", "--%"}, cmd.Args...) + args := append([]string{"-NoProfile", "-NonInteractive"}, cmd.Args...) newCmd = exec.Command(psBin, args...) newCmd.Stdout = cmd.Stdout newCmd.Stderr = cmd.Stderr From 6370008b19cd4f55c7f84fd4b8a153aba7495ca0 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 May 2020 19:50:39 -0700 Subject: [PATCH 28/51] try without quot --- test/integration/functional_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 2606d5881a..03d9f92b00 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -853,7 +853,7 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { var rr *RunResult var err error if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! - cmd := exec.CommandContext(ctx, Target()+" -p "+profile+" ssh \"cat /etc/hostname\"") + cmd := exec.CommandContext(ctx, Target()+" -p "+profile+" ssh cat /etc/hostname") t.Logf("about to run %s: ", cmd.Args) rr, err = Run(t, cmd) t.Logf("rr is %+v: \n", rr) From a0cd034cfd37a6f3ad7184670e52f28643c7b4ce Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 May 2020 20:52:03 -0700 Subject: [PATCH 29/51] try with separate --- test/integration/functional_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 03d9f92b00..01ce1858fa 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -853,7 +853,7 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { var rr *RunResult var err error if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! - cmd := exec.CommandContext(ctx, Target()+" -p "+profile+" ssh cat /etc/hostname") + cmd := exec.CommandContext(ctx, Target()+" -p "+profile+" ssh", "cat /etc/hostname") t.Logf("about to run %s: ", cmd.Args) rr, err = Run(t, cmd) t.Logf("rr is %+v: \n", rr) From 126b172ebddbfc9d676fa2e38bcd617333bd2ef8 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 May 2020 21:14:23 -0700 Subject: [PATCH 30/51] try to skip all failed ones --- test/integration/fn_tunnel_cmd.go | 8 ++++++++ test/integration/functional_test.go | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/test/integration/fn_tunnel_cmd.go b/test/integration/fn_tunnel_cmd.go index 1efe109b0c..5f03030863 100644 --- a/test/integration/fn_tunnel_cmd.go +++ b/test/integration/fn_tunnel_cmd.go @@ -128,6 +128,9 @@ func validateTunnelStart(ctx context.Context, t *testing.T, profile string) { // validateServiceStable starts nginx pod, nginx service and waits nginx having loadbalancer ingress IP func validateServiceStable(ctx context.Context, t *testing.T, profile string) { checkRoutePassword(t) + if runtime.GOOS == "windows" { + t.Skipf("skipping for now") + } client, err := kapi.Client(profile) if err != nil { @@ -172,6 +175,11 @@ func validateServiceStable(ctx context.Context, t *testing.T, profile string) { // validateAccessDirect validates if the test service can be accessed with LoadBalancer IP from host func validateAccessDirect(ctx context.Context, t *testing.T, profile string) { + checkRoutePassword(t) + if runtime.GOOS == "windows" { + t.Skipf("skipping for now") + } + checkRoutePassword(t) got := []byte{} diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 01ce1858fa..0430d78803 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -339,7 +339,9 @@ func validateComponentHealth(ctx context.Context, t *testing.T, profile string) func validateStatusCmd(ctx context.Context, t *testing.T, profile string) { defer PostMortemLogs(t, profile) - + if runtime.GOOS == "windows" { + t.Skipf("skipping windows") + } rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "status")) if err != nil { t.Errorf("failed to run minikube status. args %q : %v", rr.Command(), err) @@ -453,6 +455,9 @@ func validateDNS(ctx context.Context, t *testing.T, profile string) { // validateDryRun asserts that the dry-run mode quickly exits with the right code func validateDryRun(ctx context.Context, t *testing.T, profile string) { + if runtime.GOOS == "windows" { + t.Skip("skipping windows for now") + } // dry-run mode should always be able to finish quickly (<5s) mctx, cancel := context.WithTimeout(ctx, Seconds(5)) defer cancel() From 90af6b97a5e872be59115f7749575c4928c15883 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 May 2020 21:32:03 -0700 Subject: [PATCH 31/51] try one more time --- test/integration/functional_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 0430d78803..6b3a2739ab 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -858,7 +858,7 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { var rr *RunResult var err error if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! - cmd := exec.CommandContext(ctx, Target()+" -p "+profile+" ssh", "cat /etc/hostname") + cmd := exec.CommandContext(ctx, Target()+" -p "+profile+" ssh "+"\"cat /etc/hostname\"") t.Logf("about to run %s: ", cmd.Args) rr, err = Run(t, cmd) t.Logf("rr is %+v: \n", rr) From a7bc03ccda852b39f6b1b35d9207ac85506f9932 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 May 2020 21:53:07 -0700 Subject: [PATCH 32/51] try pwd --- test/integration/functional_test.go | 31 +++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 6b3a2739ab..0325a3173e 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -168,7 +168,7 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { rr, err = Run(t, c) } if ctx.Err() == context.DeadlineExceeded { - t.Logf("failed to run the command in 30 seconds. exceeded 30s timeout. %s", rr.Command()) + t.Errorf("failed to run the command in 30 seconds. exceeded 30s timeout. %s", rr.Command()) } if err != nil { t.Fatalf("failed to do status after eval-ing docker-env. error: %v", err) @@ -189,7 +189,7 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { } if ctx.Err() == context.DeadlineExceeded { - t.Logf("failed to run the command in 30 seconds. exceeded 30s timeout. %s", rr.Command()) + t.Errorf("failed to run the command in 30 seconds. exceeded 30s timeout. %s", rr.Command()) } if err != nil { @@ -854,9 +854,32 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { if NoneDriver() { t.Skipf("skipping: ssh unsupported by none") } - want := profile + "\n" + want := "/home/docker\n" var rr *RunResult var err error + + if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! + cmd := exec.CommandContext(ctx, Target()+" -p "+profile+" ssh "+"pwd") + t.Logf("about to run %s: ", cmd.Args) + rr, err = Run(t, cmd) + t.Logf("rr is %+v: \n", rr) + t.Logf("err is %v: \n", err) + } else { + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "pwd")) + } + if ctx.Err() == context.DeadlineExceeded { + t.Errorf("failed to run command by deadline. exceeded timeout : %s", rr.Command()) + } + + if err != nil { + t.Errorf("failed to run an ssh command. args %q : %v", rr.Command(), err) + } + if rr.Stdout.String() != want { + t.Errorf("expected minikube ssh command output to be -%q- but got *%q*. args %q", want, rr.Stdout.String(), rr.Command()) + } + + want := profile + "\n" + if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! cmd := exec.CommandContext(ctx, Target()+" -p "+profile+" ssh "+"\"cat /etc/hostname\"") t.Logf("about to run %s: ", cmd.Args) @@ -867,7 +890,7 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/hostname")) } if ctx.Err() == context.DeadlineExceeded { - t.Logf("failed to run command by deadline. exceeded timeout : %s", rr.Command()) + t.Errorf("failed to run command by deadline. exceeded timeout : %s", rr.Command()) } if err != nil { From 83053359f6f5954d6b8d68ded736e7bd467bae18 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 May 2020 21:58:31 -0700 Subject: [PATCH 33/51] fix build --- test/integration/functional_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 0325a3173e..f0ce08ec92 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -878,7 +878,7 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { t.Errorf("expected minikube ssh command output to be -%q- but got *%q*. args %q", want, rr.Stdout.String(), rr.Command()) } - want := profile + "\n" + want = profile + "\n" if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! cmd := exec.CommandContext(ctx, Target()+" -p "+profile+" ssh "+"\"cat /etc/hostname\"") From dd6ab66e196879aece80354f7eafc0afb35841c0 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 May 2020 22:47:13 -0700 Subject: [PATCH 34/51] fix --- test/integration/functional_test.go | 26 ++++--------------------- test/integration/helpers.go | 30 ++++++++++++++++++----------- 2 files changed, 23 insertions(+), 33 deletions(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index f0ce08ec92..d8dccd7aab 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -161,7 +161,7 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { var err error if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! c := exec.CommandContext(mctx, Target()+" -p "+profile+" docker-env | Invoke-Expression ;"+Target()+" status -p "+profile) - rr, err = Run(t, c) // golang exec powershell needs some tricks ! + rr, err = Run(t, c, true) // golang exec powershell needs some tricks ! } else { c := exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" docker-env) && "+Target()+" status -p "+profile) // we should be able to get minikube status with a bash which evaled docker-env @@ -855,18 +855,7 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { t.Skipf("skipping: ssh unsupported by none") } want := "/home/docker\n" - var rr *RunResult - var err error - - if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! - cmd := exec.CommandContext(ctx, Target()+" -p "+profile+" ssh "+"pwd") - t.Logf("about to run %s: ", cmd.Args) - rr, err = Run(t, cmd) - t.Logf("rr is %+v: \n", rr) - t.Logf("err is %v: \n", err) - } else { - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "pwd")) - } + rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "pwd")) if ctx.Err() == context.DeadlineExceeded { t.Errorf("failed to run command by deadline. exceeded timeout : %s", rr.Command()) } @@ -874,21 +863,14 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { if err != nil { t.Errorf("failed to run an ssh command. args %q : %v", rr.Command(), err) } + if rr.Stdout.String() != want { t.Errorf("expected minikube ssh command output to be -%q- but got *%q*. args %q", want, rr.Stdout.String(), rr.Command()) } want = profile + "\n" - if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! - cmd := exec.CommandContext(ctx, Target()+" -p "+profile+" ssh "+"\"cat /etc/hostname\"") - t.Logf("about to run %s: ", cmd.Args) - rr, err = Run(t, cmd) - t.Logf("rr is %+v: \n", rr) - t.Logf("err is %v: \n", err) - } else { - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/hostname")) - } + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/hostname")) if ctx.Err() == context.DeadlineExceeded { t.Errorf("failed to run command by deadline. exceeded timeout : %s", rr.Command()) } diff --git a/test/integration/helpers.go b/test/integration/helpers.go index f4e112a151..ff26494800 100644 --- a/test/integration/helpers.go +++ b/test/integration/helpers.go @@ -29,7 +29,6 @@ import ( "fmt" "io/ioutil" "os/exec" - "runtime" "strings" "testing" "time" @@ -88,16 +87,20 @@ func (rr RunResult) Output() string { } // Run is a test helper to log a command being executed \_(ツ)_/¯ -func Run(t *testing.T, cmd *exec.Cmd) (*RunResult, error) { +func Run(t *testing.T, cmd *exec.Cmd, powershell ...bool) (*RunResult, error) { t.Helper() + runInPowershell := false + if len(powershell) > 0 { + runInPowershell = powershell[0] + } var newCmd *exec.Cmd - if runtime.GOOS == "windows" { + if runInPowershell { psBin, err := exec.LookPath("powershell.exe") if err != nil { return &RunResult{}, errors.Wrapf(err, "lookup powershell") } - args := append([]string{"-NoProfile", "-NonInteractive"}, cmd.Args...) + args := append([]string{"-NoProfile"}, cmd.Args...) newCmd = exec.Command(psBin, args...) newCmd.Stdout = cmd.Stdout newCmd.Stderr = cmd.Stderr @@ -118,9 +121,10 @@ func Run(t *testing.T, cmd *exec.Cmd) (*RunResult, error) { elapsed := time.Since(start) if err == nil { // Reduce log spam - if elapsed > (1 * time.Second) { - t.Logf("(dbg) Done: %v: (%s)", rr.Command(), elapsed) - } + // TODO:medygh bring this back + // if elapsed > (1 * time.Second) { + t.Logf("(dbg) Done: %v: (%s)", rr.Command(), elapsed) + // } } else { if exitError, ok := err.(*exec.ExitError); ok { rr.ExitCode = exitError.ExitCode() @@ -138,17 +142,21 @@ type StartSession struct { } // Start starts a process in the background, streaming output -func Start(t *testing.T, cmd *exec.Cmd) (*StartSession, error) { +func Start(t *testing.T, cmd *exec.Cmd, powershell ...bool) (*StartSession, error) { t.Helper() - t.Logf("(dbg) daemon: %v", cmd.Args) + runInPowershell := false + if len(powershell) > 0 { + runInPowershell = powershell[0] + } + t.Logf("(dbg) daemon: %v", cmd.Args) var newCmd *exec.Cmd - if runtime.GOOS == "windows" { + if runInPowershell { psBin, err := exec.LookPath("powershell.exe") if err != nil { return &StartSession{}, errors.Wrapf(err, "lookup powershell") } - args := append([]string{"-NoProfile", "-NonInteractive"}, cmd.Args...) + args := append([]string{"-NoProfile"}, cmd.Args...) newCmd = exec.Command(psBin, args...) newCmd.Stdout = cmd.Stdout newCmd.Stderr = cmd.Stderr From bf5aefb61dee48a4ac0f6131d33a42bdc192f7a5 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 May 2020 23:08:47 -0700 Subject: [PATCH 35/51] put non-interactive back --- test/integration/helpers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/helpers.go b/test/integration/helpers.go index ff26494800..422355a1ac 100644 --- a/test/integration/helpers.go +++ b/test/integration/helpers.go @@ -100,7 +100,7 @@ func Run(t *testing.T, cmd *exec.Cmd, powershell ...bool) (*RunResult, error) { if err != nil { return &RunResult{}, errors.Wrapf(err, "lookup powershell") } - args := append([]string{"-NoProfile"}, cmd.Args...) + args := append([]string{"-NoProfile", "-NonInteractive"}, cmd.Args...) newCmd = exec.Command(psBin, args...) newCmd.Stdout = cmd.Stdout newCmd.Stderr = cmd.Stderr From d8bbcc03f5d596b2126e58f3bd84c33d625e9765 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 May 2020 23:30:42 -0700 Subject: [PATCH 36/51] docker-env --- test/integration/functional_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index d8dccd7aab..ae793c5af8 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -182,7 +182,7 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { // do a eval $(minikube -p profile docker-env) and check if we are point to docker inside minikube if runtime.GOOS == "windows" { // testing docker-env eval in powershell c := exec.CommandContext(mctx, Target(), "-p "+profile+" docker-env | Invoke-Expression ; docker images") - rr, err = Run(t, c) // golang exec powershell needs some tricks ! + rr, err = Run(t, c, true) // golang exec powershell needs some tricks ! } else { c := exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" docker-env) && docker images") rr, err = Run(t, c) From 12e911cc1c0d1bbb82c0e127c45c9aaf5f7cb0f1 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 May 2020 23:52:55 -0700 Subject: [PATCH 37/51] try run true for powerhell --- test/integration/functional_test.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index ae793c5af8..c2fd158b5d 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -855,7 +855,15 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { t.Skipf("skipping: ssh unsupported by none") } want := "/home/docker\n" - rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "pwd")) + + var rr *RunResult + var err error + if runtime.GOOS == "windows" { + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "pwd"), true) + } else { + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "pwd")) + } + if ctx.Err() == context.DeadlineExceeded { t.Errorf("failed to run command by deadline. exceeded timeout : %s", rr.Command()) } @@ -870,7 +878,11 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { want = profile + "\n" - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/hostname")) + if runtime.GOOS == "windows" { + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/hostname"), true) + } else { + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/hostname")) + } if ctx.Err() == context.DeadlineExceeded { t.Errorf("failed to run command by deadline. exceeded timeout : %s", rr.Command()) } From bfbc39a89d527269a6ec704ab982917187d51541 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 27 May 2020 00:23:43 -0700 Subject: [PATCH 38/51] try sh --- test/integration/functional_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index c2fd158b5d..4ef67bfd0a 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -859,7 +859,7 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { var rr *RunResult var err error if runtime.GOOS == "windows" { - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "pwd"), true) + rr, err = Run(t, exec.CommandContext(ctx, Target()+" -p "+profile+" ssh pwd"), true) } else { rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "pwd")) } @@ -879,7 +879,7 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { want = profile + "\n" if runtime.GOOS == "windows" { - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/hostname"), true) + rr, err = Run(t, exec.CommandContext(ctx, Target()+" -p "+profile+" ssh cat /etc/hostname"), true) } else { rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/hostname")) } From 1bc374ee6340b197654960616536a513c3f6856c Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 27 May 2020 00:48:40 -0700 Subject: [PATCH 39/51] try one more thing --- test/integration/functional_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 4ef67bfd0a..fb3c6f9e23 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -859,7 +859,7 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { var rr *RunResult var err error if runtime.GOOS == "windows" { - rr, err = Run(t, exec.CommandContext(ctx, Target()+" -p "+profile+" ssh pwd"), true) + rr, err = Run(t, exec.CommandContext(ctx, Target()+" -p "+profile+" ssh", "pwd"), true) } else { rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "pwd")) } @@ -879,7 +879,7 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { want = profile + "\n" if runtime.GOOS == "windows" { - rr, err = Run(t, exec.CommandContext(ctx, Target()+" -p "+profile+" ssh cat /etc/hostname"), true) + rr, err = Run(t, exec.CommandContext(ctx, Target()+" -p "+profile+" ssh", "cat /etc/hostname"), true) } else { rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/hostname")) } From c7135e0af9155b0642b62e2bd1ed84af5f777f68 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 27 May 2020 12:25:10 -0700 Subject: [PATCH 40/51] remove unrelated changes --- test/integration/fn_mount_cmd.go | 8 +------- test/integration/fn_tunnel_cmd.go | 8 -------- test/integration/functional_test.go | 28 ++++------------------------ 3 files changed, 5 insertions(+), 39 deletions(-) diff --git a/test/integration/fn_mount_cmd.go b/test/integration/fn_mount_cmd.go index 48671a0be3..014c470d9d 100644 --- a/test/integration/fn_mount_cmd.go +++ b/test/integration/fn_mount_cmd.go @@ -43,7 +43,7 @@ const ( createdByPodRemovedByTest = "created-by-pod-removed-by-test" ) -func validateMountCmd(ctx context.Context, t *testing.T, profile string) { //nolint cyclomatic complexity 33 of func `validateMountCmd` is high (> 30 +func validateMountCmd(ctx context.Context, t *testing.T, profile string) { if NoneDriver() { t.Skip("skipping: none driver does not support mount") } @@ -51,12 +51,6 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { //nol t.Skip("skipping: mount broken on hyperv: https://github.com/kubernetes/minikube/issues/5029") } - t.Logf("runtime is %q\n", runtime.GOOS) - - if runtime.GOOS == "windows" { - t.Skip("skipping: mount broken on windows: https://github.com/kubernetes/minikube/issues/8271") - } - tempDir, err := ioutil.TempDir("", "mounttest") defer func() { //clean up tempdir err := os.RemoveAll(tempDir) diff --git a/test/integration/fn_tunnel_cmd.go b/test/integration/fn_tunnel_cmd.go index 5f03030863..1efe109b0c 100644 --- a/test/integration/fn_tunnel_cmd.go +++ b/test/integration/fn_tunnel_cmd.go @@ -128,9 +128,6 @@ func validateTunnelStart(ctx context.Context, t *testing.T, profile string) { // validateServiceStable starts nginx pod, nginx service and waits nginx having loadbalancer ingress IP func validateServiceStable(ctx context.Context, t *testing.T, profile string) { checkRoutePassword(t) - if runtime.GOOS == "windows" { - t.Skipf("skipping for now") - } client, err := kapi.Client(profile) if err != nil { @@ -175,11 +172,6 @@ func validateServiceStable(ctx context.Context, t *testing.T, profile string) { // validateAccessDirect validates if the test service can be accessed with LoadBalancer IP from host func validateAccessDirect(ctx context.Context, t *testing.T, profile string) { - checkRoutePassword(t) - if runtime.GOOS == "windows" { - t.Skipf("skipping for now") - } - checkRoutePassword(t) got := []byte{} diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index fb3c6f9e23..4601590f72 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -339,9 +339,6 @@ func validateComponentHealth(ctx context.Context, t *testing.T, profile string) func validateStatusCmd(ctx context.Context, t *testing.T, profile string) { defer PostMortemLogs(t, profile) - if runtime.GOOS == "windows" { - t.Skipf("skipping windows") - } rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "status")) if err != nil { t.Errorf("failed to run minikube status. args %q : %v", rr.Command(), err) @@ -519,13 +516,7 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) { }) t.Run("verify_cache_inside_node", func(t *testing.T) { - if runtime.GOOS == "windows" { - t.Skipf("skipping: skipping for now") - } - - var rr *RunResult - var err error - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo", "crictl", "images")) + rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo", "crictl", "images")) if err != nil { t.Errorf("failed to get images by %q ssh %v", rr.Command(), err) } @@ -536,15 +527,9 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) { }) t.Run("cache_reload", func(t *testing.T) { // deleting image inside minikube node manually and expecting reload to bring it back - if runtime.GOOS == "windows" { - t.Skipf("skipping: skipping for now") - } - img := "busybox:latest" // deleting image inside minikube node manually - var rr *RunResult - var err error - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo", "docker", "rmi", img)) + rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo", "docker", "rmi", img)) if err != nil { t.Errorf("failed to delete inside the node %q : %v", rr.Command(), err) @@ -856,13 +841,7 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { } want := "/home/docker\n" - var rr *RunResult - var err error - if runtime.GOOS == "windows" { - rr, err = Run(t, exec.CommandContext(ctx, Target()+" -p "+profile+" ssh", "pwd"), true) - } else { - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "pwd")) - } + rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "pwd")) if ctx.Err() == context.DeadlineExceeded { t.Errorf("failed to run command by deadline. exceeded timeout : %s", rr.Command()) @@ -876,6 +855,7 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { t.Errorf("expected minikube ssh command output to be -%q- but got *%q*. args %q", want, rr.Stdout.String(), rr.Command()) } + // testing hostname as well want = profile + "\n" if runtime.GOOS == "windows" { From e935662fcdc2e318bf23e6e73aa4e643c1d72b44 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 27 May 2020 12:26:14 -0700 Subject: [PATCH 41/51] remove unrelated changes --- test/integration/functional_test.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 4601590f72..690d6bbf11 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -973,10 +973,6 @@ func validateFileSync(ctx context.Context, t *testing.T, profile string) { t.Skipf("skipping: ssh unsupported by none") } - if runtime.GOOS == "windows" { - t.Skipf("skipping for windows for now :(") - } - vp := vmSyncTestPath() t.Logf("Checking for existence of %s within VM", vp) rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", fmt.Sprintf("sudo cat %s", vp))) @@ -1004,10 +1000,6 @@ func validateCertSync(ctx context.Context, t *testing.T, profile string) { t.Skipf("skipping: ssh unsupported by none") } - if runtime.GOOS == "windows" { - t.Skipf("skipping for windows for now :(") - } - want, err := ioutil.ReadFile("./testdata/minikube_test.pem") if err != nil { t.Errorf("test file not found: %v", err) From 331a41675414dd0b5eb659ecdf95b1fe3a81f5ae Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 27 May 2020 12:28:35 -0700 Subject: [PATCH 42/51] remove unrelated changes --- test/integration/fn_mount_cmd.go | 2 +- test/integration/functional_test.go | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/test/integration/fn_mount_cmd.go b/test/integration/fn_mount_cmd.go index 014c470d9d..986a3d2bbb 100644 --- a/test/integration/fn_mount_cmd.go +++ b/test/integration/fn_mount_cmd.go @@ -62,7 +62,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { t.Fatalf("Unexpected error while creating tempDir: %v", err) } - mctx, cancel := context.WithTimeout(ctx, Minutes(3)) + mctx, cancel := context.WithTimeout(ctx, Minutes(10)) args := []string{"mount", "-p", profile, fmt.Sprintf("%s:%s", tempDir, guestMount), "--alsologtostderr", "-v=1"} ss, err := Start(t, exec.CommandContext(mctx, Target(), args...)) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 690d6bbf11..e47f7ced55 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -452,9 +452,6 @@ func validateDNS(ctx context.Context, t *testing.T, profile string) { // validateDryRun asserts that the dry-run mode quickly exits with the right code func validateDryRun(ctx context.Context, t *testing.T, profile string) { - if runtime.GOOS == "windows" { - t.Skip("skipping windows for now") - } // dry-run mode should always be able to finish quickly (<5s) mctx, cancel := context.WithTimeout(ctx, Seconds(5)) defer cancel() From 666f780a311a72988aadccde24b145d7344dc1ce Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 27 May 2020 12:51:10 -0700 Subject: [PATCH 43/51] skip none for olm addon --- test/integration/addons_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/integration/addons_test.go b/test/integration/addons_test.go index 0fdaae895d..918bfcba66 100644 --- a/test/integration/addons_test.go +++ b/test/integration/addons_test.go @@ -331,6 +331,9 @@ func validateHelmTillerAddon(ctx context.Context, t *testing.T, profile string) } func validateOlmAddon(ctx context.Context, t *testing.T, profile string) { + if NoneDriver() { + t.Skipf("Skipping none driver, olm addon is not supported on none driver") + } defer PostMortemLogs(t, profile) client, err := kapi.Client(profile) From f1ab31b61b07e38c1bada3541239ff803f9ff024 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 27 May 2020 13:45:27 -0700 Subject: [PATCH 44/51] address review comments --- test/integration/functional_test.go | 33 ++++++++++++----------------- test/integration/helpers.go | 24 ++------------------- 2 files changed, 16 insertions(+), 41 deletions(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index e47f7ced55..1b33355b3c 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -154,21 +154,20 @@ func validateNodeLabels(ctx context.Context, t *testing.T, profile string) { // check functionality of minikube after evaling docker-env func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { defer PostMortemLogs(t, profile) - mctx, cancel := context.WithTimeout(ctx, Seconds(30)) defer cancel() var rr *RunResult var err error - if runtime.GOOS == "windows" { // golang exec powershell needs some tricks ! + if runtime.GOOS == "windows" { c := exec.CommandContext(mctx, Target()+" -p "+profile+" docker-env | Invoke-Expression ;"+Target()+" status -p "+profile) - rr, err = Run(t, c, true) // golang exec powershell needs some tricks ! + rr, err = Run(t, c, true) } else { c := exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" docker-env) && "+Target()+" status -p "+profile) // we should be able to get minikube status with a bash which evaled docker-env rr, err = Run(t, c) } - if ctx.Err() == context.DeadlineExceeded { - t.Errorf("failed to run the command in 30 seconds. exceeded 30s timeout. %s", rr.Command()) + if mctx.Err() == context.DeadlineExceeded { + t.Errorf("failed to run the command by deadline. exceeded timeout. %s", rr.Command()) } if err != nil { t.Fatalf("failed to do status after eval-ing docker-env. error: %v", err) @@ -182,13 +181,13 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { // do a eval $(minikube -p profile docker-env) and check if we are point to docker inside minikube if runtime.GOOS == "windows" { // testing docker-env eval in powershell c := exec.CommandContext(mctx, Target(), "-p "+profile+" docker-env | Invoke-Expression ; docker images") - rr, err = Run(t, c, true) // golang exec powershell needs some tricks ! + rr, err = Run(t, c, true) } else { c := exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" docker-env) && docker images") rr, err = Run(t, c) } - if ctx.Err() == context.DeadlineExceeded { + if mctx.Err() == context.DeadlineExceeded { t.Errorf("failed to run the command in 30 seconds. exceeded 30s timeout. %s", rr.Command()) } @@ -836,31 +835,27 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { if NoneDriver() { t.Skipf("skipping: ssh unsupported by none") } - want := "/home/docker\n" - rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "pwd")) + want = "hello" + "\n" + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "echo hello")) if ctx.Err() == context.DeadlineExceeded { t.Errorf("failed to run command by deadline. exceeded timeout : %s", rr.Command()) } - if err != nil { t.Errorf("failed to run an ssh command. args %q : %v", rr.Command(), err) } - if rr.Stdout.String() != want { t.Errorf("expected minikube ssh command output to be -%q- but got *%q*. args %q", want, rr.Stdout.String(), rr.Command()) } - // testing hostname as well + // testing hostname as well because testing something like "minikube ssh echo" could be confusing + // because it is not clear if echo was run inside minikube on the powershell + // so better to test somethign inside minikube, that is meaningful per profile + // in this case /etc/hostname is same as the profile name want = profile + "\n" - - if runtime.GOOS == "windows" { - rr, err = Run(t, exec.CommandContext(ctx, Target()+" -p "+profile+" ssh", "cat /etc/hostname"), true) - } else { - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/hostname")) - } - if ctx.Err() == context.DeadlineExceeded { + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/hostname")) + if mctx.Err() == context.DeadlineExceeded { t.Errorf("failed to run command by deadline. exceeded timeout : %s", rr.Command()) } diff --git a/test/integration/helpers.go b/test/integration/helpers.go index 422355a1ac..5c8a9717c1 100644 --- a/test/integration/helpers.go +++ b/test/integration/helpers.go @@ -34,7 +34,6 @@ import ( "time" "github.com/docker/machine/libmachine/state" - "github.com/pkg/errors" "github.com/shirou/gopsutil/process" core "k8s.io/api/core/v1" meta "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -96,12 +95,8 @@ func Run(t *testing.T, cmd *exec.Cmd, powershell ...bool) (*RunResult, error) { var newCmd *exec.Cmd if runInPowershell { - psBin, err := exec.LookPath("powershell.exe") - if err != nil { - return &RunResult{}, errors.Wrapf(err, "lookup powershell") - } args := append([]string{"-NoProfile", "-NonInteractive"}, cmd.Args...) - newCmd = exec.Command(psBin, args...) + newCmd = exec.Command("powershell.exe", args...) newCmd.Stdout = cmd.Stdout newCmd.Stderr = cmd.Stderr newCmd.Env = cmd.Env @@ -152,12 +147,8 @@ func Start(t *testing.T, cmd *exec.Cmd, powershell ...bool) (*StartSession, erro t.Logf("(dbg) daemon: %v", cmd.Args) var newCmd *exec.Cmd if runInPowershell { - psBin, err := exec.LookPath("powershell.exe") - if err != nil { - return &StartSession{}, errors.Wrapf(err, "lookup powershell") - } args := append([]string{"-NoProfile"}, cmd.Args...) - newCmd = exec.Command(psBin, args...) + newCmd = exec.Command("powershell.exe", args...) newCmd.Stdout = cmd.Stdout newCmd.Stderr = cmd.Stderr newCmd.Env = cmd.Env @@ -489,14 +480,3 @@ func killProcessFamily(t *testing.T, pid int) { } } } - -func RunPowershellCmd(args ...string) (string, error) { - psBin, err := exec.LookPath("powershell.exe") - if err != nil { - return "", err - } - args = append([]string{"-NoProfile", "-NonInteractive"}, args...) - cmd := exec.Command(psBin, args...) - out, err := cmd.CombinedOutput() - return string(out), err -} From 70e5b525117503462fd321c530d700e26e72b971 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 27 May 2020 13:56:16 -0700 Subject: [PATCH 45/51] address review comments --- test/integration/functional_test.go | 17 ++++----- test/integration/helpers.go | 53 +++++++++++++++++++---------- 2 files changed, 44 insertions(+), 26 deletions(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 1b33355b3c..9c63cc3d4e 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -160,7 +160,7 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { var err error if runtime.GOOS == "windows" { c := exec.CommandContext(mctx, Target()+" -p "+profile+" docker-env | Invoke-Expression ;"+Target()+" status -p "+profile) - rr, err = Run(t, c, true) + rr, err = RunInPowershell(t, c) } else { c := exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" docker-env) && "+Target()+" status -p "+profile) // we should be able to get minikube status with a bash which evaled docker-env @@ -181,7 +181,7 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { // do a eval $(minikube -p profile docker-env) and check if we are point to docker inside minikube if runtime.GOOS == "windows" { // testing docker-env eval in powershell c := exec.CommandContext(mctx, Target(), "-p "+profile+" docker-env | Invoke-Expression ; docker images") - rr, err = Run(t, c, true) + rr, err = RunInPowershell(t, c) } else { c := exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" docker-env) && docker images") rr, err = Run(t, c) @@ -831,15 +831,16 @@ func validateAddonsCmd(ctx context.Context, t *testing.T, profile string) { // validateSSHCmd asserts basic "ssh" command functionality func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { defer PostMortemLogs(t, profile) - if NoneDriver() { t.Skipf("skipping: ssh unsupported by none") } + mctx, cancel := context.WithTimeout(ctx, Minutes(1)) + defer cancel() - want = "hello" + "\n" + want := "hello\n" - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "echo hello")) - if ctx.Err() == context.DeadlineExceeded { + rr, err := Run(t, exec.CommandContext(mctx, Target(), "-p", profile, "ssh", "echo hello")) + if mctx.Err() == context.DeadlineExceeded { t.Errorf("failed to run command by deadline. exceeded timeout : %s", rr.Command()) } if err != nil { @@ -851,10 +852,10 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { // testing hostname as well because testing something like "minikube ssh echo" could be confusing // because it is not clear if echo was run inside minikube on the powershell - // so better to test somethign inside minikube, that is meaningful per profile + // so better to test something inside minikube, that is meaningful per profile // in this case /etc/hostname is same as the profile name want = profile + "\n" - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/hostname")) + rr, err = Run(t, exec.CommandContext(mctx, Target(), "-p", profile, "ssh", "cat /etc/hostname")) if mctx.Err() == context.DeadlineExceeded { t.Errorf("failed to run command by deadline. exceeded timeout : %s", rr.Command()) } diff --git a/test/integration/helpers.go b/test/integration/helpers.go index 5c8a9717c1..514bbe72bc 100644 --- a/test/integration/helpers.go +++ b/test/integration/helpers.go @@ -86,23 +86,41 @@ func (rr RunResult) Output() string { } // Run is a test helper to log a command being executed \_(ツ)_/¯ -func Run(t *testing.T, cmd *exec.Cmd, powershell ...bool) (*RunResult, error) { +func Run(t *testing.T, cmd *exec.Cmd) (*RunResult, error) { t.Helper() - runInPowershell := false - if len(powershell) > 0 { - runInPowershell = powershell[0] - } + rr := &RunResult{Args: cmd.Args} - var newCmd *exec.Cmd - if runInPowershell { - args := append([]string{"-NoProfile", "-NonInteractive"}, cmd.Args...) - newCmd = exec.Command("powershell.exe", args...) - newCmd.Stdout = cmd.Stdout - newCmd.Stderr = cmd.Stderr - newCmd.Env = cmd.Env + t.Logf("(dbg) Run: %v", rr.Command()) + + var outb, errb bytes.Buffer + cmd.Stdout, rr.Stdout = &outb, &outb + cmd.Stderr, rr.Stderr = &errb, &errb + start := time.Now() + err := cmd.Run() + elapsed := time.Since(start) + if err == nil { + // Reduce log spam + if elapsed > (1 * time.Second) { + t.Logf("(dbg) Done: %v: (%s)", rr.Command(), elapsed) + } } else { - newCmd = cmd + if exitError, ok := err.(*exec.ExitError); ok { + rr.ExitCode = exitError.ExitCode() + } + t.Logf("(dbg) Non-zero exit: %v: %v (%s)\n%s", rr.Command(), err, elapsed, rr.Output()) } + return rr, err +} + +// RunInPowershell is a test helper to log a command being executed in powershell \_(ツ)_/¯ +func RunInPowershell(t *testing.T, cmd *exec.Cmd) (*RunResult, error) { + t.Helper() + var newCmd *exec.Cmd + args := append([]string{"-NoProfile", "-NonInteractive"}, cmd.Args...) + newCmd = exec.Command("powershell.exe", args...) + newCmd.Stdout = cmd.Stdout + newCmd.Stderr = cmd.Stderr + newCmd.Env = cmd.Env rr := &RunResult{Args: newCmd.Args} @@ -114,12 +132,11 @@ func Run(t *testing.T, cmd *exec.Cmd, powershell ...bool) (*RunResult, error) { start := time.Now() err := newCmd.Run() elapsed := time.Since(start) + if err == nil { - // Reduce log spam - // TODO:medygh bring this back - // if elapsed > (1 * time.Second) { - t.Logf("(dbg) Done: %v: (%s)", rr.Command(), elapsed) - // } + if elapsed > (1 * time.Second) { + t.Logf("(dbg) Done: %v: (%s)", rr.Command(), elapsed) + } } else { if exitError, ok := err.(*exec.ExitError); ok { rr.ExitCode = exitError.ExitCode() From 76f9a71a1863b01394f36b48515c62a6066491ef Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 27 May 2020 15:40:43 -0700 Subject: [PATCH 46/51] address review comments --- test/integration/functional_test.go | 8 ++-- test/integration/helpers.go | 58 ++--------------------------- 2 files changed, 8 insertions(+), 58 deletions(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 9c63cc3d4e..fd70db8557 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -159,8 +159,8 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { var rr *RunResult var err error if runtime.GOOS == "windows" { - c := exec.CommandContext(mctx, Target()+" -p "+profile+" docker-env | Invoke-Expression ;"+Target()+" status -p "+profile) - rr, err = RunInPowershell(t, c) + c := exec.CommandContext(mctx, "powershell.exe", "-NoProfile", "-NonInteractive", Target()+" -p "+profile+" docker-env | Invoke-Expression ;"+Target()+" status -p "+profile) + rr, err = Run(t, c) } else { c := exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" docker-env) && "+Target()+" status -p "+profile) // we should be able to get minikube status with a bash which evaled docker-env @@ -180,8 +180,8 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { defer cancel() // do a eval $(minikube -p profile docker-env) and check if we are point to docker inside minikube if runtime.GOOS == "windows" { // testing docker-env eval in powershell - c := exec.CommandContext(mctx, Target(), "-p "+profile+" docker-env | Invoke-Expression ; docker images") - rr, err = RunInPowershell(t, c) + c := exec.CommandContext(mctx, "powershell.exe", "-NoProfile", "-NonInteractive", Target(), "-p "+profile+" docker-env | Invoke-Expression ; docker images") + rr, err = Run(t, c) } else { c := exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" docker-env) && docker images") rr, err = Run(t, c) diff --git a/test/integration/helpers.go b/test/integration/helpers.go index 514bbe72bc..bc646ce8a5 100644 --- a/test/integration/helpers.go +++ b/test/integration/helpers.go @@ -112,40 +112,6 @@ func Run(t *testing.T, cmd *exec.Cmd) (*RunResult, error) { return rr, err } -// RunInPowershell is a test helper to log a command being executed in powershell \_(ツ)_/¯ -func RunInPowershell(t *testing.T, cmd *exec.Cmd) (*RunResult, error) { - t.Helper() - var newCmd *exec.Cmd - args := append([]string{"-NoProfile", "-NonInteractive"}, cmd.Args...) - newCmd = exec.Command("powershell.exe", args...) - newCmd.Stdout = cmd.Stdout - newCmd.Stderr = cmd.Stderr - newCmd.Env = cmd.Env - - rr := &RunResult{Args: newCmd.Args} - - t.Logf("(dbg) Run: %v", rr.Command()) - - var outb, errb bytes.Buffer - newCmd.Stdout, rr.Stdout = &outb, &outb - newCmd.Stderr, rr.Stderr = &errb, &errb - start := time.Now() - err := newCmd.Run() - elapsed := time.Since(start) - - if err == nil { - if elapsed > (1 * time.Second) { - t.Logf("(dbg) Done: %v: (%s)", rr.Command(), elapsed) - } - } else { - if exitError, ok := err.(*exec.ExitError); ok { - rr.ExitCode = exitError.ExitCode() - } - t.Logf("(dbg) Non-zero exit: %v: %v (%s)\n%s", rr.Command(), err, elapsed, rr.Output()) - } - return rr, err -} - // StartSession stores the result of an cmd.Start call type StartSession struct { Stdout *bufio.Reader @@ -156,34 +122,18 @@ type StartSession struct { // Start starts a process in the background, streaming output func Start(t *testing.T, cmd *exec.Cmd, powershell ...bool) (*StartSession, error) { t.Helper() - runInPowershell := false - if len(powershell) > 0 { - runInPowershell = powershell[0] - } - t.Logf("(dbg) daemon: %v", cmd.Args) - var newCmd *exec.Cmd - if runInPowershell { - args := append([]string{"-NoProfile"}, cmd.Args...) - newCmd = exec.Command("powershell.exe", args...) - newCmd.Stdout = cmd.Stdout - newCmd.Stderr = cmd.Stderr - newCmd.Env = cmd.Env - } else { - newCmd = cmd - } - - stdoutPipe, err := newCmd.StdoutPipe() + stdoutPipe, err := cmd.StdoutPipe() if err != nil { t.Fatalf("stdout pipe failed: %v %v", newCmd.Args, err) } - stderrPipe, err := newCmd.StderrPipe() + stderrPipe, err := cmd.StderrPipe() if err != nil { t.Fatalf("stderr pipe failed: %v %v", newCmd.Args, err) } - sr := &StartSession{Stdout: bufio.NewReader(stdoutPipe), Stderr: bufio.NewReader(stderrPipe), cmd: newCmd} - return sr, newCmd.Start() + sr := &StartSession{Stdout: bufio.NewReader(stdoutPipe), Stderr: bufio.NewReader(stderrPipe), cmd: cmd} + return sr, cmd.Start() } // Stop stops the started process From 27250f8bbe940a5376cb6b97e1f39f96fe3b73eb Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 27 May 2020 15:46:49 -0700 Subject: [PATCH 47/51] lint --- test/integration/helpers.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/helpers.go b/test/integration/helpers.go index bc646ce8a5..9f35eeb347 100644 --- a/test/integration/helpers.go +++ b/test/integration/helpers.go @@ -125,11 +125,11 @@ func Start(t *testing.T, cmd *exec.Cmd, powershell ...bool) (*StartSession, erro t.Logf("(dbg) daemon: %v", cmd.Args) stdoutPipe, err := cmd.StdoutPipe() if err != nil { - t.Fatalf("stdout pipe failed: %v %v", newCmd.Args, err) + t.Fatalf("stdout pipe failed: %v %v", cmd.Args, err) } stderrPipe, err := cmd.StderrPipe() if err != nil { - t.Fatalf("stderr pipe failed: %v %v", newCmd.Args, err) + t.Fatalf("stderr pipe failed: %v %v", cmd.Args, err) } sr := &StartSession{Stdout: bufio.NewReader(stdoutPipe), Stderr: bufio.NewReader(stderrPipe), cmd: cmd} From 7aa96307e10aafa29d69aa7525e33d449547a002 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 27 May 2020 15:57:26 -0700 Subject: [PATCH 48/51] remove unneeded code --- test/integration/helpers.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/integration/helpers.go b/test/integration/helpers.go index 9f35eeb347..e7e9c218ab 100644 --- a/test/integration/helpers.go +++ b/test/integration/helpers.go @@ -89,7 +89,6 @@ func (rr RunResult) Output() string { func Run(t *testing.T, cmd *exec.Cmd) (*RunResult, error) { t.Helper() rr := &RunResult{Args: cmd.Args} - t.Logf("(dbg) Run: %v", rr.Command()) var outb, errb bytes.Buffer @@ -120,7 +119,7 @@ type StartSession struct { } // Start starts a process in the background, streaming output -func Start(t *testing.T, cmd *exec.Cmd, powershell ...bool) (*StartSession, error) { +func Start(t *testing.T, cmd *exec.Cmd) (*StartSession, error) { t.Helper() t.Logf("(dbg) daemon: %v", cmd.Args) stdoutPipe, err := cmd.StdoutPipe() From 9fd88800b949546251fce3fb75ad5c273a431e47 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 27 May 2020 15:59:34 -0700 Subject: [PATCH 49/51] revert code --- test/integration/helpers.go | 1 + 1 file changed, 1 insertion(+) diff --git a/test/integration/helpers.go b/test/integration/helpers.go index e7e9c218ab..cc3036a7e9 100644 --- a/test/integration/helpers.go +++ b/test/integration/helpers.go @@ -122,6 +122,7 @@ type StartSession struct { func Start(t *testing.T, cmd *exec.Cmd) (*StartSession, error) { t.Helper() t.Logf("(dbg) daemon: %v", cmd.Args) + stdoutPipe, err := cmd.StdoutPipe() if err != nil { t.Fatalf("stdout pipe failed: %v %v", cmd.Args, err) From 30a714ad2fec687632d7523d80483d1ae0b67321 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 27 May 2020 16:47:52 -0700 Subject: [PATCH 50/51] address review comment --- test/integration/fn_mount_cmd.go | 16 ++++++++-------- test/integration/fn_pvc.go | 10 +++++----- test/integration/fn_tunnel_cmd.go | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/test/integration/fn_mount_cmd.go b/test/integration/fn_mount_cmd.go index 986a3d2bbb..f6e218d8a4 100644 --- a/test/integration/fn_mount_cmd.go +++ b/test/integration/fn_mount_cmd.go @@ -62,10 +62,10 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { t.Fatalf("Unexpected error while creating tempDir: %v", err) } - mctx, cancel := context.WithTimeout(ctx, Minutes(10)) + ctx, cancel := context.WithTimeout(ctx, Minutes(10)) args := []string{"mount", "-p", profile, fmt.Sprintf("%s:%s", tempDir, guestMount), "--alsologtostderr", "-v=1"} - ss, err := Start(t, exec.CommandContext(mctx, Target(), args...)) + ss, err := Start(t, exec.CommandContext(ctx, Target(), args...)) if err != nil { t.Fatalf("%v failed: %v", args, err) } @@ -107,7 +107,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { // Block until the mount succeeds to avoid file race checkMount := func() error { - _, err := Run(t, exec.CommandContext(mctx, Target(), "-p", profile, "ssh", "findmnt -T /mount-9p | grep 9p")) + _, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "findmnt -T /mount-9p | grep 9p")) return err } @@ -121,7 +121,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { } // Assert that we can access the mount without an error. Display for debugging. - rr, err := Run(t, exec.CommandContext(mctx, Target(), "-p", profile, "ssh", "--", "ls", "-la", guestMount)) + rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "--", "ls", "-la", guestMount)) if err != nil { t.Fatalf("failed verifying accessing to the mount. args %q : %v", rr.Command(), err) } @@ -129,7 +129,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { // Assert that the mount contains our unique test marker, as opposed to a stale mount tp := filepath.Join("/mount-9p", testMarker) - rr, err = Run(t, exec.CommandContext(mctx, Target(), "-p", profile, "ssh", "cat", tp)) + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat", tp)) if err != nil { t.Fatalf("failed to verify the mount contains unique test marked: args %q: %v", rr.Command(), err) } @@ -140,12 +140,12 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { } // Start the "busybox-mount" pod. - rr, err = Run(t, exec.CommandContext(mctx, "kubectl", "--context", profile, "replace", "--force", "-f", filepath.Join(*testdataDir, "busybox-mount-test.yaml"))) + rr, err = Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "replace", "--force", "-f", filepath.Join(*testdataDir, "busybox-mount-test.yaml"))) if err != nil { t.Fatalf("failed to 'kubectl replace' for busybox-mount-test. args %q : %v", rr.Command(), err) } - if _, err := PodWait(mctx, t, profile, "default", "integration-test=busybox-mount", Minutes(4)); err != nil { + if _, err := PodWait(ctx, t, profile, "default", "integration-test=busybox-mount", Minutes(4)); err != nil { t.Fatalf("failed waiting for busybox-mount pod: %v", err) } @@ -161,7 +161,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { } // test that file written from host was read in by the pod via cat /mount-9p/written-by-host; - rr, err = Run(t, exec.CommandContext(mctx, "kubectl", "--context", profile, "logs", "busybox-mount")) + rr, err = Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "logs", "busybox-mount")) if err != nil { t.Errorf("failed to get kubectl logs for busybox-mount. args %q : %v", rr.Command(), err) } diff --git a/test/integration/fn_pvc.go b/test/integration/fn_pvc.go index 5e6421d4fe..18f573d3bd 100644 --- a/test/integration/fn_pvc.go +++ b/test/integration/fn_pvc.go @@ -36,15 +36,15 @@ import ( func validatePersistentVolumeClaim(ctx context.Context, t *testing.T, profile string) { defer PostMortemLogs(t, profile) - mctx, cancel := context.WithTimeout(ctx, Minutes(10)) + ctx, cancel := context.WithTimeout(ctx, Minutes(10)) defer cancel() - if _, err := PodWait(mctx, t, profile, "kube-system", "integration-test=storage-provisioner", Minutes(4)); err != nil { + if _, err := PodWait(ctx, t, profile, "kube-system", "integration-test=storage-provisioner", Minutes(4)); err != nil { t.Fatalf("failed waiting for storage-provisioner: %v", err) } checkStorageClass := func() error { - rr, err := Run(t, exec.CommandContext(mctx, "kubectl", "--context", profile, "get", "storageclass", "-o=json")) + rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "get", "storageclass", "-o=json")) if err != nil { return err } @@ -64,13 +64,13 @@ func validatePersistentVolumeClaim(ctx context.Context, t *testing.T, profile st } // Now create a testpvc - rr, err := Run(t, exec.CommandContext(mctx, "kubectl", "--context", profile, "apply", "-f", filepath.Join(*testdataDir, "pvc.yaml"))) + rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "apply", "-f", filepath.Join(*testdataDir, "pvc.yaml"))) if err != nil { t.Fatalf("kubectl apply pvc.yaml failed: args %q: %v", rr.Command(), err) } checkStoragePhase := func() error { - rr, err := Run(t, exec.CommandContext(mctx, "kubectl", "--context", profile, "get", "pvc", "testpvc", "-o=json")) + rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "get", "pvc", "testpvc", "-o=json")) if err != nil { return err } diff --git a/test/integration/fn_tunnel_cmd.go b/test/integration/fn_tunnel_cmd.go index 1efe109b0c..f7fb587724 100644 --- a/test/integration/fn_tunnel_cmd.go +++ b/test/integration/fn_tunnel_cmd.go @@ -49,7 +49,7 @@ var ( ) func validateTunnelCmd(ctx context.Context, t *testing.T, profile string) { - mctx, cancel := context.WithTimeout(ctx, Minutes(5)) + ctx, cancel := context.WithTimeout(ctx, Minutes(5)) type validateFunc func(context.Context, *testing.T, string) defer cancel() @@ -70,7 +70,7 @@ func validateTunnelCmd(ctx context.Context, t *testing.T, profile string) { for _, tc := range tests { tc := tc t.Run(tc.name, func(t *testing.T) { - tc.validator(mctx, t, profile) + tc.validator(ctx, t, profile) }) } }) From c861d4a280ad566b9c0d58fbb1551122af56f8a6 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 27 May 2020 16:50:37 -0700 Subject: [PATCH 51/51] address review --- test/integration/fn_tunnel_cmd.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/integration/fn_tunnel_cmd.go b/test/integration/fn_tunnel_cmd.go index f7fb587724..e990b02778 100644 --- a/test/integration/fn_tunnel_cmd.go +++ b/test/integration/fn_tunnel_cmd.go @@ -49,7 +49,7 @@ var ( ) func validateTunnelCmd(ctx context.Context, t *testing.T, profile string) { - ctx, cancel := context.WithTimeout(ctx, Minutes(5)) + ctx, cancel := context.WithTimeout(ctx, Minutes(20)) type validateFunc func(context.Context, *testing.T, string) defer cancel() @@ -117,6 +117,7 @@ func getKubeDNSIP(t *testing.T, profile string) string { // validateTunnelStart starts `minikube tunnel` func validateTunnelStart(ctx context.Context, t *testing.T, profile string) { checkRoutePassword(t) + args := []string{"-p", profile, "tunnel", "--alsologtostderr"} ss, err := Start(t, exec.CommandContext(ctx, Target(), args...)) if err != nil {