Skip to content

Commit 903d6d4

Browse files
committed
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.
1 parent 1f056f8 commit 903d6d4

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

test/e2e/common/node/pod_resize.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func offsetMemory(index int64, value string) string {
6969
return ptr.String()
7070
}
7171

72-
func doPodResizeTests() {
72+
func doPodResizeTests(f *framework.Framework) {
7373
type testCase struct {
7474
name string
7575
containers []podresize.ResizableContainerInfo
@@ -1157,7 +1157,6 @@ func doPodResizeTests() {
11571157

11581158
for idx := range tests {
11591159
tc := tests[idx]
1160-
f := framework.NewDefaultFramework("pod-resize-tests")
11611160

11621161
ginkgo.It(tc.name, func(ctx context.Context) {
11631162
podClient := e2epod.NewPodClient(f)
@@ -1235,7 +1234,7 @@ func doPodResizeTests() {
12351234
}
12361235
}
12371236

1238-
func doPodResizeErrorTests() {
1237+
func doPodResizeErrorTests(f *framework.Framework) {
12391238

12401239
type testCase struct {
12411240
name string
@@ -1390,7 +1389,6 @@ func doPodResizeErrorTests() {
13901389

13911390
for idx := range tests {
13921391
tc := tests[idx]
1393-
f := framework.NewDefaultFramework("pod-resize-error-tests")
13941392

13951393
ginkgo.It(tc.name, func(ctx context.Context) {
13961394
podClient := e2epod.NewPodClient(f)
@@ -1453,6 +1451,6 @@ var _ = SIGDescribe("Pod InPlace Resize Container", framework.WithFeatureGate(fe
14531451
}
14541452
})
14551453

1456-
doPodResizeTests()
1457-
doPodResizeErrorTests()
1454+
doPodResizeTests(f)
1455+
doPodResizeErrorTests(f)
14581456
})

test/e2e/node/pod_resize.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import (
4040
"github.com/onsi/gomega"
4141
)
4242

43-
func doPodResizeAdmissionPluginsTests() {
43+
func doPodResizeAdmissionPluginsTests(f *framework.Framework) {
4444
testcases := []struct {
4545
name string
4646
enableAdmissionPlugin func(ctx context.Context, f *framework.Framework)
@@ -119,8 +119,6 @@ func doPodResizeAdmissionPluginsTests() {
119119
}
120120

121121
for _, tc := range testcases {
122-
f := framework.NewDefaultFramework(tc.name)
123-
124122
ginkgo.It(tc.name, func(ctx context.Context) {
125123
containers := []podresize.ResizableContainerInfo{
126124
{
@@ -459,7 +457,7 @@ var _ = SIGDescribe("Pod InPlace Resize Container", framework.WithFeatureGate(fe
459457
e2eskipper.Skipf("runtime does not support InPlacePodVerticalScaling -- skipping")
460458
}
461459
})
462-
doPodResizeAdmissionPluginsTests()
460+
doPodResizeAdmissionPluginsTests(f)
463461
})
464462

465463
func waitForResourceQuota(ctx context.Context, c clientset.Interface, ns, quotaName string) error {

0 commit comments

Comments
 (0)