From 2eb0286c8aca36fc56ecaf464499ebe89d7ef096 Mon Sep 17 00:00:00 2001 From: Elvin Efendi Date: Wed, 16 May 2018 19:05:49 -0400 Subject: [PATCH 1/2] 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() { From c7de5a5bf678f94d5e7b6d07219c76796c807879 Mon Sep 17 00:00:00 2001 From: Elvin Efendi Date: Wed, 16 May 2018 19:19:38 -0400 Subject: [PATCH 2/2] do not assert on random behaviour --- test/e2e/lua/dynamic_configuration.go | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/test/e2e/lua/dynamic_configuration.go b/test/e2e/lua/dynamic_configuration.go index 2eccb6ea4..e4cbda154 100644 --- a/test/e2e/lua/dynamic_configuration.go +++ b/test/e2e/lua/dynamic_configuration.go @@ -18,7 +18,6 @@ package lua import ( "fmt" - "math/rand" "net/http" "regexp" "strings" @@ -253,22 +252,6 @@ var _ = framework.IngressNginxDescribe("Dynamic Configuration", func() { newUpstreamName := hostnamePattern.FindAllStringSubmatch(body, -1)[0][1] Expect(newUpstreamName).Should(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() {