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:
Filipe Brandenburger
2015-01-22 08:15:36 -08:00
parent 6aea499f38
commit df6ab47c6e
3 changed files with 117 additions and 0 deletions

View File

@@ -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++ {