Add container lifecycle hook test.

This commit is contained in:
Random-Liu
2016-09-23 13:36:37 -07:00
parent 72524e45b5
commit 5eb41e9acb
4 changed files with 201 additions and 2 deletions

View File

@@ -149,3 +149,19 @@ func (c *PodClient) mungeSpec(pod *api.Pod) {
}
// TODO(random-liu): Move pod wait function into this file
// WaitForSuccess waits for pod to success.
func (c *PodClient) WaitForSuccess(name string, timeout time.Duration) {
f := c.f
Expect(waitForPodCondition(f.Client, f.Namespace.Name, name, "success or failure", timeout,
func(pod *api.Pod) (bool, error) {
switch pod.Status.Phase {
case api.PodFailed:
return true, fmt.Errorf("pod %q failed with reason: %q, message: %q", name, pod.Status.Reason, pod.Status.Message)
case api.PodSucceeded:
return true, nil
default:
return false, nil
}
},
)).To(Succeed(), "wait for pod %q to success", name)
}