Skip to content

Commit e03d0f6

Browse files
committed
Orient tests to run faster, but tolerate infra slowdowns up to 5 minutes
Signed-off-by: Laura Lorenz <[email protected]>
1 parent d293c50 commit e03d0f6

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

test/e2e_node/container_restart_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727

2828
"github.com/onsi/ginkgo/v2"
2929
"github.com/onsi/gomega"
30+
"github.com/pkg/errors"
3031
kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config"
3132

3233
v1 "k8s.io/api/core/v1"
@@ -59,7 +60,7 @@ var _ = SIGDescribe("Container Restart", feature.CriProxy, framework.WithSerial(
5960

6061
ginkgo.It("Container restart backs off.", func(ctx context.Context) {
6162
// 0s, 0s, 10s, 30s, 70s, 150s, 310s
62-
doTest(ctx, f, 5, containerName, 7)
63+
doTest(ctx, f, 3, containerName, 7)
6364
})
6465
})
6566

@@ -82,8 +83,8 @@ var _ = SIGDescribe("Container Restart", feature.CriProxy, framework.WithSerial(
8283
})
8384

8485
ginkgo.It("Alternate restart backs off.", func(ctx context.Context) {
85-
// 0s, 0s, 10s, 30s, 60s, 90s, 120s, 150, 180, 210)
86-
doTest(ctx, f, 7, containerName, 10)
86+
// 0s, 0s, 10s, 30s, 60s, 90s, 120s, 150s, 180s, 210s, 240s, 270s, 300s
87+
doTest(ctx, f, 3, containerName, 13)
8788
})
8889
})
8990
})
@@ -94,8 +95,9 @@ func doTest(ctx context.Context, f *framework.Framework, targetRestarts int, con
9495
podErr := e2epod.WaitForPodContainerToFail(ctx, f.ClientSet, f.Namespace.Name, pod.Name, 0, "CrashLoopBackOff", 1*time.Minute)
9596
gomega.Expect(podErr).To(gomega.HaveOccurred())
9697

97-
// Wait for 210s worth of backoffs to occur so we can confirm the backoff growth.
98-
podErr = e2epod.WaitForContainerRestartedNTimes(ctx, f.ClientSet, f.Namespace.Name, pod.Name, containerName, 210*time.Second, targetRestarts)
98+
// Hard wait 30 seconds for targetRestarts in the best case; longer timeout later will handle if infra was slow.
99+
time.Sleep(30 * time.Second)
100+
podErr = e2epod.WaitForContainerRestartedNTimes(ctx, f.ClientSet, f.Namespace.Name, pod.Name, containerName, 5*time.Minute, targetRestarts)
99101
gomega.Expect(podErr).ShouldNot(gomega.HaveOccurred(), "Expected container to repeatedly back off container failures")
100102

101103
r, err := extractObservedBackoff(ctx, f, pod.Name, containerName)
@@ -117,7 +119,7 @@ func extractObservedBackoff(ctx context.Context, f *framework.Framework, podName
117119
}
118120
}
119121
}
120-
return r, nil
122+
return r, errors.Errorf("Could not find container status for container %s in pod %s", containerName, podName)
121123
}
122124

123125
func newFailAlwaysPod() *v1.Pod {

test/e2e_node/image_pull_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,15 @@ var _ = SIGDescribe("Pull Image", feature.CriProxy, framework.WithSerial(), func
257257
isExpectedErrMsg := strings.Contains(eventMsg, expectedErr.Error())
258258
gomega.Expect(isExpectedErrMsg).To(gomega.BeTrueBecause("we injected an exception into the PullImage interface of the cri proxy"))
259259

260-
// Wait for ~60s worth of backoffs to occur so we can confirm the backoff growth.
261-
podErr = e2epod.WaitForPodContainerStarted(ctx, f.ClientSet, f.Namespace.Name, pod.Name, 0, 1*time.Minute)
260+
podErr = e2epod.WaitForPodContainerStarted(ctx, f.ClientSet, f.Namespace.Name, pod.Name, 0, 30*time.Second)
262261
gomega.Expect(podErr).To(gomega.HaveOccurred(), "Expected container not to start from repeatedly backing off image pulls")
263262

264263
e, err := getImagePullAttempts(ctx, f, pod.Name)
265264
framework.ExpectNoError(err)
266-
// 3 would take 10s best case
265+
// 3 would take 10s best case.
267266
gomega.Expect(e.Count).Should(gomega.BeNumerically(">", 3))
268-
// 6 would take 150s best case
269-
gomega.Expect(e.Count).Should(gomega.BeNumerically("<=", 6))
267+
// 7 would take 310s best case, if the infra went slow.
268+
gomega.Expect(e.Count).Should(gomega.BeNumerically("<=", 7))
270269

271270
})
272271

0 commit comments

Comments
 (0)