Refactor e2e tests to use the service ClusterIP

This commit is contained in:
Manuel Alejandro de Brito Fontes 2019-02-22 11:03:42 -03:00
parent f04361cc06
commit 5e249d3366
No known key found for this signature in database
GPG key ID: 786136016A8BA02A
80 changed files with 777 additions and 706 deletions

View file

@ -48,7 +48,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
host := "foo"
annotations := map[string]string{}
ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations)
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations)
f.EnsureIngress(ing)
f.WaitForNginxServer(host,
@ -63,14 +63,14 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
canaryIngName := fmt.Sprintf("%v-canary", host)
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary",
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary",
80, &canaryAnnotations)
f.EnsureIngress(canaryIng)
time.Sleep(waitForLuaSync)
resp, body, errs := gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
End()
@ -90,7 +90,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
canaryIngName := fmt.Sprintf("%v-canary", host)
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary",
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary",
80, &canaryAnnotations)
f.EnsureIngress(canaryIng)
@ -98,7 +98,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
time.Sleep(waitForLuaSync)
resp, _, errs := gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
Set("CanaryByHeader", "always").
End()
@ -115,7 +115,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
host := "foo"
annotations := map[string]string{}
ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations)
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations)
f.EnsureIngress(ing)
f.WaitForNginxServer(host,
@ -130,7 +130,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
canaryIngName := fmt.Sprintf("%v-canary", host)
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary",
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary",
80, &canaryAnnotations)
f.EnsureIngress(canaryIng)
@ -141,7 +141,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
f.NewEchoDeploymentWithReplicas(0)
resp, _, errs := gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
Set("CanaryByHeader", "always").
End()
@ -155,7 +155,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
f.NewDeployment("http-svc-canary", "gcr.io/kubernetes-e2e-test-images/echoserver:2.2", 8080, 0)
resp, _, errs = gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
Set("CanaryByHeader", "never").
End()
@ -169,7 +169,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
host := "foo"
annotations := map[string]string{}
ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations)
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations)
f.EnsureIngress(ing)
f.WaitForNginxServer(host,
@ -184,7 +184,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
canaryIngName := fmt.Sprintf("%v-canary", host)
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary",
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary",
80, &canaryAnnotations)
f.EnsureIngress(canaryIng)
@ -192,7 +192,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
By("routing requests destined for the mainline ingress to the maineline upstream")
resp, body, errs := gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
Set("CanaryByHeader", "never").
End()
@ -205,7 +205,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
By("routing requests destined for the canary ingress to the canary upstream")
resp, body, errs = gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
Set("CanaryByHeader", "always").
End()
@ -225,7 +225,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
canaryIngName := fmt.Sprintf("%v-canary", host)
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary",
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary",
80, &canaryAnnotations)
f.EnsureIngress(canaryIng)
@ -233,7 +233,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
annotations := map[string]string{}
ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations)
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations)
f.EnsureIngress(ing)
f.WaitForNginxServer(host,
@ -243,7 +243,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
By("routing requests destined for the mainline ingress to the mainelin upstream")
resp, body, errs := gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
Set("CanaryByHeader", "never").
End()
@ -256,7 +256,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
By("routing requests destined for the canary ingress to the canary upstream")
resp, body, errs = gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
Set("CanaryByHeader", "always").
End()
@ -270,7 +270,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
host := "foo"
annotations := map[string]string{}
ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations)
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations)
f.EnsureIngress(ing)
f.WaitForNginxServer(host,
@ -285,7 +285,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
canaryIngName := fmt.Sprintf("%v-canary", host)
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary",
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary",
80, &canaryAnnotations)
f.EnsureIngress(canaryIng)
@ -295,7 +295,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
"foo": "bar",
}
modIng := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &modAnnotations)
modIng := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &modAnnotations)
f.EnsureIngress(modIng)
@ -307,7 +307,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
By("routing requests destined fro the mainline ingress to the mainline upstream")
resp, body, errs := gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
Set("CanaryByHeader", "never").
End()
@ -320,7 +320,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
By("routing requests destined for the canary ingress to the canary upstream")
resp, body, errs = gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
Set("CanaryByHeader", "always").
End()
@ -334,7 +334,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
host := "foo"
annotations := map[string]string{}
ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations)
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations)
f.EnsureIngress(ing)
f.WaitForNginxServer(host,
@ -349,7 +349,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
canaryIngName := fmt.Sprintf("%v-canary", host)
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary",
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary",
80, &canaryAnnotations)
f.EnsureIngress(canaryIng)
@ -360,7 +360,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
"nginx.ingress.kubernetes.io/canary-by-header": "CanaryByHeader2",
}
modCanaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary", 80, &modCanaryAnnotations)
modCanaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", 80, &modCanaryAnnotations)
f.EnsureIngress(modCanaryIng)
time.Sleep(waitForLuaSync)
@ -368,7 +368,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
By("routing requests destined for the mainline ingress to the mainline upstream")
resp, body, errs := gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
Set("CanaryByHeader2", "never").
End()
@ -381,7 +381,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
By("routing requests destined for the canary ingress to the canary upstream")
resp, body, errs = gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
Set("CanaryByHeader2", "always").
End()
@ -397,7 +397,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
host := "foo"
annotations := map[string]string{}
ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations)
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations)
f.EnsureIngress(ing)
f.WaitForNginxServer(host,
@ -412,7 +412,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
canaryIngName := fmt.Sprintf("%v-canary", host)
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary",
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary",
80, &canaryAnnotations)
f.EnsureIngress(canaryIng)
@ -421,7 +421,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
By("routing requests to the canary upstream when header is set to 'always'")
resp, body, errs := gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
Set("CanaryByHeader", "always").
End()
@ -433,7 +433,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
By("routing requests to the mainline upstream when header is set to 'never'")
resp, body, errs = gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
Set("CanaryByHeader", "never").
End()
@ -446,7 +446,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
By("routing requests to the mainline upstream when header is set to anything else")
resp, body, errs = gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
Set("CanaryByHeader", "badheadervalue").
End()
@ -463,7 +463,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
host := "foo"
annotations := map[string]string{}
ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations)
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations)
f.EnsureIngress(ing)
f.WaitForNginxServer(host,
@ -479,7 +479,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
canaryIngName := fmt.Sprintf("%v-canary", host)
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary",
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary",
80, &canaryAnnotations)
f.EnsureIngress(canaryIng)
@ -488,7 +488,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
By("routing requests to the canary upstream when header is set to 'DoCanary'")
resp, body, errs := gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
Set("CanaryByHeader", "DoCanary").
End()
@ -500,7 +500,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
By("routing requests to the mainline upstream when header is set to 'always'")
resp, body, errs = gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
Set("CanaryByHeader", "always").
End()
@ -513,7 +513,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
By("routing requests to the mainline upstream when header is set to 'never'")
resp, body, errs = gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
Set("CanaryByHeader", "never").
End()
@ -526,7 +526,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
By("routing requests to the mainline upstream when header is set to anything else")
resp, body, errs = gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
Set("CanaryByHeader", "otherheadervalue").
End()
@ -543,7 +543,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
host := "foo"
annotations := map[string]string{}
ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations)
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations)
f.EnsureIngress(ing)
f.WaitForNginxServer(host,
@ -560,7 +560,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
canaryIngName := fmt.Sprintf("%v-canary", host)
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary",
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary",
80, &canaryAnnotations)
f.EnsureIngress(canaryIng)
@ -568,7 +568,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
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.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
Set("CanaryByHeader", "otherheadervalue").
AddCookie(&http.Cookie{Name: "CanaryByCookie", Value: "always"}).
@ -585,7 +585,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
host := "foo"
annotations := map[string]string{}
ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations)
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations)
f.EnsureIngress(ing)
f.WaitForNginxServer(host,
@ -600,7 +600,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
canaryIngName := fmt.Sprintf("%v-canary", host)
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary",
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary",
80, &canaryAnnotations)
f.EnsureIngress(canaryIng)
@ -608,7 +608,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
By("routing requests to the canary upstream when cookie is set to 'always'")
resp, body, errs := gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
AddCookie(&http.Cookie{Name: "Canary-By-Cookie", Value: "always"}).
End()
@ -620,7 +620,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
By("routing requests to the mainline upstream when cookie is set to 'never'")
resp, body, errs = gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
AddCookie(&http.Cookie{Name: "Canary-By-Cookie", Value: "never"}).
End()
@ -633,7 +633,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
By("routing requests to the mainline upstream when cookie is set to anything else")
resp, body, errs = gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
AddCookie(&http.Cookie{Name: "Canary-By-Cookie", Value: "badcookievalue"}).
End()
@ -651,7 +651,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
host := "foo"
annotations := map[string]string{}
ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations)
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations)
f.EnsureIngress(ing)
f.WaitForNginxServer(host,
@ -666,7 +666,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
canaryIngName := fmt.Sprintf("%v-canary", host)
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary",
canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary",
80, &canaryAnnotations)
f.EnsureIngress(canaryIng)
@ -675,7 +675,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
By("returning requests from the mainline only when weight is equal to 0")
resp, body, errs := gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
End()
@ -691,14 +691,14 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
"nginx.ingress.kubernetes.io/canary-weight": "100",
}
modCanaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary", 80, &modCanaryAnnotations)
modCanaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", 80, &modCanaryAnnotations)
f.EnsureIngress(modCanaryIng)
time.Sleep(waitForLuaSync)
resp, body, errs = gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
End()
@ -718,16 +718,16 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
"nginx.ingress.kubernetes.io/canary-by-header": "CanaryByHeader",
}
ing := framework.NewSingleCatchAllIngress(canaryIngName, f.IngressController.Namespace, "http-svc-canary", 80, &annotations)
ing := framework.NewSingleCatchAllIngress(canaryIngName, f.Namespace, "http-svc-canary", 80, &annotations)
f.EnsureIngress(ing)
ing = framework.NewSingleCatchAllIngress(host, f.IngressController.Namespace, "http-svc", 80, nil)
ing = framework.NewSingleCatchAllIngress(host, f.Namespace, "http-svc", 80, nil)
f.EnsureIngress(ing)
f.WaitForNginxServer("_",
func(server string) bool {
upstreamName := fmt.Sprintf(`set $proxy_upstream_name "%s-%s-%s";`, f.IngressController.Namespace, "http-svc", "80")
canaryUpstreamName := fmt.Sprintf(`set $proxy_upstream_name "%s-%s-%s";`, f.IngressController.Namespace, "http-svc-canary", "80")
upstreamName := fmt.Sprintf(`set $proxy_upstream_name "%s-%s-%s";`, f.Namespace, "http-svc", "80")
canaryUpstreamName := fmt.Sprintf(`set $proxy_upstream_name "%s-%s-%s";`, f.Namespace, "http-svc-canary", "80")
return Expect(server).Should(ContainSubstring(`set $ingress_name "`+host+`";`)) &&
Expect(server).ShouldNot(ContainSubstring(`set $proxy_upstream_name "upstream-default-backend";`)) &&
Expect(server).ShouldNot(ContainSubstring(canaryUpstreamName)) &&
@ -743,11 +743,11 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
"nginx.ingress.kubernetes.io/canary-by-header": "CanaryByHeader",
}
ing := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary", 80, &annotations)
ing := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", 80, &annotations)
f.EnsureIngress(ing)
otherHost := "bar"
ing = framework.NewSingleIngress(otherHost, "/", otherHost, f.IngressController.Namespace, "http-svc", 80, nil)
ing = framework.NewSingleIngress(otherHost, "/", otherHost, f.Namespace, "http-svc", 80, nil)
f.EnsureIngress(ing)
time.Sleep(waitForLuaSync)