mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-10 13:42:02 +00:00
Convert liveness e2e test to Go
This commit reimplements hack/e2e-suite/liveness.sh in Go as part of cmd/e2e. Tested by running it on a live cluster: $ cmd/e2e --host=https://w.x.y.z --provider=gce -t TestLivenessHttp -t TestLivenessExec I0122 08:12:53.183298 6502 liveness.go:72] Restart count of pod liveness-exec-6f917474-a251-11e4-8cc2-d4ae52bb3eea increased from 0 to 1 during the test I0122 08:13:23.605471 6502 liveness.go:72] Restart count of pod liveness-http-84d28569-a251-11e4-8cc2-d4ae52bb3eea increased from 0 to 1 during the test Also ran the full e2e suite including kube-up/kube-down to confirm it works.
This commit is contained in:
@@ -54,6 +54,27 @@ func waitForPodRunning(c *client.Client, id string) {
|
||||
}
|
||||
}
|
||||
|
||||
// waitForPodNotPending returns false if it took too long for the pod to go out of pending state.
|
||||
func waitForPodNotPending(c *client.Client, podName string) bool {
|
||||
for i := 0; i < 10; i++ {
|
||||
if i > 0 {
|
||||
time.Sleep(5 * time.Second)
|
||||
}
|
||||
pod, err := c.Pods(api.NamespaceDefault).Get(podName)
|
||||
if err != nil {
|
||||
glog.Warningf("Get pod %s failed: %v", podName, err)
|
||||
continue
|
||||
}
|
||||
if pod.Status.Phase != api.PodPending {
|
||||
glog.Infof("Saw pod %s out of pending state (found %q)", podName, pod.Status.Phase)
|
||||
return true
|
||||
}
|
||||
glog.Infof("Waiting for pod %s status to be !%q (found %q)", podName, api.PodPending, pod.Status.Phase)
|
||||
}
|
||||
glog.Warningf("Gave up waiting for pod %s status to go out of pending", podName)
|
||||
return false
|
||||
}
|
||||
|
||||
// waitForPodSuccess returns true if the pod reached state success, or false if it reached failure or ran too long.
|
||||
func waitForPodSuccess(c *client.Client, podName string, contName string) bool {
|
||||
for i := 0; i < 10; i++ {
|
||||
|
Reference in New Issue
Block a user