fix flaky test

This commit is contained in:
Elvin Efendi 2018-05-16 19:05:49 -04:00
parent df61bd7565
commit 2eb0286c8a

View file

@ -18,6 +18,7 @@ package lua
import ( import (
"fmt" "fmt"
"math/rand"
"net/http" "net/http"
"regexp" "regexp"
"strings" "strings"
@ -253,14 +254,21 @@ var _ = framework.IngressNginxDescribe("Dynamic Configuration", func() {
Expect(newUpstreamName).Should(Equal(upstreamName)) Expect(newUpstreamName).Should(Equal(upstreamName))
} }
resp, body, errs = gorequest.New(). notEqualFound := false
Get(fmt.Sprintf("%s?completely-different-path", f.IngressController.HTTPURL)). for i := 0; i < 5; i++ {
Set("Host", "foo.com"). resp, body, errs = gorequest.New().
End() Get(fmt.Sprintf("%s?completely-different-path=%f", f.IngressController.HTTPURL, rand.Float64())).
Expect(len(errs)).Should(Equal(0)) Set("Host", "foo.com").
Expect(resp.StatusCode).Should(Equal(http.StatusOK)) End()
anotherUpstreamName := hostnamePattern.FindAllStringSubmatch(body, -1)[0][1] Expect(len(errs)).Should(Equal(0))
Expect(anotherUpstreamName).NotTo(Equal(upstreamName)) 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() { Context("when session affinity annotation is present", func() {