From 183562d79ab5823ddf43951ffac97ed8fbbd6700 Mon Sep 17 00:00:00 2001 From: Phillip Wittrock Date: Mon, 21 Mar 2016 10:20:48 -0700 Subject: [PATCH] node e2e conformance keep polling if encounters errors --- test/e2e_node/conformance_test.go | 33 +++++++++++-------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/test/e2e_node/conformance_test.go b/test/e2e_node/conformance_test.go index a3c4b46d53..9afb0b692c 100644 --- a/test/e2e_node/conformance_test.go +++ b/test/e2e_node/conformance_test.go @@ -28,7 +28,8 @@ import ( ) const ( - serviceCreateTimeout = 2 * time.Minute + retryTimeout = 4 * time.Minute + pollInterval = time.Second * 5 ) var _ = Describe("Container Conformance Test", func() { @@ -97,7 +98,7 @@ var _ = Describe("Container Conformance Test", func() { }) Context("when running a container that terminates", func() { var terminateCase ConformanceContainer - It("it should start successfully [Conformance]", func() { + It("it should run successfully to completion [Conformance]", func() { terminateCase = ConformanceContainer{ Container: api.Container{ Image: "gcr.io/google_containers/busybox", @@ -112,15 +113,11 @@ var _ = Describe("Container Conformance Test", func() { err := terminateCase.Create() Expect(err).NotTo(HaveOccurred()) - phase := api.PodPending - for start := time.Now(); time.Since(start) < serviceCreateTimeout; time.Sleep(time.Second * 30) { - ccontainer, err := terminateCase.Get() - if err != nil || ccontainer.Phase != api.PodPending { - phase = ccontainer.Phase - break - } - } - Expect(phase).Should(Equal(terminateCase.Phase)) + // TODO: Check that the container enters running state by sleeping in the container #23309 + Eventually(func() (api.PodPhase, error) { + pod, err := terminateCase.Get() + return pod.Phase, err + }, retryTimeout, pollInterval).Should(Equal(terminateCase.Phase)) }) It("it should report its phase as 'succeeded' [Conformance]", func() { ccontainer, err := terminateCase.Get() @@ -148,16 +145,10 @@ var _ = Describe("Container Conformance Test", func() { } err := invalidImageCase.Create() Expect(err).NotTo(HaveOccurred()) - - phase := api.PodPending - for start := time.Now(); time.Since(start) < serviceCreateTimeout; time.Sleep(time.Second * 30) { - ccontainer, err := invalidImageCase.Get() - if err != nil || ccontainer.Phase != api.PodPending { - phase = ccontainer.Phase - break - } - } - Expect(phase).Should(Equal(invalidImageCase.Phase)) + Eventually(func() (api.PodPhase, error) { + pod, err := invalidImageCase.Get() + return pod.Phase, err + }, retryTimeout, pollInterval).Should(Equal(invalidImageCase.Phase)) }) It("it should report its phase as 'pending' [Conformance]", func() { ccontainer, err := invalidImageCase.Get()