Wait for endpoints instead of pods

This commit is contained in:
Manuel Alejandro de Brito Fontes 2018-11-29 12:15:37 -03:00
parent 8a0dec9dd1
commit e192bbaf14
No known key found for this signature in database
GPG key ID: 786136016A8BA02A
2 changed files with 15 additions and 22 deletions

View file

@ -27,6 +27,7 @@ import (
var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() { var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() {
f := framework.NewDefaultFramework("proxy") f := framework.NewDefaultFramework("proxy")
host := "proxy.foo.com"
BeforeEach(func() { BeforeEach(func() {
f.NewEchoDeploymentWithReplicas(2) f.NewEchoDeploymentWithReplicas(2)
@ -36,7 +37,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() {
}) })
It("should set proxy_redirect to off", func() { It("should set proxy_redirect to off", func() {
host := "proxy.foo.com"
annotations := map[string]string{ annotations := map[string]string{
"nginx.ingress.kubernetes.io/proxy-redirect-from": "off", "nginx.ingress.kubernetes.io/proxy-redirect-from": "off",
"nginx.ingress.kubernetes.io/proxy-redirect-to": "goodbye.com", "nginx.ingress.kubernetes.io/proxy-redirect-to": "goodbye.com",
@ -52,7 +52,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() {
}) })
It("should set proxy_redirect to default", func() { It("should set proxy_redirect to default", func() {
host := "proxy.foo.com"
annotations := map[string]string{ annotations := map[string]string{
"nginx.ingress.kubernetes.io/proxy-redirect-from": "default", "nginx.ingress.kubernetes.io/proxy-redirect-from": "default",
"nginx.ingress.kubernetes.io/proxy-redirect-to": "goodbye.com", "nginx.ingress.kubernetes.io/proxy-redirect-to": "goodbye.com",
@ -68,7 +67,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() {
}) })
It("should set proxy_redirect to hello.com goodbye.com", func() { It("should set proxy_redirect to hello.com goodbye.com", func() {
host := "proxy.foo.com"
annotations := map[string]string{ annotations := map[string]string{
"nginx.ingress.kubernetes.io/proxy-redirect-from": "hello.com", "nginx.ingress.kubernetes.io/proxy-redirect-from": "hello.com",
"nginx.ingress.kubernetes.io/proxy-redirect-to": "goodbye.com", "nginx.ingress.kubernetes.io/proxy-redirect-to": "goodbye.com",
@ -84,7 +82,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() {
}) })
It("should set proxy client-max-body-size to 8m", func() { It("should set proxy client-max-body-size to 8m", func() {
host := "proxy.foo.com"
annotations := map[string]string{ annotations := map[string]string{
"nginx.ingress.kubernetes.io/proxy-body-size": "8m", "nginx.ingress.kubernetes.io/proxy-body-size": "8m",
} }
@ -99,7 +96,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() {
}) })
It("should not set proxy client-max-body-size to incorrect value", func() { It("should not set proxy client-max-body-size to incorrect value", func() {
host := "proxy.foo.com"
annotations := map[string]string{ annotations := map[string]string{
"nginx.ingress.kubernetes.io/proxy-body-size": "15r", "nginx.ingress.kubernetes.io/proxy-body-size": "15r",
} }
@ -114,7 +110,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() {
}) })
It("should set valid proxy timeouts", func() { It("should set valid proxy timeouts", func() {
host := "proxy.foo.com"
annotations := map[string]string{ annotations := map[string]string{
"nginx.ingress.kubernetes.io/proxy-connect-timeout": "50", "nginx.ingress.kubernetes.io/proxy-connect-timeout": "50",
"nginx.ingress.kubernetes.io/proxy-send-timeout": "20", "nginx.ingress.kubernetes.io/proxy-send-timeout": "20",
@ -126,12 +121,13 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() {
f.WaitForNginxServer(host, f.WaitForNginxServer(host,
func(server string) bool { func(server string) bool {
return strings.Contains(server, "proxy_connect_timeout 50s;") && strings.Contains(server, "proxy_send_timeout 20s;") && strings.Contains(server, "proxy_read_timeout 20s;") return strings.Contains(server, "proxy_connect_timeout 50s;") &&
strings.Contains(server, "proxy_send_timeout 20s;") &&
strings.Contains(server, "proxy_read_timeout 20s;")
}) })
}) })
It("should not set invalid proxy timeouts", func() { It("should not set invalid proxy timeouts", func() {
host := "proxy.foo.com"
annotations := map[string]string{ annotations := map[string]string{
"nginx.ingress.kubernetes.io/proxy-connect-timeout": "50k", "nginx.ingress.kubernetes.io/proxy-connect-timeout": "50k",
"nginx.ingress.kubernetes.io/proxy-send-timeout": "20k", "nginx.ingress.kubernetes.io/proxy-send-timeout": "20k",
@ -143,12 +139,13 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() {
f.WaitForNginxServer(host, f.WaitForNginxServer(host,
func(server string) bool { func(server string) bool {
return !strings.Contains(server, "proxy_connect_timeout 50ks;") && !strings.Contains(server, "proxy_send_timeout 20ks;") && !strings.Contains(server, "proxy_read_timeout 60s;") return !strings.Contains(server, "proxy_connect_timeout 50ks;") &&
!strings.Contains(server, "proxy_send_timeout 20ks;") &&
!strings.Contains(server, "proxy_read_timeout 60s;")
}) })
}) })
It("should turn on proxy-buffering", func() { It("should turn on proxy-buffering", func() {
host := "proxy.foo.com"
annotations := map[string]string{ annotations := map[string]string{
"nginx.ingress.kubernetes.io/proxy-buffering": "on", "nginx.ingress.kubernetes.io/proxy-buffering": "on",
"nginx.ingress.kubernetes.io/proxy-buffer-size": "8k", "nginx.ingress.kubernetes.io/proxy-buffer-size": "8k",
@ -159,12 +156,14 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() {
f.WaitForNginxServer(host, f.WaitForNginxServer(host,
func(server string) bool { func(server string) bool {
return strings.Contains(server, "proxy_buffering on;") && strings.Contains(server, "proxy_buffer_size 8k;") && strings.Contains(server, "proxy_buffers 4 8k;") && strings.Contains(server, "proxy_request_buffering on;") return strings.Contains(server, "proxy_buffering on;") &&
strings.Contains(server, "proxy_buffer_size 8k;") &&
strings.Contains(server, "proxy_buffers 4 8k;") &&
strings.Contains(server, "proxy_request_buffering on;")
}) })
}) })
It("should turn off proxy-request-buffering", func() { It("should turn off proxy-request-buffering", func() {
host := "proxy.foo.com"
annotations := map[string]string{ annotations := map[string]string{
"nginx.ingress.kubernetes.io/proxy-request-buffering": "off", "nginx.ingress.kubernetes.io/proxy-request-buffering": "off",
} }
@ -179,7 +178,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() {
}) })
It("should build proxy next upstream", func() { It("should build proxy next upstream", func() {
host := "proxy.foo.com"
annotations := map[string]string{ annotations := map[string]string{
"nginx.ingress.kubernetes.io/proxy-next-upstream": "error timeout http_502", "nginx.ingress.kubernetes.io/proxy-next-upstream": "error timeout http_502",
"nginx.ingress.kubernetes.io/proxy-next-upstream-tries": "5", "nginx.ingress.kubernetes.io/proxy-next-upstream-tries": "5",
@ -190,12 +188,12 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() {
f.WaitForNginxServer(host, f.WaitForNginxServer(host,
func(server string) bool { func(server string) bool {
return strings.Contains(server, "proxy_next_upstream error timeout http_502;") && strings.Contains(server, "proxy_next_upstream_tries 5;") return strings.Contains(server, "proxy_next_upstream error timeout http_502;") &&
strings.Contains(server, "proxy_next_upstream_tries 5;")
}) })
}) })
It("should setup proxy cookies", func() { It("should setup proxy cookies", func() {
host := "proxy.foo.com"
annotations := map[string]string{ annotations := map[string]string{
"nginx.ingress.kubernetes.io/proxy-cookie-domain": "localhost example.org", "nginx.ingress.kubernetes.io/proxy-cookie-domain": "localhost example.org",
"nginx.ingress.kubernetes.io/proxy-cookie-path": "/one/ /", "nginx.ingress.kubernetes.io/proxy-cookie-path": "/one/ /",
@ -206,7 +204,8 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() {
f.WaitForNginxServer(host, f.WaitForNginxServer(host,
func(server string) bool { func(server string) bool {
return strings.Contains(server, "proxy_cookie_domain localhost example.org;") && strings.Contains(server, "proxy_cookie_path /one/ /;") return strings.Contains(server, "proxy_cookie_domain localhost example.org;") &&
strings.Contains(server, "proxy_cookie_path /one/ /;")
}) })
}) })
}) })

View file

@ -22,7 +22,6 @@ import (
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
extensions "k8s.io/api/extensions/v1beta1" extensions "k8s.io/api/extensions/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/intstr"
) )
@ -101,11 +100,6 @@ func (f *Framework) NewDeployment(name, image string, port int32, replicas int32
Expect(err).NotTo(HaveOccurred(), "failed to create a deployment") Expect(err).NotTo(HaveOccurred(), "failed to create a deployment")
Expect(d).NotTo(BeNil(), "expected a deployement but none returned") Expect(d).NotTo(BeNil(), "expected a deployement but none returned")
err = WaitForPodsReady(f.KubeClientSet, defaultTimeout, int(replicas), f.IngressController.Namespace, metav1.ListOptions{
LabelSelector: fields.SelectorFromSet(fields.Set(d.Spec.Template.ObjectMeta.Labels)).String(),
})
Expect(err).NotTo(HaveOccurred(), "failed to wait for pods to become ready")
service := &corev1.Service{ service := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: name, Name: name,