mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
kubelet: add e2e test for exec readiness probe timeout
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
This commit is contained in:
parent
733862ed7f
commit
81ad32e3a4
@ -223,6 +223,23 @@ var _ = framework.KubeDescribe("Probing container", func() {
|
|||||||
RunLivenessTest(f, pod, 1, defaultObservationTimeout)
|
RunLivenessTest(f, pod, 1, defaultObservationTimeout)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
Release: v1.20
|
||||||
|
Testname: Pod readiness probe, docker exec, not ready
|
||||||
|
Description: A Pod is created with readiness probe with a Exec action on the Pod. If the readiness probe call does not return within the timeout specified, readiness probe MUST not be Ready.
|
||||||
|
*/
|
||||||
|
ginkgo.It("should not be ready with a docker exec readiness probe timeout ", func() {
|
||||||
|
cmd := []string{"/bin/sh", "-c", "sleep 600"}
|
||||||
|
readinessProbe := &v1.Probe{
|
||||||
|
Handler: execHandler([]string{"/bin/sh", "-c", "sleep 10"}),
|
||||||
|
InitialDelaySeconds: 15,
|
||||||
|
TimeoutSeconds: 1,
|
||||||
|
FailureThreshold: 1,
|
||||||
|
}
|
||||||
|
pod := busyBoxPodSpec(readinessProbe, nil, cmd)
|
||||||
|
runReadinessFailTest(f, pod, time.Minute)
|
||||||
|
})
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Release: v1.14
|
Release: v1.14
|
||||||
Testname: Pod http liveness probe, redirected to a local address
|
Testname: Pod http liveness probe, redirected to a local address
|
||||||
@ -622,3 +639,35 @@ func RunLivenessTest(f *framework.Framework, pod *v1.Pod, expectNumRestarts int,
|
|||||||
ns, pod.Name, expectNumRestarts, observedRestarts)
|
ns, pod.Name, expectNumRestarts, observedRestarts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func runReadinessFailTest(f *framework.Framework, pod *v1.Pod, notReadyUntil time.Duration) {
|
||||||
|
podClient := f.PodClient()
|
||||||
|
ns := f.Namespace.Name
|
||||||
|
gomega.Expect(pod.Spec.Containers).NotTo(gomega.BeEmpty())
|
||||||
|
|
||||||
|
// At the end of the test, clean up by removing the pod.
|
||||||
|
defer func() {
|
||||||
|
ginkgo.By("deleting the pod")
|
||||||
|
podClient.Delete(context.TODO(), pod.Name, *metav1.NewDeleteOptions(0))
|
||||||
|
}()
|
||||||
|
ginkgo.By(fmt.Sprintf("Creating pod %s in namespace %s", pod.Name, ns))
|
||||||
|
podClient.Create(pod)
|
||||||
|
|
||||||
|
// Wait until the pod is not pending. (Here we need to check for something other than
|
||||||
|
// 'Pending', since when failures occur, we go to 'Terminated' which can cause indefinite blocking.)
|
||||||
|
framework.ExpectNoError(e2epod.WaitForPodNotPending(f.ClientSet, ns, pod.Name),
|
||||||
|
fmt.Sprintf("starting pod %s in namespace %s", pod.Name, ns))
|
||||||
|
framework.Logf("Started pod %s in namespace %s", pod.Name, ns)
|
||||||
|
|
||||||
|
// Wait for the not ready state to be true for notReadyUntil duration
|
||||||
|
deadline := time.Now().Add(notReadyUntil)
|
||||||
|
for start := time.Now(); time.Now().Before(deadline); time.Sleep(2 * time.Second) {
|
||||||
|
// poll for Not Ready
|
||||||
|
if podutil.IsPodReady(pod) {
|
||||||
|
framework.Failf("pod %s/%s - expected to be not ready", ns, pod.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
framework.Logf("pod %s/%s is not ready (%v elapsed)",
|
||||||
|
ns, pod.Name, time.Since(start))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user