From 03384a5d988f6948d4728b0a723e4cc2b0a794f5 Mon Sep 17 00:00:00 2001 From: Steven Powell Date: Mon, 25 Sep 2023 15:16:15 -0700 Subject: [PATCH] add nvidia-device-plugin test --- test/integration/addons_test.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/integration/addons_test.go b/test/integration/addons_test.go index 40e3fee39e05..af8fd5a969cb 100644 --- a/test/integration/addons_test.go +++ b/test/integration/addons_test.go @@ -78,7 +78,7 @@ func TestAddons(t *testing.T) { // so we override that here to let minikube auto-detect appropriate cgroup driver os.Setenv(constants.MinikubeForceSystemdEnv, "") - args := append([]string{"start", "-p", profile, "--wait=true", "--memory=4000", "--alsologtostderr", "--addons=registry", "--addons=metrics-server", "--addons=volumesnapshots", "--addons=csi-hostpath-driver", "--addons=gcp-auth", "--addons=cloud-spanner", "--addons=inspektor-gadget"}, StartArgs()...) + args := append([]string{"start", "-p", profile, "--wait=true", "--memory=4000", "--alsologtostderr", "--addons=registry", "--addons=metrics-server", "--addons=volumesnapshots", "--addons=csi-hostpath-driver", "--addons=gcp-auth", "--addons=cloud-spanner", "--addons=inspektor-gadget", "--addons=nvidia-device-plugin"}, StartArgs()...) if !NoneDriver() { // none driver does not support ingress args = append(args, "--addons=ingress", "--addons=ingress-dns") } @@ -111,6 +111,7 @@ func TestAddons(t *testing.T) { {"CSI", validateCSIDriverAndSnapshots}, {"Headlamp", validateHeadlampAddon}, {"CloudSpanner", validateCloudSpannerAddon}, + {"NvidiaDevicePlugin", validateNvidiaDevicePlugin}, } for _, tc := range tests { tc := tc @@ -837,3 +838,15 @@ func validateCloudSpannerAddon(ctx context.Context, t *testing.T, profile string t.Errorf("failed to disable cloud-spanner addon: args %q : %v", rr.Command(), err) } } + +// 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 PostMortemLogs(t, profile) + + if _, err := PodWait(ctx, t, profile, "kube-system", "nvidia-device-plugin-ds", Minutes(1)); 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) + } +}