fix
parent
83053359f6
commit
dd6ab66e19
|
@ -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"))
|
||||
}
|
||||
if ctx.Err() == context.DeadlineExceeded {
|
||||
t.Errorf("failed to run command by deadline. exceeded timeout : %s", rr.Command())
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
// 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
|
||||
|
|
Loading…
Reference in New Issue