From 2eb0286c8aca36fc56ecaf464499ebe89d7ef096 Mon Sep 17 00:00:00 2001 From: Elvin Efendi Date: Wed, 16 May 2018 19:05:49 -0400 Subject: [PATCH] fix flaky test --- test/e2e/lua/dynamic_configuration.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/test/e2e/lua/dynamic_configuration.go b/test/e2e/lua/dynamic_configuration.go index c44f56043..2eccb6ea4 100644 --- a/test/e2e/lua/dynamic_configuration.go +++ b/test/e2e/lua/dynamic_configuration.go @@ -18,6 +18,7 @@ package lua import ( "fmt" + "math/rand" "net/http" "regexp" "strings" @@ -253,14 +254,21 @@ var _ = framework.IngressNginxDescribe("Dynamic Configuration", func() { Expect(newUpstreamName).Should(Equal(upstreamName)) } - resp, body, errs = gorequest.New(). - Get(fmt.Sprintf("%s?completely-different-path", f.IngressController.HTTPURL)). - Set("Host", "foo.com"). - End() - Expect(len(errs)).Should(Equal(0)) - Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - anotherUpstreamName := hostnamePattern.FindAllStringSubmatch(body, -1)[0][1] - Expect(anotherUpstreamName).NotTo(Equal(upstreamName)) + notEqualFound := false + for i := 0; i < 5; i++ { + resp, body, errs = gorequest.New(). + Get(fmt.Sprintf("%s?completely-different-path=%f", f.IngressController.HTTPURL, rand.Float64())). + Set("Host", "foo.com"). + End() + Expect(len(errs)).Should(Equal(0)) + Expect(resp.StatusCode).Should(Equal(http.StatusOK)) + anotherUpstreamName := hostnamePattern.FindAllStringSubmatch(body, -1)[0][1] + notEqualFound = anotherUpstreamName != upstreamName + if notEqualFound { + break + } + } + Expect(notEqualFound).Should(Equal(true)) }) Context("when session affinity annotation is present", func() {