Skip to content

Commit

Permalink
Create tests to ensure custom addon images persist.
Browse files Browse the repository at this point in the history
  • Loading branch information
andriyDev committed May 17, 2021
1 parent 9ed3311 commit 36ffe39
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions test/integration/addons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
}

0 comments on commit 36ffe39

Please sign in to comment.