Refactor e2e tests to use testify y httpexpect
This commit is contained in:
parent
046e2d959d
commit
f9624cbe46
80 changed files with 2280 additions and 2631 deletions
|
|
@ -18,13 +18,12 @@ package loadbalance
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/parnurzeal/gorequest"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"k8s.io/ingress-nginx/test/e2e/framework"
|
||||
)
|
||||
|
|
@ -32,12 +31,12 @@ import (
|
|||
var _ = framework.DescribeSetting("[Load Balancer] round-robin", func() {
|
||||
f := framework.NewDefaultFramework("round-robin")
|
||||
|
||||
BeforeEach(func() {
|
||||
ginkgo.BeforeEach(func() {
|
||||
f.NewEchoDeploymentWithReplicas(3)
|
||||
f.UpdateNginxConfigMapData("worker-processes", "1")
|
||||
})
|
||||
|
||||
It("should evenly distribute requests with round-robin (default algorithm)", func() {
|
||||
ginkgo.It("should evenly distribute requests with round-robin (default algorithm)", func() {
|
||||
host := "load-balance.com"
|
||||
|
||||
f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil))
|
||||
|
|
@ -50,14 +49,14 @@ var _ = framework.DescribeSetting("[Load Balancer] round-robin", func() {
|
|||
replicaRequestCount := map[string]int{}
|
||||
|
||||
for i := 0; i < 600; i++ {
|
||||
_, body, errs := gorequest.New().
|
||||
Get(f.GetURL(framework.HTTP)).
|
||||
Set("Host", host).
|
||||
End()
|
||||
Expect(errs).Should(BeEmpty())
|
||||
body := f.HTTPTestClient().
|
||||
GET("/").
|
||||
WithHeader("Host", host).
|
||||
Expect().
|
||||
Status(http.StatusOK).Body().Raw()
|
||||
|
||||
replica := re.FindString(body)
|
||||
Expect(replica).ShouldNot(Equal(""))
|
||||
assert.NotEmpty(ginkgo.GinkgoT(), replica)
|
||||
|
||||
if _, ok := replicaRequestCount[replica]; !ok {
|
||||
replicaRequestCount[replica] = 1
|
||||
|
|
@ -67,7 +66,7 @@ var _ = framework.DescribeSetting("[Load Balancer] round-robin", func() {
|
|||
}
|
||||
|
||||
for _, v := range replicaRequestCount {
|
||||
Expect(v).Should(Equal(200))
|
||||
assert.Equal(ginkgo.GinkgoT(), v, 200)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue