From b5cef55af5176c91c8b59b67999de959dfa405c0 Mon Sep 17 00:00:00 2001 From: Random-Liu Date: Thu, 30 Jun 2016 17:00:22 -0700 Subject: [PATCH] fix pull image test flake --- test/e2e_node/runtime_conformance_test.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/test/e2e_node/runtime_conformance_test.go b/test/e2e_node/runtime_conformance_test.go index 6d74482d05e..eb91f891db6 100644 --- a/test/e2e_node/runtime_conformance_test.go +++ b/test/e2e_node/runtime_conformance_test.go @@ -261,14 +261,22 @@ while true; do sleep 1; done Expect(container.Create()).To(Succeed()) defer container.Delete() - By("check the pod phase") - Eventually(container.GetPhase, retryTimeout, pollInterval).Should(Equal(testCase.phase)) - Consistently(container.GetPhase, consistentCheckTimeout, pollInterval).Should(Equal(testCase.phase)) - + // We need to check container state first. The default pod status is pending, If we check + // pod phase first, and the expected pod phase is Pending, the container status may not + // even show up when we check it. By("check the container state") - status, err := container.GetStatus() - Expect(err).NotTo(HaveOccurred()) - Expect(GetContainerState(status.State)).To(Equal(testCase.state)) + getState := func() (ContainerState, error) { + status, err := container.GetStatus() + if err != nil { + return ContainerStateUnknown, err + } + return GetContainerState(status.State), nil + } + Eventually(getState, retryTimeout, pollInterval).Should(Equal(testCase.state)) + Consistently(getState, consistentCheckTimeout, pollInterval).Should(Equal(testCase.state)) + + By("check the pod phase") + Expect(container.GetPhase()).To(Equal(testCase.phase)) By("it should be possible to delete") Expect(container.Delete()).To(Succeed())