Skip to content

Commit

Permalink
testing: Add more addon test disable defers (#19744)
Browse files Browse the repository at this point in the history
  • Loading branch information
spowelljr authored Oct 9, 2024
1 parent 30db4fd commit a220f0e
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions test/integration/addons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ func validateLocalPathAddon(ctx context.Context, t *testing.T, profile string) {
t.Skipf("skip local-path test on none driver")
}
defer disableAddon(t, "storage-provisioner-rancher", profile)
defer PostMortemLogs(t, profile)

// Create a test PVC
rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "apply", "-f", filepath.Join(*testdataDir, "storage-provisioner-rancher", "pvc.yaml")))
Expand Down Expand Up @@ -953,26 +954,21 @@ func validateDisablingAddonOnNonExistingCluster(ctx context.Context, t *testing.

// validateNvidiaDevicePlugin tests the nvidia-device-plugin addon by ensuring the pod comes up and the addon disables
func validateNvidiaDevicePlugin(ctx context.Context, t *testing.T, profile string) {
defer disableAddon(t, "nvidia-device-plugin", profile)
defer PostMortemLogs(t, profile)

if _, err := PodWait(ctx, t, profile, "kube-system", "name=nvidia-device-plugin-ds", Minutes(6)); err != nil {
t.Fatalf("failed waiting for nvidia-device-plugin-ds pod: %v", err)
}
if rr, err := Run(t, exec.CommandContext(ctx, Target(), "addons", "disable", "nvidia-device-plugin", "-p", profile)); err != nil {
t.Errorf("failed to disable nvidia-device-plugin: args %q : %v", rr.Command(), err)
}
}

func validateYakdAddon(ctx context.Context, t *testing.T, profile string) {
defer disableAddon(t, "yakd", profile)
defer PostMortemLogs(t, profile)

if _, err := PodWait(ctx, t, profile, "yakd-dashboard", "app.kubernetes.io/name=yakd-dashboard", Minutes(2)); err != nil {
t.Fatalf("failed waiting for YAKD - Kubernetes Dashboard pod: %v", err)
}

if rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "addons", "disable", "yakd", "--alsologtostderr", "-v=1")); err != nil {
t.Errorf("failed to disable yakd addon: args %q: %v", rr.Command(), err)
}
}

func disableAddon(t *testing.T, addon, profile string) {
Expand Down

0 comments on commit a220f0e

Please sign in to comment.