Remove hard-coded timeout in e2e tests

This commit is contained in:
Manuel Alejandro de Brito Fontes 2020-01-26 21:01:52 -03:00
parent d9983cb387
commit 68bfbd939b
10 changed files with 5 additions and 72 deletions

View file

@ -57,7 +57,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions",
func(server string) bool {
return strings.Contains(server, fmt.Sprintf("server_name %s ;", host))
})
time.Sleep(waitForLuaSync)
resp, _, errs := gorequest.New().
Get(f.GetURL(framework.HTTP)).
@ -83,7 +82,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions",
func(server string) bool {
return strings.Contains(server, fmt.Sprintf("server_name %s ;", host))
})
time.Sleep(waitForLuaSync)
resp, _, errs := gorequest.New().
Get(f.GetURL(framework.HTTP)).
@ -97,8 +95,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions",
ing.ObjectMeta.Annotations["nginx.ingress.kubernetes.io/session-cookie-name"] = "OTHERCOOKIENAME"
f.EnsureIngress(ing)
time.Sleep(waitForLuaSync)
resp, _, errs = gorequest.New().
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
@ -123,7 +119,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions",
func(server string) bool {
return strings.Contains(server, fmt.Sprintf("server_name %s ;", host))
})
time.Sleep(waitForLuaSync)
resp, _, errs := gorequest.New().
Get(f.GetURL(framework.HTTP)+"/something").
@ -181,7 +176,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions",
func(server string) bool {
return strings.Contains(server, fmt.Sprintf("server_name %s ;", host))
})
time.Sleep(waitForLuaSync)
resp, _, errs := gorequest.New().
Get(f.GetURL(framework.HTTP)+"/something").
@ -218,7 +212,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions",
func(server string) bool {
return strings.Contains(server, fmt.Sprintf("server_name %s ;", host))
})
time.Sleep(waitForLuaSync)
resp, _, errs := gorequest.New().
Get(f.GetURL(framework.HTTP)).
@ -254,7 +247,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions",
func(server string) bool {
return strings.Contains(server, fmt.Sprintf("server_name %s ;", host))
})
time.Sleep(waitForLuaSync)
resp, _, errs := gorequest.New().
Get(f.GetURL(framework.HTTP)+"/foo/bar").
@ -282,7 +274,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions",
func(server string) bool {
return strings.Contains(server, fmt.Sprintf("server_name %s ;", host))
})
time.Sleep(waitForLuaSync)
resp, _, errs := gorequest.New().
Get(f.GetURL(framework.HTTP)+"/foo/bar").
@ -313,7 +304,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions",
func(server string) bool {
return strings.Contains(server, `location /foo/bar`) && strings.Contains(server, `location /foo`)
})
time.Sleep(waitForLuaSync)
resp, _, errs := gorequest.New().
Get(f.GetURL(framework.HTTP)+"/foo").
@ -347,7 +337,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions",
func(server string) bool {
return strings.Contains(server, "server_name _")
})
time.Sleep(waitForLuaSync)
resp, _, errs := gorequest.New().
Get(f.GetURL(framework.HTTP)).

View file

