From 903d6d4f0304e1e5f88086d9cac96b938a4fc3c9 Mon Sep 17 00:00:00 2001 From: kevinrizza Date: Tue, 29 Apr 2025 09:17:40 -0400 Subject: [PATCH] Don't reinitialize test framework during each test case This commit updates pod resize tests to resolve an issue where extraneous unused namespaces are created when the tests are run. This happens because a new instance of the test framework is generated when looping over the test specs, registering BeforeEach each time. --- test/e2e/common/node/pod_resize.go | 10 ++++------ test/e2e/node/pod_resize.go | 6 ++---- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/test/e2e/common/node/pod_resize.go b/test/e2e/common/node/pod_resize.go index 3c0cae3d88d..2109439ceb9 100644 --- a/test/e2e/common/node/pod_resize.go +++ b/test/e2e/common/node/pod_resize.go @@ -69,7 +69,7 @@ func offsetMemory(index int64, value string) string { return ptr.String() } -func doPodResizeTests() { +func doPodResizeTests(f *framework.Framework) { type testCase struct { name string containers []podresize.ResizableContainerInfo @@ -1157,7 +1157,6 @@ func doPodResizeTests() { for idx := range tests { tc := tests[idx] - f := framework.NewDefaultFramework("pod-resize-tests") ginkgo.It(tc.name, func(ctx context.Context) { podClient := e2epod.NewPodClient(f) @@ -1235,7 +1234,7 @@ func doPodResizeTests() { } } -func doPodResizeErrorTests() { +func doPodResizeErrorTests(f *framework.Framework) { type testCase struct { name string @@ -1390,7 +1389,6 @@ func doPodResizeErrorTests() { for idx := range tests { tc := tests[idx] - f := framework.NewDefaultFramework("pod-resize-error-tests") ginkgo.It(tc.name, func(ctx context.Context) { podClient := e2epod.NewPodClient(f) @@ -1453,6 +1451,6 @@ var _ = SIGDescribe("Pod InPlace Resize Container", framework.WithFeatureGate(fe } }) - doPodResizeTests() - doPodResizeErrorTests() + doPodResizeTests(f) + doPodResizeErrorTests(f) }) diff --git a/test/e2e/node/pod_resize.go b/test/e2e/node/pod_resize.go index d460b94820c..68f859bf51d 100644 --- a/test/e2e/node/pod_resize.go +++ b/test/e2e/node/pod_resize.go @@ -40,7 +40,7 @@ import ( "github.com/onsi/gomega" ) -func doPodResizeAdmissionPluginsTests() { +func doPodResizeAdmissionPluginsTests(f *framework.Framework) { testcases := []struct { name string enableAdmissionPlugin func(ctx context.Context, f *framework.Framework) @@ -119,8 +119,6 @@ func doPodResizeAdmissionPluginsTests() { } for _, tc := range testcases { - f := framework.NewDefaultFramework(tc.name) - ginkgo.It(tc.name, func(ctx context.Context) { containers := []podresize.ResizableContainerInfo{ { @@ -459,7 +457,7 @@ var _ = SIGDescribe("Pod InPlace Resize Container", framework.WithFeatureGate(fe e2eskipper.Skipf("runtime does not support InPlacePodVerticalScaling -- skipping") } }) - doPodResizeAdmissionPluginsTests() + doPodResizeAdmissionPluginsTests(f) }) func waitForResourceQuota(ctx context.Context, c clientset.Interface, ns, quotaName string) error {