Skip to content

Commit 13ae28b

Browse files
committed
Speed up resize test suite: only test rollback for a subset of cases
1 parent f557903 commit 13ae28b

File tree

1 file changed

+35
-24
lines changed

1 file changed

+35
-24
lines changed

test/e2e/common/node/pod_resize.go

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,16 @@ func doPodResizeTests(f *framework.Framework) {
122122
patchString string
123123
expected []e2epod.ResizableContainerInfo
124124
addExtendedResource bool
125+
// TODO(123940): test rollback for all test cases once resize is more responsive.
126+
testRollback bool
125127
}
126128

127129
noRestart := v1.NotRequired
128130
doRestart := v1.RestartContainer
129131
tests := []testCase{
130132
{
131-
name: "Guaranteed QoS pod, one container - increase CPU & memory",
133+
name: "Guaranteed QoS pod, one container - increase CPU & memory",
134+
testRollback: true,
132135
containers: []e2epod.ResizableContainerInfo{
133136
{
134137
Name: "c1",
@@ -208,7 +211,8 @@ func doPodResizeTests(f *framework.Framework) {
208211
},
209212
},
210213
{
211-
name: "Guaranteed QoS pod, three containers (c1, c2, c3) - increase: CPU (c1,c3), memory (c2) ; decrease: CPU (c2), memory (c1,c3)",
214+
name: "Guaranteed QoS pod, three containers (c1, c2, c3) - increase: CPU (c1,c3), memory (c2) ; decrease: CPU (c2), memory (c1,c3)",
215+
testRollback: true,
212216
containers: []e2epod.ResizableContainerInfo{
213217
{
214218
Name: "c1",
@@ -256,7 +260,8 @@ func doPodResizeTests(f *framework.Framework) {
256260
},
257261
},
258262
{
259-
name: "Burstable QoS pod, one container with cpu & memory requests + limits - decrease memory requests only",
263+
name: "Burstable QoS pod, one container with cpu & memory requests + limits - decrease memory requests only",
264+
testRollback: true,
260265
containers: []e2epod.ResizableContainerInfo{
261266
{
262267
Name: "c1",
@@ -274,7 +279,8 @@ func doPodResizeTests(f *framework.Framework) {
274279
},
275280
},
276281
{
277-
name: "Burstable QoS pod, one container with cpu & memory requests + limits - decrease memory limits only",
282+
name: "Burstable QoS pod, one container with cpu & memory requests + limits - decrease memory limits only",
283+
testRollback: true,
278284
containers: []e2epod.ResizableContainerInfo{
279285
{
280286
Name: "c1",
@@ -328,7 +334,8 @@ func doPodResizeTests(f *framework.Framework) {
328334
},
329335
},
330336
{
331-
name: "Burstable QoS pod, one container with cpu & memory requests + limits - decrease CPU requests only",
337+
name: "Burstable QoS pod, one container with cpu & memory requests + limits - decrease CPU requests only",
338+
testRollback: true,
332339
containers: []e2epod.ResizableContainerInfo{
333340
{
334341
Name: "c1",
@@ -346,7 +353,8 @@ func doPodResizeTests(f *framework.Framework) {
346353
},
347354
},
348355
{
349-
name: "Burstable QoS pod, one container with cpu & memory requests + limits - decrease CPU limits only",
356+
name: "Burstable QoS pod, one container with cpu & memory requests + limits - decrease CPU limits only",
357+
testRollback: true,
350358
containers: []e2epod.ResizableContainerInfo{
351359
{
352360
Name: "c1",
@@ -634,7 +642,8 @@ func doPodResizeTests(f *framework.Framework) {
634642
},
635643
},
636644
{
637-
name: "Guaranteed QoS pod, one container - increase CPU (NotRequired) & memory (RestartContainer)",
645+
name: "Guaranteed QoS pod, one container - increase CPU (NotRequired) & memory (RestartContainer)",
646+
testRollback: true,
638647
containers: []e2epod.ResizableContainerInfo{
639648
{
640649
Name: "c1",
@@ -657,7 +666,8 @@ func doPodResizeTests(f *framework.Framework) {
657666
},
658667
},
659668
{
660-
name: "Burstable QoS pod, one container - decrease CPU (RestartContainer) & memory (NotRequired)",
669+
name: "Burstable QoS pod, one container - decrease CPU (RestartContainer) & memory (NotRequired)",
670+
testRollback: true,
661671
containers: []e2epod.ResizableContainerInfo{
662672
{
663673
Name: "c1",
@@ -850,8 +860,6 @@ func doPodResizeTests(f *framework.Framework) {
850860
},
851861
}
852862

853-
timeouts := f.Timeouts
854-
855863
for idx := range tests {
856864
tc := tests[idx]
857865
ginkgo.It(tc.name, func(ctx context.Context) {
@@ -862,7 +870,8 @@ func doPodResizeTests(f *framework.Framework) {
862870
tStamp := strconv.Itoa(time.Now().Nanosecond())
863871
e2epod.InitDefaultResizePolicy(tc.containers)
864872
e2epod.InitDefaultResizePolicy(tc.expected)
865-
testPod = e2epod.MakePodWithResizableContainers(f.Namespace.Name, "testpod", tStamp, tc.containers)
873+
testPod = e2epod.MakePodWithResizableContainers(f.Namespace.Name, "", tStamp, tc.containers)
874+
testPod.GenerateName = "resize-test-"
866875
testPod = e2epod.MustMixinRestrictedPodSecurity(testPod)
867876

868877
if tc.addExtendedResource {
@@ -908,22 +917,24 @@ func doPodResizeTests(f *framework.Framework) {
908917

909918
patchAndVerify(tc.patchString, tc.expected, "resize")
910919

911-
// Resize has been actuated, test rollback
912-
rollbackContainers := make([]e2epod.ResizableContainerInfo, len(tc.containers))
913-
copy(rollbackContainers, tc.containers)
914-
for i, c := range rollbackContainers {
915-
gomega.Expect(c.Name).To(gomega.Equal(tc.expected[i].Name),
916-
"test case containers & expectations should be in the same order")
917-
// Resizes that trigger a restart should trigger a second restart when rolling back.
918-
rollbackContainers[i].RestartCount = tc.expected[i].RestartCount * 2
919-
}
920+
if tc.testRollback {
921+
// Resize has been actuated, test rollback
922+
rollbackContainers := make([]e2epod.ResizableContainerInfo, len(tc.containers))
923+
copy(rollbackContainers, tc.containers)
924+
for i, c := range rollbackContainers {
925+
gomega.Expect(c.Name).To(gomega.Equal(tc.expected[i].Name),
926+
"test case containers & expectations should be in the same order")
927+
// Resizes that trigger a restart should trigger a second restart when rolling back.
928+
rollbackContainers[i].RestartCount = tc.expected[i].RestartCount * 2
929+
}
920930

921-
rbPatchStr, err := e2epod.ResizeContainerPatch(tc.containers)
922-
framework.ExpectNoError(err)
923-
patchAndVerify(rbPatchStr, rollbackContainers, "rollback")
931+
rbPatchStr, err := e2epod.ResizeContainerPatch(tc.containers)
932+
framework.ExpectNoError(err)
933+
patchAndVerify(rbPatchStr, rollbackContainers, "rollback")
934+
}
924935

925936
ginkgo.By("deleting pod")
926-
podClient.DeleteSync(ctx, newPod.Name, metav1.DeleteOptions{}, timeouts.PodDelete)
937+
framework.ExpectNoError(podClient.Delete(ctx, newPod.Name, metav1.DeleteOptions{}))
927938
})
928939
}
929940
}

0 commit comments

Comments
 (0)