@ -19,7 +19,6 @@ package annotations
import (
"fmt"
"net/http"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@ -29,8 +28,6 @@ import (
)
const (
waitForLuaSync = 5 * time.Second
canaryService = "echo-canary"
)
@ -68,8 +65,6 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, canaryService, 80, canaryAnnotations)
f.EnsureIngress(canaryIng)
time.Sleep(waitForLuaSync)
resp, body, errs := gorequest.New().
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
@ -96,8 +91,6 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
f.EnsureIngress(canaryIng)
time.Sleep(waitForLuaSync)
resp, _, errs := gorequest.New().
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
@ -135,7 +128,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
80, canaryAnnotations)
f.EnsureIngress(canaryIng)
time.Sleep(waitForLuaSync)
By("returning a 503 status when the mainline deployment has 0 replicas and a request is sent to the canary")
@ -189,8 +182,6 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
80, canaryAnnotations)
f.EnsureIngress(canaryIng)
time.Sleep(waitForLuaSync)
By("routing requests destined for the mainline ingress to the maineline upstream")
resp, body, errs := gorequest.New().
Get(f.GetURL(framework.HTTP)).
@ -230,8 +221,6 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
80, canaryAnnotations)
f.EnsureIngress(canaryIng)
time.Sleep(waitForLuaSync)
annotations := map[string]string{}
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations)
@ -290,8 +279,6 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
80, canaryAnnotations)
f.EnsureIngress(canaryIng)
time.Sleep(waitForLuaSync)
modAnnotations := map[string]string{
"foo": "bar",
}
@ -354,8 +341,6 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
80, canaryAnnotations)
f.EnsureIngress(canaryIng)
time.Sleep(waitForLuaSync)
modCanaryAnnotations := map[string]string{
"nginx.ingress.kubernetes.io/canary": "true",
"nginx.ingress.kubernetes.io/canary-by-header": "CanaryByHeader2",
@ -364,8 +349,6 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
modCanaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, canaryService, 80, modCanaryAnnotations)
f.EnsureIngress(modCanaryIng)
time.Sleep(waitForLuaSync)
By("routing requests destined for the mainline ingress to the mainline upstream")
resp, body, errs := gorequest.New().
@ -417,8 +400,6 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
80, canaryAnnotations)
f.EnsureIngress(canaryIng)
time.Sleep(waitForLuaSync)
By("routing requests to the canary upstream when header is set to 'always'")
resp, body, errs := gorequest.New().
@ -484,8 +465,6 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
80, canaryAnnotations)
f.EnsureIngress(canaryIng)
time.Sleep(waitForLuaSync)
By("routing requests to the canary upstream when header is set to 'DoCanary'")
resp, body, errs := gorequest.New().
@ -565,8 +544,6 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
80, canaryAnnotations)
f.EnsureIngress(canaryIng)
time.Sleep(waitForLuaSync)
By("routing requests to the canary upstream when header value does not match and cookie is set to 'always'")
resp, body, errs := gorequest.New().
Get(f.GetURL(framework.HTTP)).
@ -605,8 +582,6 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
80, canaryAnnotations)
f.EnsureIngress(canaryIng)
time.Sleep(waitForLuaSync)
By("routing requests to the canary upstream when cookie is set to 'always'")
resp, body, errs := gorequest.New().
Get(f.GetURL(framework.HTTP)).
@ -671,8 +646,6 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
80, canaryAnnotations)
f.EnsureIngress(canaryIng)
time.Sleep(waitForLuaSync)
By("returning requests from the mainline only when weight is equal to 0")
resp, body, errs := gorequest.New().
@ -696,8 +669,6 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
f.EnsureIngress(modCanaryIng)
time.Sleep(waitForLuaSync)
resp, body, errs = gorequest.New().
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
@ -751,8 +722,6 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
ing = framework.NewSingleIngress(otherHost, "/", otherHost, f.Namespace, framework.EchoService, 80, nil)
f.EnsureIngress(ing)
time.Sleep(waitForLuaSync)
f.WaitForNginxConfiguration(func(cfg string) bool {
return Expect(cfg).Should(ContainSubstring("server_name "+otherHost)) &&
Expect(cfg).ShouldNot(ContainSubstring("server_name "+host))

View file

@ -19,7 +19,6 @@ package annotations
import (
"fmt"
"net/http"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@ -45,8 +44,6 @@ var _ = framework.IngressNginxDescribe("Annotations - custom default-backend", f
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "invalid", 80, annotations)
f.EnsureIngress(ing)
time.Sleep(5 * time.Second)
f.WaitForNginxServer(host,
func(server string) bool {
return Expect(server).Should(ContainSubstring(fmt.Sprintf("server_name %v", host)))