From 4634246391420bf0a43aa50193be337eff15a6db Mon Sep 17 00:00:00 2001 From: Marcin Wielgus Date: Thu, 24 Sep 2015 20:03:43 +0200 Subject: [PATCH] E2E test - check pod.Status.Phase when greping through pod logs --- test/e2e/examples.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/test/e2e/examples.go b/test/e2e/examples.go index 0c2efba36e..286e4e6e1b 100644 --- a/test/e2e/examples.go +++ b/test/e2e/examples.go @@ -562,22 +562,26 @@ func prepareResourceWithReplacedString(inputFile, old, new string) string { } func forEachPod(c *client.Client, ns, selectorKey, selectorValue string, fn func(api.Pod)) { - var pods *api.PodList - var err error + pods := []*api.Pod{} for t := time.Now(); time.Since(t) < podListTimeout; time.Sleep(poll) { - pods, err = c.Pods(ns).List(labels.SelectorFromSet(labels.Set(map[string]string{selectorKey: selectorValue})), fields.Everything()) + podList, err := c.Pods(ns).List(labels.SelectorFromSet(labels.Set(map[string]string{selectorKey: selectorValue})), fields.Everything()) Expect(err).NotTo(HaveOccurred()) - if len(pods.Items) > 0 { + for _, pod := range podList.Items { + if pod.Status.Phase == api.PodPending || pod.Status.Phase == api.PodRunning { + pods = append(pods, &pod) + } + } + if len(pods) > 0 { break } } - if pods == nil || len(pods.Items) == 0 { + if pods == nil || len(pods) == 0 { Failf("No pods found") } - for _, pod := range pods.Items { - err = waitForPodRunningInNamespace(c, pod.Name, ns) + for _, pod := range pods { + err := waitForPodRunningInNamespace(c, pod.Name, ns) Expect(err).NotTo(HaveOccurred()) - fn(pod) + fn(*pod) } }