Merge pull request #3407 from Shopify/rr-e2e

Restructure load balance e2e tests and update round robin test
This commit is contained in:
k8s-ci-robot 2018-11-12 08:48:02 -08:00 committed by GitHub
commit 01a343cd09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 13 deletions

View file

@ -33,6 +33,7 @@ import (
// tests to run // tests to run
_ "k8s.io/ingress-nginx/test/e2e/annotations" _ "k8s.io/ingress-nginx/test/e2e/annotations"
_ "k8s.io/ingress-nginx/test/e2e/defaultbackend" _ "k8s.io/ingress-nginx/test/e2e/defaultbackend"
_ "k8s.io/ingress-nginx/test/e2e/loadbalance"
_ "k8s.io/ingress-nginx/test/e2e/lua" _ "k8s.io/ingress-nginx/test/e2e/lua"
_ "k8s.io/ingress-nginx/test/e2e/servicebackend" _ "k8s.io/ingress-nginx/test/e2e/servicebackend"
_ "k8s.io/ingress-nginx/test/e2e/settings" _ "k8s.io/ingress-nginx/test/e2e/settings"

View file

@ -17,10 +17,8 @@ limitations under the License.
package settings package settings
import ( import (
"net/http"
"regexp" "regexp"
"strings" "strings"
"time"
"github.com/parnurzeal/gorequest" "github.com/parnurzeal/gorequest"
@ -30,25 +28,22 @@ import (
"k8s.io/ingress-nginx/test/e2e/framework" "k8s.io/ingress-nginx/test/e2e/framework"
) )
var _ = framework.IngressNginxDescribe("Load Balance", func() { var _ = framework.IngressNginxDescribe("Load Balance - Round Robin", func() {
f := framework.NewDefaultFramework("load-balance") f := framework.NewDefaultFramework("round-robin")
setting := "load-balance"
BeforeEach(func() { BeforeEach(func() {
f.NewEchoDeploymentWithReplicas(3) f.NewEchoDeploymentWithReplicas(3)
f.UpdateNginxConfigMapData("worker-processes", "1")
}) })
AfterEach(func() { AfterEach(func() {
f.UpdateNginxConfigMapData(setting, "") f.UpdateNginxConfigMapData("worker-processes", "")
}) })
It("should evenly distribute requests with round-robin (default algorithm)", func() { It("should evenly distribute requests with round-robin (default algorithm)", func() {
host := "load-balance.com" host := "load-balance.com"
f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, nil)) f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, nil))
f.WaitForNginxServer(host, f.WaitForNginxServer(host,
func(server string) bool { func(server string) bool {
return strings.Contains(server, "server_name load-balance.com") return strings.Contains(server, "server_name load-balance.com")
@ -61,9 +56,8 @@ var _ = framework.IngressNginxDescribe("Load Balance", func() {
_, body, errs := gorequest.New(). _, body, errs := gorequest.New().
Get(f.IngressController.HTTPURL). Get(f.IngressController.HTTPURL).
Set("Host", host). Set("Host", host).
Retry(10, 1*time.Second, http.StatusNotFound, http.StatusServiceUnavailable).
End() End()
Expect(len(errs)).Should(BeNumerically("==", 0)) Expect(errs).Should(BeEmpty())
replica := re.FindString(body) replica := re.FindString(body)
Expect(replica).ShouldNot(Equal("")) Expect(replica).ShouldNot(Equal(""))
@ -75,9 +69,8 @@ var _ = framework.IngressNginxDescribe("Load Balance", func() {
} }
} }
acceptableRequestRange := []int{198, 199, 200, 201, 202}
for _, v := range replicaRequestCount { for _, v := range replicaRequestCount {
Expect(acceptableRequestRange).Should(ContainElement(v)) Expect(v).Should(Equal(200))
} }
}) })
}) })