Speed up resize test suite: only test rollback for a subset of cases

This commit is contained in:
Tim Allclair 2024-11-03 12:34:30 -08:00
parent f557903263
commit 13ae28bd67

View File

@ -122,6 +122,8 @@ func doPodResizeTests(f *framework.Framework) {
patchString string
expected []e2epod.ResizableContainerInfo
addExtendedResource bool
// TODO(123940): test rollback for all test cases once resize is more responsive.
testRollback bool
}
noRestart := v1.NotRequired
@ -129,6 +131,7 @@ func doPodResizeTests(f *framework.Framework) {
tests := []testCase{
{
name: "Guaranteed QoS pod, one container - increase CPU & memory",
testRollback: true,
containers: []e2epod.ResizableContainerInfo{
{
Name: "c1",
@ -209,6 +212,7 @@ func doPodResizeTests(f *framework.Framework) {
},
{
name: "Guaranteed QoS pod, three containers (c1, c2, c3) - increase: CPU (c1,c3), memory (c2) ; decrease: CPU (c2), memory (c1,c3)",
testRollback: true,
containers: []e2epod.ResizableContainerInfo{
{
Name: "c1",
@ -257,6 +261,7 @@ func doPodResizeTests(f *framework.Framework) {
},
{
name: "Burstable QoS pod, one container with cpu & memory requests + limits - decrease memory requests only",
testRollback: true,
containers: []e2epod.ResizableContainerInfo{
{
Name: "c1",
@ -275,6 +280,7 @@ func doPodResizeTests(f *framework.Framework) {
},
{
name: "Burstable QoS pod, one container with cpu & memory requests + limits - decrease memory limits only",
testRollback: true,
containers: []e2epod.ResizableContainerInfo{
{
Name: "c1",
@ -329,6 +335,7 @@ func doPodResizeTests(f *framework.Framework) {
},
{
name: "Burstable QoS pod, one container with cpu & memory requests + limits - decrease CPU requests only",
testRollback: true,
containers: []e2epod.ResizableContainerInfo{
{
Name: "c1",
@ -347,6 +354,7 @@ func doPodResizeTests(f *framework.Framework) {
},
{
name: "Burstable QoS pod, one container with cpu & memory requests + limits - decrease CPU limits only",
testRollback: true,
containers: []e2epod.ResizableContainerInfo{
{
Name: "c1",
@ -635,6 +643,7 @@ func doPodResizeTests(f *framework.Framework) {
},
{
name: "Guaranteed QoS pod, one container - increase CPU (NotRequired) & memory (RestartContainer)",
testRollback: true,
containers: []e2epod.ResizableContainerInfo{
{
Name: "c1",
@ -658,6 +667,7 @@ func doPodResizeTests(f *framework.Framework) {
},
{
name: "Burstable QoS pod, one container - decrease CPU (RestartContainer) & memory (NotRequired)",
testRollback: true,
containers: []e2epod.ResizableContainerInfo{
{
Name: "c1",
@ -850,8 +860,6 @@ func doPodResizeTests(f *framework.Framework) {
},
}
timeouts := f.Timeouts
for idx := range tests {
tc := tests[idx]
ginkgo.It(tc.name, func(ctx context.Context) {
@ -862,7 +870,8 @@ func doPodResizeTests(f *framework.Framework) {
tStamp := strconv.Itoa(time.Now().Nanosecond())
e2epod.InitDefaultResizePolicy(tc.containers)
e2epod.InitDefaultResizePolicy(tc.expected)
testPod = e2epod.MakePodWithResizableContainers(f.Namespace.Name, "testpod", tStamp, tc.containers)
testPod = e2epod.MakePodWithResizableContainers(f.Namespace.Name, "", tStamp, tc.containers)
testPod.GenerateName = "resize-test-"
testPod = e2epod.MustMixinRestrictedPodSecurity(testPod)
if tc.addExtendedResource {
@ -908,6 +917,7 @@ func doPodResizeTests(f *framework.Framework) {
patchAndVerify(tc.patchString, tc.expected, "resize")
if tc.testRollback {
// Resize has been actuated, test rollback
rollbackContainers := make([]e2epod.ResizableContainerInfo, len(tc.containers))
copy(rollbackContainers, tc.containers)
@ -921,9 +931,10 @@ func doPodResizeTests(f *framework.Framework) {
rbPatchStr, err := e2epod.ResizeContainerPatch(tc.containers)
framework.ExpectNoError(err)
patchAndVerify(rbPatchStr, rollbackContainers, "rollback")
}
ginkgo.By("deleting pod")
podClient.DeleteSync(ctx, newPod.Name, metav1.DeleteOptions{}, timeouts.PodDelete)
framework.ExpectNoError(podClient.Delete(ctx, newPod.Name, metav1.DeleteOptions{}))
})
}
}