Merge branch 'master' of github.com:kubernetes/minikube into native-ssh
commit
e2ec890c7d
|
@ -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,50 +330,10 @@ 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) {
|
||||
if NoneDriver() {
|
||||
t.Skipf("Skipping none driver, olm addon is not supported on none driver")
|
||||
}
|
||||
defer PostMortemLogs(t, profile)
|
||||
|
||||
client, err := kapi.Client(profile)
|
||||
|
|
|
@ -154,24 +154,43 @@ 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(13))
|
||||
mctx, cancel := context.WithTimeout(ctx, Seconds(30))
|
||||
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" {
|
||||
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
|
||||
rr, err = Run(t, c)
|
||||
}
|
||||
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 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())
|
||||
}
|
||||
|
||||
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
|
||||
c = exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" docker-env) && docker images")
|
||||
rr, err = Run(t, c)
|
||||
if runtime.GOOS == "windows" { // testing docker-env eval in powershell
|
||||
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)
|
||||
}
|
||||
|
||||
if mctx.Err() == context.DeadlineExceeded {
|
||||
t.Errorf("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)
|
||||
}
|
||||
|
@ -319,7 +338,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)
|
||||
|
||||
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)
|
||||
|
@ -507,7 +525,8 @@ 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
|
||||
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)
|
||||
}
|
||||
|
@ -812,12 +831,36 @@ 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"
|
||||
rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", fmt.Sprintf("echo hello")))
|
||||
|
||||
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 {
|
||||
t.Errorf("failed to run an ssh command. args %q : %v", rr.Command(), err)
|
||||
}
|
||||
// trailing whitespace differs between native and external SSH clients, so let's trim it and call it a day
|
||||
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 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 something inside minikube, that is meaningful per profile
|
||||
// in this case /etc/hostname is same as the profile name
|
||||
want = profile
|
||||
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())
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("failed to run an ssh command. args %q : %v", rr.Command(), err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue