Add container lifecycle hook test.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -1456,6 +1456,7 @@ func waitForPodTerminatedInNamespace(c *client.Client, podName, reason, namespac
|
||||
func waitForPodSuccessInNamespaceTimeout(c *client.Client, podName string, contName string, namespace string, timeout time.Duration) error {
|
||||
return waitForPodCondition(c, namespace, podName, "success or failure", timeout, func(pod *api.Pod) (bool, error) {
|
||||
// Cannot use pod.Status.Phase == api.PodSucceeded/api.PodFailed due to #2632
|
||||
// TODO: This was not true from long time ago. We can use api.PodSucceeded now.
|
||||
ci, ok := api.GetContainerStatus(pod.Status.ContainerStatuses, contName)
|
||||
if !ok {
|
||||
Logf("No Status.Info for container '%s' in pod '%s' yet", contName, podName)
|
||||
|
||||
Reference in New Issue
Block a user