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
|
|
@ -21,31 +21,30 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/parnurzeal/gorequest"
|
||||
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/stretchr/testify/assert"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
|
||||
"k8s.io/ingress-nginx/test/e2e/framework"
|
||||
)
|
||||
|
||||
var _ = framework.DescribeAnnotation("influxdb-*", func() {
|
||||
f := framework.NewDefaultFramework("influxdb")
|
||||
|
||||
BeforeEach(func() {
|
||||
ginkgo.BeforeEach(func() {
|
||||
f.NewInfluxDBDeployment()
|
||||
f.NewEchoDeployment()
|
||||
})
|
||||
|
||||
Context("when influxdb is enabled", func() {
|
||||
It("should send the request metric to the influxdb server", func() {
|
||||
ginkgo.Context("when influxdb is enabled", func() {
|
||||
ginkgo.It("should send the request metric to the influxdb server", func() {
|
||||
ifs := createInfluxDBService(f)
|
||||
|
||||
// Ingress configured with InfluxDB annotations
|
||||
|
|
@ -66,13 +65,11 @@ var _ = framework.DescribeAnnotation("influxdb-*", func() {
|
|||
|
||||
// Do a request to the echo server ingress that sends metrics
|
||||
// to the InfluxDB backend.
|
||||
res, _, errs := gorequest.New().
|
||||
Get(f.GetURL(framework.HTTP)).
|
||||
Set("Host", host).
|
||||
End()
|
||||
|
||||
Expect(len(errs)).Should(Equal(0))
|
||||
Expect(res.StatusCode).Should(Equal(http.StatusOK))
|
||||
f.HTTPTestClient().
|
||||
GET("/").
|
||||
WithHeader("Host", host).
|
||||
Expect().
|
||||
Status(http.StatusOK)
|
||||
|
||||
time.Sleep(10 * time.Second)
|
||||
|
||||
|
|
@ -86,14 +83,14 @@ var _ = framework.DescribeAnnotation("influxdb-*", func() {
|
|||
}
|
||||
return true, nil
|
||||
})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
assert.Nil(ginkgo.GinkgoT(), err)
|
||||
|
||||
var results map[string][]map[string]interface{}
|
||||
_ = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(measurements), &results)
|
||||
|
||||
Expect(len(measurements)).ShouldNot(Equal(0))
|
||||
assert.NotEqual(ginkgo.GinkgoT(), len(measurements), 0)
|
||||
for _, elem := range results["results"] {
|
||||
Expect(len(elem)).ShouldNot(Equal(0))
|
||||
assert.NotEqual(ginkgo.GinkgoT(), len(elem), 0)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
@ -128,7 +125,7 @@ func createInfluxDBIngress(f *framework.Framework, host, service string, port in
|
|||
|
||||
f.WaitForNginxServer(host,
|
||||
func(server string) bool {
|
||||
return Expect(server).Should(ContainSubstring(fmt.Sprintf("server_name %v", host)))
|
||||
return strings.Contains(server, fmt.Sprintf("server_name %v", host))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue