Deflake startupProbe e2e test

Co-authored-by: Sergey Kanzhelev <S.Kanzhelev@live.com>
This commit is contained in:
Matthias Bertschy 2021-03-09 10:52:47 +01:00
parent 78862bf971
commit bcd582030f

View File

@ -402,7 +402,9 @@ var _ = SIGDescribe("Probing container", func() {
readinessProbe := &v1.Probe{ readinessProbe := &v1.Probe{
Handler: execHandler([]string{"/bin/cat", "/tmp/health"}), Handler: execHandler([]string{"/bin/cat", "/tmp/health"}),
InitialDelaySeconds: 0, InitialDelaySeconds: 0,
PeriodSeconds: 60, // PeriodSeconds is set to a large value to make sure that the first execution of readiness probe
// will happen before the first period passed.
PeriodSeconds: 600,
} }
startupProbe := &v1.Probe{ startupProbe := &v1.Probe{
Handler: execHandler([]string{"/bin/cat", "/tmp/startup"}), Handler: execHandler([]string{"/bin/cat", "/tmp/startup"}),
@ -416,13 +418,11 @@ var _ = SIGDescribe("Probing container", func() {
err = e2epod.WaitForPodContainerStarted(f.ClientSet, f.Namespace.Name, p.Name, 0, framework.PodStartTimeout) err = e2epod.WaitForPodContainerStarted(f.ClientSet, f.Namespace.Name, p.Name, 0, framework.PodStartTimeout)
framework.ExpectNoError(err) framework.ExpectNoError(err)
startedTime := time.Now()
// We assume the pod became ready when the container became ready. This // We assume the pod became ready when the container became ready. This
// is true for a single container pod. // is true for a single container pod.
err = e2epod.WaitTimeoutForPodReadyInNamespace(f.ClientSet, p.Name, f.Namespace.Name, framework.PodStartTimeout) err = e2epod.WaitTimeoutForPodReadyInNamespace(f.ClientSet, p.Name, f.Namespace.Name, framework.PodStartTimeout)
framework.ExpectNoError(err) framework.ExpectNoError(err)
readyTime := time.Now()
p, err = podClient.Get(context.TODO(), p.Name, metav1.GetOptions{}) p, err = podClient.Get(context.TODO(), p.Name, metav1.GetOptions{})
framework.ExpectNoError(err) framework.ExpectNoError(err)
@ -430,15 +430,6 @@ var _ = SIGDescribe("Probing container", func() {
isReady, err := testutils.PodRunningReady(p) isReady, err := testutils.PodRunningReady(p)
framework.ExpectNoError(err) framework.ExpectNoError(err)
framework.ExpectEqual(isReady, true, "pod should be ready") framework.ExpectEqual(isReady, true, "pod should be ready")
readyIn := readyTime.Sub(startedTime)
framework.Logf("Container started at %v, pod became ready at %v, %v after startupProbe succeeded", startedTime, readyTime, readyIn)
if readyIn < 0 {
framework.Failf("Pod became ready before startupProbe succeeded")
}
if readyIn > 5*time.Second {
framework.Failf("Pod became ready in %v, more than 5s after startupProbe succeeded. It means that the delay readiness probes were not initiated immediately after startup finished.", readyIn)
}
}) })
/* /*