diff --git a/test/integration/addons_test.go b/test/integration/addons_test.go index 369ca992710a..a4738a80db74 100644 --- a/test/integration/addons_test.go +++ b/test/integration/addons_test.go @@ -99,6 +99,7 @@ func TestAddons(t *testing.T) { } } + type validateFunc func(context.Context, *testing.T, string) // Parallelized tests t.Run("parallel", func(t *testing.T) { tests := []struct { @@ -711,3 +712,58 @@ func validateGCPAuthAddon(ctx context.Context, t *testing.T, profile string) { t.Errorf("failed disabling gcp-auth addon. arg %q.s %v", rr.Command(), err) } } + +func TestAddonsPersistAfterRestart(t *testing.T) { + profile := UniqueProfileName("addons") + ctx, cancel := context.WithTimeout(context.Background(), Minutes(10)) + defer Cleanup(t, profile, cancel) + + rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "start")) + if err != nil { + t.Fatalf("failed to start minikube. arg %q.s %v", rr.Command(), err) + } + + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "addons", "enable", "dashboard", "--images=Dashboard=k8s.gcr.io/echoserver:1.4", "--stderrthreshold=1")) + if err != nil { + t.Fatalf("failed to enable dashboard addon. arg %q.s %v", rr.Command(), err) + } + + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "stop")) + if err != nil { + t.Fatalf("failed to stop minikube. arg %q.s %v", rr.Command(), err) + } + + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "start")) + if err != nil { + t.Fatalf("failed to start minikube. arg %q.s %v", rr.Command(), err) + } + output := rr.Stdout.String() + if !strings.Contains(output, "echoserver") { + t.Fatalf("echoserver image not loaded on start. minikube start output: %s", output) + } +} + +func TestAddonsPersistPriorToStart(t *testing.T) { + profile := UniqueProfileName("addons") + ctx, cancel := context.WithTimeout(context.Background(), Minutes(10)) + defer Cleanup(t, profile, cancel) + + rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "start", "--download-only")) + if err != nil { + t.Fatalf("failed to create minikube profile. arg %q.s %v", rr.Command(), err) + } + + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "addons", "enable", "dashboard", "--images=Dashboard=k8s.gcr.io/echoserver:1.4")) + if err != nil { + t.Fatalf("failed to enable dashboard addon. arg %q.s %v", rr.Command(), err) + } + + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "start")) + if err != nil { + t.Fatalf("failed to start minikube. arg %q.s %v", rr.Command(), err) + } + output := rr.Stdout.String() + if !strings.Contains(output, "echoserver") { + t.Fatalf("echoserver image not loaded on start. minikube start output: %s", output) + } +}