diff --git a/images/httpbin/Makefile b/images/httpbin/Makefile new file mode 100644 index 000000000..451797f1c --- /dev/null +++ b/images/httpbin/Makefile @@ -0,0 +1,97 @@ +all: all-container + +BUILDTAGS= + +# Use the 0.0 tag for testing, it shouldn't clobber any release builds +TAG?=0.1 +REGISTRY?=kubernetes-ingress-controller +GOOS?=linux +DOCKER?=docker +SED_I?=sed -i +GOHOSTOS ?= $(shell go env GOHOSTOS) + +ifeq ($(GOHOSTOS),darwin) + SED_I=sed -i '' +endif + +REPO_INFO=$(shell git config --get remote.origin.url) + +ARCH ?= $(shell go env GOARCH) +GOARCH = ${ARCH} + +# Set default base image dynamically for each arch +BASEIMAGE?=quay.io/kubernetes-ingress-controller/debian-base-$(ARCH):0.1 + +ALL_ARCH = amd64 arm arm64 + +QEMUVERSION=v4.0.0 + +IMGNAME = httpbin +IMAGE = $(REGISTRY)/$(IMGNAME) +MULTI_ARCH_IMG = $(IMAGE)-$(ARCH) + +ifeq ($(ARCH),arm) + QEMUARCH=arm +endif +ifeq ($(ARCH),arm64) + QEMUARCH=aarch64 +endif +ifeq ($(ARCH),ppc64le) + QEMUARCH=ppc64le +endif + +TEMP_DIR := $(shell mktemp -d) + +DOCKERFILE := $(TEMP_DIR)/rootfs/Dockerfile + +sub-container-%: + $(MAKE) ARCH=$* container + +sub-push-%: + $(MAKE) ARCH=$* push + +all-container: $(addprefix sub-container-,$(ALL_ARCH)) + +all-push: $(addprefix sub-push-,$(ALL_ARCH)) + +container: .container-$(ARCH) +.container-$(ARCH): + cp -r ./* $(TEMP_DIR) + $(SED_I) 's|BASEIMAGE|$(BASEIMAGE)|g' $(DOCKERFILE) + $(SED_I) "s|QEMUARCH|$(QEMUARCH)|g" $(DOCKERFILE) + +ifeq ($(ARCH),amd64) + # When building "normally" for amd64, remove the whole line, it has no part in the amd64 image + $(SED_I) "/CROSS_BUILD_/d" $(DOCKERFILE) +else + # When cross-building, only the placeholder "CROSS_BUILD_" should be removed + # Register /usr/bin/qemu-ARCH-static as the handler for ARM binaries in the kernel + # $(DOCKER) run --rm --privileged multiarch/qemu-user-static:register --reset + curl -sSL https://github.com/multiarch/qemu-user-static/releases/download/$(QEMUVERSION)/x86_64_qemu-$(QEMUARCH)-static.tar.gz | tar -xz -C $(TEMP_DIR)/rootfs + $(SED_I) "s/CROSS_BUILD_//g" $(DOCKERFILE) +endif + + $(DOCKER) build -t $(MULTI_ARCH_IMG):$(TAG) $(TEMP_DIR)/rootfs + +ifeq ($(ARCH), amd64) + # This is for to maintain the backward compatibility + $(DOCKER) tag $(MULTI_ARCH_IMG):$(TAG) $(IMAGE):$(TAG) +endif + +push: .push-$(ARCH) +.push-$(ARCH): + $(DOCKER) push $(MULTI_ARCH_IMG):$(TAG) +ifeq ($(ARCH), amd64) + $(DOCKER) push $(IMAGE):$(TAG) +endif + +clean: + $(DOCKER) rmi -f $(MULTI_ARCH_IMG):$(TAG) || true + +release: all-container all-push + echo "done" + +.PHONY: register-qemu +register-qemu: + # Register /usr/bin/qemu-ARCH-static as the handler for binaries in multiple platforms + $(DOCKER) run --rm --privileged multiarch/qemu-user-static:register --reset diff --git a/images/httpbin/rootfs/Dockerfile b/images/httpbin/rootfs/Dockerfile new file mode 100644 index 000000000..1bb95b061 --- /dev/null +++ b/images/httpbin/rootfs/Dockerfile @@ -0,0 +1,32 @@ +# Copyright 2019 The Kubernetes Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM BASEIMAGE + +CROSS_BUILD_COPY qemu-QEMUARCH-static /usr/bin/ + +ENV LC_ALL=C.UTF-8 +ENV LANG=C.UTF-8 + +WORKDIR /httpbin + +RUN clean-install python3-pip curl python3-pip git bash gcc libstdc++-8-dev libpython3.7-dev python3-setuptools \ + && pip3 install --no-cache-dir httpbin \ + && pip3 install --no-cache-dir gunicorn \ + && pip3 install --no-cache-dir gevent \ + && apt remove git gcc libstdc++-8-dev libpython3.7-dev python3-setuptools --yes + +EXPOSE 80 + +CMD ["gunicorn", "-b", "0.0.0.0:80", "httpbin:app", "-k", "gevent"] diff --git a/test/e2e/annotations/affinity.go b/test/e2e/annotations/affinity.go index 2f74c4764..241d354a4 100644 --- a/test/e2e/annotations/affinity.go +++ b/test/e2e/annotations/affinity.go @@ -50,7 +50,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", "nginx.ingress.kubernetes.io/session-cookie-name": "SERVERID", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -76,7 +76,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", "nginx.ingress.kubernetes.io/session-cookie-name": "SERVERID", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -116,7 +116,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", "nginx.ingress.kubernetes.io/session-cookie-name": "SERVERID", } - ing := framework.NewSingleIngress(host, "/something", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/something", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -158,14 +158,14 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", { Path: "/something", Backend: extensions.IngressBackend{ - ServiceName: "http-svc", + ServiceName: framework.EchoService, ServicePort: intstr.FromInt(80), }, }, { Path: "/somewhereelese", Backend: extensions.IngressBackend{ - ServiceName: "http-svc", + ServiceName: framework.EchoService, ServicePort: intstr.FromInt(80), }, }, @@ -211,7 +211,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", "nginx.ingress.kubernetes.io/session-cookie-max-age": "259200", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -247,7 +247,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", "nginx.ingress.kubernetes.io/session-cookie-path": "/foo/bar", } - ing := framework.NewSingleIngress(host, "/foo/.*", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/foo/.*", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -275,7 +275,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", "nginx.ingress.kubernetes.io/use-regex": "true", } - ing := framework.NewSingleIngress(host, "/foo/.*", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/foo/.*", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -303,10 +303,10 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", annotations := map[string]string{ "nginx.ingress.kubernetes.io/affinity": "cookie", } - ing1 := framework.NewSingleIngress("ingress1", "/foo/bar", host, f.Namespace, "http-svc", 80, &annotations) + ing1 := framework.NewSingleIngress("ingress1", "/foo/bar", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing1) - ing2 := framework.NewSingleIngress("ingress2", "/foo", host, f.Namespace, "http-svc", 80, &map[string]string{}) + ing2 := framework.NewSingleIngress("ingress2", "/foo", host, f.Namespace, framework.EchoService, 80, &map[string]string{}) f.EnsureIngress(ing2) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/alias.go b/test/e2e/annotations/alias.go index 96d281a30..f1a87a0b1 100644 --- a/test/e2e/annotations/alias.go +++ b/test/e2e/annotations/alias.go @@ -41,7 +41,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Alias", func() { host := "foo" annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -74,7 +74,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Alias", func() { "nginx.ingress.kubernetes.io/server-alias": "bar", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/approot.go b/test/e2e/annotations/approot.go index 8d5621b37..e331c7985 100644 --- a/test/e2e/annotations/approot.go +++ b/test/e2e/annotations/approot.go @@ -43,7 +43,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Approot", func() { "nginx.ingress.kubernetes.io/app-root": "/foo", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/auth.go b/test/e2e/annotations/auth.go index 210707539..726e94de0 100644 --- a/test/e2e/annotations/auth.go +++ b/test/e2e/annotations/auth.go @@ -46,7 +46,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { It("should return status code 200 when no authentication is configured", func() { host := "auth" - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -73,7 +73,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { "nginx.ingress.kubernetes.io/auth-realm": "test auth", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -103,7 +103,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { "nginx.ingress.kubernetes.io/auth-realm": "test auth", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -133,7 +133,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { "nginx.ingress.kubernetes.io/auth-realm": "test auth", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -164,7 +164,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { "nginx.ingress.kubernetes.io/auth-realm": "test auth", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -206,7 +206,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { "nginx.ingress.kubernetes.io/auth-realm": "test auth", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -234,7 +234,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { proxy_set_header My-Custom-Header 42;`, } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -251,7 +251,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { proxy_set_header My-Custom-Header 42;`, } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -269,7 +269,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { "nginx.ingress.kubernetes.io/auth-cache-duration": "200 202 401 30m", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -288,10 +288,10 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { var httpbinIP string - err := framework.WaitForEndpoints(f.KubeClientSet, framework.DefaultTimeout, "httpbin", f.Namespace, 1) + err := framework.WaitForEndpoints(f.KubeClientSet, framework.DefaultTimeout, framework.HTTPBinService, f.Namespace, 1) Expect(err).NotTo(HaveOccurred()) - e, err := f.KubeClientSet.CoreV1().Endpoints(f.Namespace).Get("httpbin", metav1.GetOptions{}) + e, err := f.KubeClientSet.CoreV1().Endpoints(f.Namespace).Get(framework.HTTPBinService, metav1.GetOptions{}) Expect(err).NotTo(HaveOccurred()) httpbinIP = e.Subsets[0].Addresses[0].IP @@ -301,7 +301,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { "nginx.ingress.kubernetes.io/auth-signin": "http://$host/auth/start", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, func(server string) bool { @@ -355,10 +355,10 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { var httpbinIP string - err := framework.WaitForEndpoints(f.KubeClientSet, framework.DefaultTimeout, "httpbin", f.Namespace, 1) + err := framework.WaitForEndpoints(f.KubeClientSet, framework.DefaultTimeout, framework.HTTPBinService, f.Namespace, 1) Expect(err).NotTo(HaveOccurred()) - e, err := f.KubeClientSet.CoreV1().Endpoints(f.Namespace).Get("httpbin", metav1.GetOptions{}) + e, err := f.KubeClientSet.CoreV1().Endpoints(f.Namespace).Get(framework.HTTPBinService, metav1.GetOptions{}) Expect(err).NotTo(HaveOccurred()) httpbinIP = e.Subsets[0].Addresses[0].IP @@ -372,14 +372,14 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { for _, host := range []string{thisHost, thatHost} { By("Adding an ingress rule for /foo") - fooIng := framework.NewSingleIngress(fmt.Sprintf("foo-%s-ing", host), fooPath, host, f.Namespace, "http-svc", 80, &annotations) + fooIng := framework.NewSingleIngress(fmt.Sprintf("foo-%s-ing", host), fooPath, host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(fooIng) f.WaitForNginxServer(host, func(server string) bool { return Expect(server).Should(ContainSubstring("location /foo")) }) By("Adding an ingress rule for /bar") - barIng := framework.NewSingleIngress(fmt.Sprintf("bar-%s-ing", host), barPath, host, f.Namespace, "http-svc", 80, &annotations) + barIng := framework.NewSingleIngress(fmt.Sprintf("bar-%s-ing", host), barPath, host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(barIng) f.WaitForNginxServer(host, func(server string) bool { return Expect(server).Should(ContainSubstring("location /bar")) @@ -400,7 +400,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { } Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - err := f.DeleteDeployment("httpbin") + err := f.DeleteDeployment(framework.HTTPBinService) Expect(err).NotTo(HaveOccurred()) resp, _, errs = gorequest.New(). @@ -429,7 +429,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { } Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - err := f.DeleteDeployment("httpbin") + err := f.DeleteDeployment(framework.HTTPBinService) Expect(err).NotTo(HaveOccurred()) _, _, errs = gorequest.New(). @@ -472,7 +472,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { } Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - err := f.DeleteDeployment("httpbin") + err := f.DeleteDeployment(framework.HTTPBinService) Expect(err).NotTo(HaveOccurred()) resp, _, errs = gorequest.New(). diff --git a/test/e2e/annotations/authtls.go b/test/e2e/annotations/authtls.go index aee411923..8a69d27f0 100644 --- a/test/e2e/annotations/authtls.go +++ b/test/e2e/annotations/authtls.go @@ -53,7 +53,7 @@ var _ = framework.IngressNginxDescribe("Annotations - AuthTLS", func() { "nginx.ingress.kubernetes.io/auth-tls-secret": nameSpace + "/" + host, } - f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, nameSpace, "http-svc", 80, &annotations)) + f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, nameSpace, framework.EchoService, 80, &annotations)) assertSslClientCertificateConfig(f, host, "on", "1") @@ -95,7 +95,7 @@ var _ = framework.IngressNginxDescribe("Annotations - AuthTLS", func() { "nginx.ingress.kubernetes.io/auth-tls-verify-depth": "2", } - f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, nameSpace, "http-svc", 80, &annotations)) + f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, nameSpace, framework.EchoService, 80, &annotations)) assertSslClientCertificateConfig(f, host, "off", "2") @@ -130,7 +130,7 @@ var _ = framework.IngressNginxDescribe("Annotations - AuthTLS", func() { "nginx.ingress.kubernetes.io/auth-tls-pass-certificate-to-upstream": "true", } - f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, nameSpace, "http-svc", 80, &annotations)) + f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, nameSpace, framework.EchoService, 80, &annotations)) assertSslClientCertificateConfig(f, host, "on", "1") diff --git a/test/e2e/annotations/backendprotocol.go b/test/e2e/annotations/backendprotocol.go index 2d2b5aace..a0ab446fc 100644 --- a/test/e2e/annotations/backendprotocol.go +++ b/test/e2e/annotations/backendprotocol.go @@ -38,7 +38,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Backendprotocol", func() { "nginx.ingress.kubernetes.io/backend-protocol": "HTTPS", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -53,7 +53,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Backendprotocol", func() { "nginx.ingress.kubernetes.io/backend-protocol": "GRPC", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -68,7 +68,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Backendprotocol", func() { "nginx.ingress.kubernetes.io/backend-protocol": "GRPCS", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -83,7 +83,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Backendprotocol", func() { "nginx.ingress.kubernetes.io/backend-protocol": "FCGI", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -98,7 +98,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Backendprotocol", func() { "nginx.ingress.kubernetes.io/backend-protocol": "AJP", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/canary.go b/test/e2e/annotations/canary.go index 7a9a237c9..2fa8eb238 100644 --- a/test/e2e/annotations/canary.go +++ b/test/e2e/annotations/canary.go @@ -30,6 +30,8 @@ import ( const ( waitForLuaSync = 5 * time.Second + + canaryService = "echo-canary" ) var _ = framework.IngressNginxDescribe("Annotations - canary", func() { @@ -40,7 +42,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { f.NewEchoDeployment() // Deployment for canary backend - f.NewDeployment("http-svc-canary", "gcr.io/kubernetes-e2e-test-images/echoserver:2.2", 8080, 1) + f.NewEchoDeploymentWithNameAndReplicas(canaryService, 1) }) Context("when canary is created", func() { @@ -48,7 +50,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { host := "foo" annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -63,8 +65,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", - 80, &canaryAnnotations) + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, canaryService, 80, &canaryAnnotations) f.EnsureIngress(canaryIng) time.Sleep(waitForLuaSync) @@ -76,8 +77,8 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - Expect(body).Should(ContainSubstring("http-svc")) - Expect(body).ShouldNot(ContainSubstring("http-svc-canary")) + Expect(body).Should(ContainSubstring(framework.EchoService)) + Expect(body).ShouldNot(ContainSubstring(canaryService)) }) It("should return 404 status for requests to the canary if no matching ingress is found", func() { @@ -90,7 +91,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, canaryService, 80, &canaryAnnotations) f.EnsureIngress(canaryIng) @@ -115,7 +116,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { host := "foo" annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -130,7 +131,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, canaryService, 80, &canaryAnnotations) f.EnsureIngress(canaryIng) @@ -152,7 +153,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { By("returning a 200 status when the canary deployment has 0 replicas and a request is sent to the mainline ingress") f.NewEchoDeploymentWithReplicas(1) - f.NewDeployment("http-svc-canary", "gcr.io/kubernetes-e2e-test-images/echoserver:2.2", 8080, 0) + f.NewDeployment(canaryService, "gcr.io/kubernetes-e2e-test-images/echoserver:2.2", 8080, 0) resp, _, errs = gorequest.New(). Get(f.GetURL(framework.HTTP)). @@ -169,7 +170,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { host := "foo" annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -184,7 +185,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, canaryService, 80, &canaryAnnotations) f.EnsureIngress(canaryIng) @@ -199,8 +200,8 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - Expect(body).Should(ContainSubstring("http-svc")) - Expect(body).ShouldNot(ContainSubstring("http-svc-canary")) + Expect(body).Should(ContainSubstring(framework.EchoService)) + Expect(body).ShouldNot(ContainSubstring(canaryService)) By("routing requests destined for the canary ingress to the canary upstream") @@ -212,7 +213,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - Expect(body).Should(ContainSubstring("http-svc-canary")) + Expect(body).Should(ContainSubstring(canaryService)) }) It("should route requests to the correct upstream if mainline ingress is created after the canary ingress", func() { @@ -225,7 +226,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, canaryService, 80, &canaryAnnotations) f.EnsureIngress(canaryIng) @@ -233,7 +234,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -250,8 +251,8 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - Expect(body).Should(ContainSubstring("http-svc")) - Expect(body).ShouldNot(ContainSubstring("http-svc-canary")) + Expect(body).Should(ContainSubstring(framework.EchoService)) + Expect(body).ShouldNot(ContainSubstring(canaryService)) By("routing requests destined for the canary ingress to the canary upstream") @@ -263,14 +264,14 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - Expect(body).Should(ContainSubstring("http-svc-canary")) + Expect(body).Should(ContainSubstring(canaryService)) }) It("should route requests to the correct upstream if the mainline ingress is modified", func() { host := "foo" annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -285,7 +286,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, canaryService, 80, &canaryAnnotations) f.EnsureIngress(canaryIng) @@ -295,7 +296,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { "foo": "bar", } - modIng := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &modAnnotations) + modIng := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &modAnnotations) f.EnsureIngress(modIng) @@ -314,8 +315,8 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - Expect(body).Should(ContainSubstring("http-svc")) - Expect(body).ShouldNot(ContainSubstring("http-svc-canary")) + Expect(body).Should(ContainSubstring(framework.EchoService)) + Expect(body).ShouldNot(ContainSubstring(canaryService)) By("routing requests destined for the canary ingress to the canary upstream") @@ -327,14 +328,14 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - Expect(body).Should(ContainSubstring("http-svc-canary")) + Expect(body).Should(ContainSubstring(canaryService)) }) It("should route requests to the correct upstream if the canary ingress is modified", func() { host := "foo" annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -349,7 +350,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, canaryService, 80, &canaryAnnotations) f.EnsureIngress(canaryIng) @@ -360,7 +361,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { "nginx.ingress.kubernetes.io/canary-by-header": "CanaryByHeader2", } - modCanaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", 80, &modCanaryAnnotations) + modCanaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, canaryService, 80, &modCanaryAnnotations) f.EnsureIngress(modCanaryIng) time.Sleep(waitForLuaSync) @@ -375,8 +376,8 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - Expect(body).Should(ContainSubstring("http-svc")) - Expect(body).ShouldNot(ContainSubstring("http-svc-canary")) + Expect(body).Should(ContainSubstring(framework.EchoService)) + Expect(body).ShouldNot(ContainSubstring(canaryService)) By("routing requests destined for the canary ingress to the canary upstream") @@ -388,7 +389,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - Expect(body).Should(ContainSubstring("http-svc-canary")) + Expect(body).Should(ContainSubstring(canaryService)) }) }) @@ -397,7 +398,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { host := "foo" annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -412,7 +413,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, canaryService, 80, &canaryAnnotations) f.EnsureIngress(canaryIng) @@ -428,7 +429,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - Expect(body).Should(ContainSubstring("http-svc-canary")) + Expect(body).Should(ContainSubstring(canaryService)) By("routing requests to the mainline upstream when header is set to 'never'") @@ -440,8 +441,8 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - Expect(body).Should(ContainSubstring("http-svc")) - Expect(body).ShouldNot(ContainSubstring("http-svc-canary")) + Expect(body).Should(ContainSubstring(framework.EchoService)) + Expect(body).ShouldNot(ContainSubstring(canaryService)) By("routing requests to the mainline upstream when header is set to anything else") @@ -453,8 +454,8 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - Expect(body).Should(ContainSubstring("http-svc")) - Expect(body).ShouldNot(ContainSubstring("http-svc-canary")) + Expect(body).Should(ContainSubstring(framework.EchoService)) + Expect(body).ShouldNot(ContainSubstring(canaryService)) }) }) @@ -463,7 +464,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { host := "foo" annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -479,7 +480,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, canaryService, 80, &canaryAnnotations) f.EnsureIngress(canaryIng) @@ -495,7 +496,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - Expect(body).Should(ContainSubstring("http-svc-canary")) + Expect(body).Should(ContainSubstring(canaryService)) By("routing requests to the mainline upstream when header is set to 'always'") @@ -507,8 +508,8 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - Expect(body).Should(ContainSubstring("http-svc")) - Expect(body).ShouldNot(ContainSubstring("http-svc-canary")) + Expect(body).Should(ContainSubstring(framework.EchoService)) + Expect(body).ShouldNot(ContainSubstring(canaryService)) By("routing requests to the mainline upstream when header is set to 'never'") @@ -520,8 +521,8 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - Expect(body).Should(ContainSubstring("http-svc")) - Expect(body).ShouldNot(ContainSubstring("http-svc-canary")) + Expect(body).Should(ContainSubstring(framework.EchoService)) + Expect(body).ShouldNot(ContainSubstring(canaryService)) By("routing requests to the mainline upstream when header is set to anything else") @@ -533,8 +534,8 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - Expect(body).Should(ContainSubstring("http-svc")) - Expect(body).ShouldNot(ContainSubstring("http-svc-canary")) + Expect(body).Should(ContainSubstring(framework.EchoService)) + Expect(body).ShouldNot(ContainSubstring(canaryService)) }) }) @@ -543,7 +544,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { host := "foo" annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -560,7 +561,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, canaryService, 80, &canaryAnnotations) f.EnsureIngress(canaryIng) @@ -576,7 +577,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - Expect(body).Should(ContainSubstring("http-svc-canary")) + Expect(body).Should(ContainSubstring(canaryService)) }) }) @@ -585,7 +586,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { host := "foo" annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -600,7 +601,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, canaryService, 80, &canaryAnnotations) f.EnsureIngress(canaryIng) @@ -615,7 +616,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - Expect(body).Should(ContainSubstring("http-svc-canary")) + Expect(body).Should(ContainSubstring(canaryService)) By("routing requests to the mainline upstream when cookie is set to 'never'") @@ -627,8 +628,8 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - Expect(body).Should(ContainSubstring("http-svc")) - Expect(body).ShouldNot(ContainSubstring("http-svc-canary")) + Expect(body).Should(ContainSubstring(framework.EchoService)) + Expect(body).ShouldNot(ContainSubstring(canaryService)) By("routing requests to the mainline upstream when cookie is set to anything else") @@ -640,8 +641,8 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - Expect(body).Should(ContainSubstring("http-svc")) - Expect(body).ShouldNot(ContainSubstring("http-svc-canary")) + Expect(body).Should(ContainSubstring(framework.EchoService)) + Expect(body).ShouldNot(ContainSubstring(canaryService)) }) }) @@ -651,7 +652,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { host := "foo" annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -666,7 +667,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, canaryService, 80, &canaryAnnotations) f.EnsureIngress(canaryIng) @@ -681,8 +682,8 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - Expect(body).Should(ContainSubstring("http-svc")) - Expect(body).ShouldNot(ContainSubstring("http-svc-canary")) + Expect(body).Should(ContainSubstring(framework.EchoService)) + Expect(body).ShouldNot(ContainSubstring(canaryService)) By("returning requests from the canary only when weight is equal to 100") @@ -691,7 +692,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { "nginx.ingress.kubernetes.io/canary-weight": "100", } - modCanaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", 80, &modCanaryAnnotations) + modCanaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, canaryService, 80, &modCanaryAnnotations) f.EnsureIngress(modCanaryIng) @@ -704,7 +705,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - Expect(body).Should(ContainSubstring("http-svc-canary")) + Expect(body).Should(ContainSubstring(canaryService)) }) }) @@ -718,16 +719,16 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { "nginx.ingress.kubernetes.io/canary-by-header": "CanaryByHeader", } - ing := framework.NewSingleCatchAllIngress(canaryIngName, f.Namespace, "http-svc-canary", 80, &annotations) + ing := framework.NewSingleCatchAllIngress(canaryIngName, f.Namespace, canaryService, 80, &annotations) f.EnsureIngress(ing) - ing = framework.NewSingleCatchAllIngress(host, f.Namespace, "http-svc", 80, nil) + ing = framework.NewSingleCatchAllIngress(host, f.Namespace, framework.EchoService, 80, nil) f.EnsureIngress(ing) f.WaitForNginxServer("_", func(server string) bool { - 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") + upstreamName := fmt.Sprintf(`set $proxy_upstream_name "%s-%s-%s";`, f.Namespace, framework.EchoService, "80") + canaryUpstreamName := fmt.Sprintf(`set $proxy_upstream_name "%s-%s-%s";`, f.Namespace, canaryService, "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 +744,11 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { "nginx.ingress.kubernetes.io/canary-by-header": "CanaryByHeader", } - ing := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", 80, &annotations) + ing := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, canaryService, 80, &annotations) f.EnsureIngress(ing) otherHost := "bar" - ing = framework.NewSingleIngress(otherHost, "/", otherHost, f.Namespace, "http-svc", 80, nil) + ing = framework.NewSingleIngress(otherHost, "/", otherHost, f.Namespace, framework.EchoService, 80, nil) f.EnsureIngress(ing) time.Sleep(waitForLuaSync) @@ -771,7 +772,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { ing := framework.NewSingleIngressWithMultiplePaths(canaryIngName, paths, host, f.Namespace, "httpy-svc-canary", 80, &annotations) f.EnsureIngress(ing) - ing = framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil) + ing = framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/clientbodybuffersize.go b/test/e2e/annotations/clientbodybuffersize.go index cfaa664e1..2c52faf42 100644 --- a/test/e2e/annotations/clientbodybuffersize.go +++ b/test/e2e/annotations/clientbodybuffersize.go @@ -38,7 +38,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Client-Body-Buffer-Size", "nginx.ingress.kubernetes.io/client-body-buffer-size": "1000", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -53,7 +53,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Client-Body-Buffer-Size", "nginx.ingress.kubernetes.io/client-body-buffer-size": "1K", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -68,7 +68,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Client-Body-Buffer-Size", "nginx.ingress.kubernetes.io/client-body-buffer-size": "1k", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -83,7 +83,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Client-Body-Buffer-Size", "nginx.ingress.kubernetes.io/client-body-buffer-size": "1m", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -98,7 +98,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Client-Body-Buffer-Size", "nginx.ingress.kubernetes.io/client-body-buffer-size": "1M", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -113,7 +113,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Client-Body-Buffer-Size", "nginx.ingress.kubernetes.io/client-body-buffer-size": "1b", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/connection.go b/test/e2e/annotations/connection.go index 5becd22ac..1fcde61ec 100644 --- a/test/e2e/annotations/connection.go +++ b/test/e2e/annotations/connection.go @@ -43,7 +43,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Connection", func() { "nginx.ingress.kubernetes.io/connection-proxy-header": "keep-alive", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/cors.go b/test/e2e/annotations/cors.go index ec1c5560e..bfb65cb83 100644 --- a/test/e2e/annotations/cors.go +++ b/test/e2e/annotations/cors.go @@ -42,7 +42,7 @@ var _ = framework.IngressNginxDescribe("Annotations - CORS", func() { "nginx.ingress.kubernetes.io/enable-cors": "true", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -86,7 +86,7 @@ var _ = framework.IngressNginxDescribe("Annotations - CORS", func() { "nginx.ingress.kubernetes.io/cors-allow-methods": "POST, GET", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -102,7 +102,7 @@ var _ = framework.IngressNginxDescribe("Annotations - CORS", func() { "nginx.ingress.kubernetes.io/cors-max-age": "200", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -118,7 +118,7 @@ var _ = framework.IngressNginxDescribe("Annotations - CORS", func() { "nginx.ingress.kubernetes.io/cors-allow-credentials": "false", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -134,7 +134,7 @@ var _ = framework.IngressNginxDescribe("Annotations - CORS", func() { "nginx.ingress.kubernetes.io/cors-allow-origin": "https://origin.cors.com:8080", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -150,7 +150,7 @@ var _ = framework.IngressNginxDescribe("Annotations - CORS", func() { "nginx.ingress.kubernetes.io/cors-allow-headers": "DNT, User-Agent", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/customhttperrors.go b/test/e2e/annotations/customhttperrors.go index 0a623fe92..358f8778a 100644 --- a/test/e2e/annotations/customhttperrors.go +++ b/test/e2e/annotations/customhttperrors.go @@ -50,7 +50,7 @@ var _ = framework.IngressNginxDescribe("Annotations - custom-http-errors", func( "nginx.ingress.kubernetes.io/custom-http-errors": strings.Join(errorCodes, ","), } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) var serverConfig string @@ -91,7 +91,7 @@ var _ = framework.IngressNginxDescribe("Annotations - custom-http-errors", func( By("ignoring duplicate values (503 in this case) per server") annotations["nginx.ingress.kubernetes.io/custom-http-errors"] = "404, 503" - ing = framework.NewSingleIngress(fmt.Sprintf("%s-else", host), "/else", host, f.Namespace, "http-svc", 80, &annotations) + ing = framework.NewSingleIngress(fmt.Sprintf("%s-else", host), "/else", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, func(sc string) bool { serverConfig = sc diff --git a/test/e2e/annotations/default_backend.go b/test/e2e/annotations/default_backend.go index 4aff300f7..b5e3b08ab 100644 --- a/test/e2e/annotations/default_backend.go +++ b/test/e2e/annotations/default_backend.go @@ -39,7 +39,7 @@ var _ = framework.IngressNginxDescribe("Annotations - custom default-backend", f It("should use a custom default backend as upstream", func() { host := "default-backend" annotations := map[string]string{ - "nginx.ingress.kubernetes.io/default-backend": "http-svc", + "nginx.ingress.kubernetes.io/default-backend": framework.EchoService, } ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "invalid", 80, &annotations) diff --git a/test/e2e/annotations/forcesslredirect.go b/test/e2e/annotations/forcesslredirect.go index 118d07f22..085df6cd9 100644 --- a/test/e2e/annotations/forcesslredirect.go +++ b/test/e2e/annotations/forcesslredirect.go @@ -43,7 +43,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Forcesslredirect", func() "nginx.ingress.kubernetes.io/force-ssl-redirect": "true", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) resp, _, errs := gorequest.New(). diff --git a/test/e2e/annotations/fromtowwwredirect.go b/test/e2e/annotations/fromtowwwredirect.go index e9799968b..3f0452a22 100644 --- a/test/e2e/annotations/fromtowwwredirect.go +++ b/test/e2e/annotations/fromtowwwredirect.go @@ -47,7 +47,7 @@ var _ = framework.IngressNginxDescribe("Annotations - from-to-www-redirect", fun "nginx.ingress.kubernetes.io/from-to-www-redirect": "true", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxConfiguration( @@ -81,7 +81,7 @@ var _ = framework.IngressNginxDescribe("Annotations - from-to-www-redirect", fun "nginx.ingress.kubernetes.io/configuration-snippet": "more_set_headers \"ExpectedHost: $http_host\";", } - ing := framework.NewSingleIngressWithTLS(fromHost, "/", fromHost, []string{fromHost, toHost}, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngressWithTLS(fromHost, "/", fromHost, []string{fromHost, toHost}, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) _, err := framework.CreateIngressTLSSecret(f.KubeClientSet, diff --git a/test/e2e/annotations/http2pushpreload.go b/test/e2e/annotations/http2pushpreload.go index 5ba7212b1..cc5d94d76 100644 --- a/test/e2e/annotations/http2pushpreload.go +++ b/test/e2e/annotations/http2pushpreload.go @@ -38,7 +38,7 @@ var _ = framework.IngressNginxDescribe("Annotations - HTTP2 Push Preload", func( "nginx.ingress.kubernetes.io/http2-push-preload": "true", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/influxdb.go b/test/e2e/annotations/influxdb.go index 23917b6b8..ed131718d 100644 --- a/test/e2e/annotations/influxdb.go +++ b/test/e2e/annotations/influxdb.go @@ -53,8 +53,8 @@ var _ = framework.IngressNginxDescribe("Annotations - influxdb", func() { createInfluxDBIngress( f, host, - "http-svc", - 8080, + framework.EchoService, + 80, map[string]string{ "nginx.ingress.kubernetes.io/enable-influxdb": "true", "nginx.ingress.kubernetes.io/influxdb-host": ifs.Spec.ClusterIP, diff --git a/test/e2e/annotations/ipwhitelist.go b/test/e2e/annotations/ipwhitelist.go index 74fd12d0f..d6cad5344 100644 --- a/test/e2e/annotations/ipwhitelist.go +++ b/test/e2e/annotations/ipwhitelist.go @@ -42,7 +42,7 @@ var _ = framework.IngressNginxDescribe("Annotations - IPWhiteList", func() { "nginx.ingress.kubernetes.io/whitelist-source-range": "18.0.0.0/8, 56.0.0.0/8", } - ing := framework.NewSingleIngress(host, "/", host, nameSpace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, nameSpace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/log.go b/test/e2e/annotations/log.go index 068f953bd..a702f3eb1 100644 --- a/test/e2e/annotations/log.go +++ b/test/e2e/annotations/log.go @@ -39,7 +39,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Log", func() { "nginx.ingress.kubernetes.io/enable-access-log": "false", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -54,7 +54,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Log", func() { "nginx.ingress.kubernetes.io/enable-rewrite-log": "true", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/luarestywaf.go b/test/e2e/annotations/luarestywaf.go index aaeda0c59..b9ff6be02 100644 --- a/test/e2e/annotations/luarestywaf.go +++ b/test/e2e/annotations/luarestywaf.go @@ -38,7 +38,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() { Context("when lua-resty-waf is enabled", func() { It("should return 403 for a malicious request that matches a default WAF rule and 200 for other requests", func() { host := "foo" - createIngress(f, host, "http-svc", 80, map[string]string{"nginx.ingress.kubernetes.io/lua-resty-waf": "active"}) + createIngress(f, host, framework.EchoService, 80, map[string]string{"nginx.ingress.kubernetes.io/lua-resty-waf": "active"}) url := fmt.Sprintf("%s?msg=XSS", f.GetURL(framework.HTTP)) resp, _, errs := gorequest.New(). @@ -51,7 +51,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() { }) It("should not apply ignored rulesets", func() { host := "foo" - createIngress(f, host, "http-svc", 80, map[string]string{ + createIngress(f, host, framework.EchoService, 80, map[string]string{ "nginx.ingress.kubernetes.io/lua-resty-waf": "active", "nginx.ingress.kubernetes.io/lua-resty-waf-ignore-rulesets": "41000_sqli, 42000_xss"}) @@ -66,7 +66,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() { }) It("should apply the score threshold", func() { host := "foo" - createIngress(f, host, "http-svc", 80, map[string]string{ + createIngress(f, host, framework.EchoService, 80, map[string]string{ "nginx.ingress.kubernetes.io/lua-resty-waf": "active", "nginx.ingress.kubernetes.io/lua-resty-waf-score-threshold": "20"}) @@ -82,7 +82,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() { It("should not reject request with an unknown content type", func() { host := "foo" contenttype := "application/octet-stream" - createIngress(f, host, "http-svc", 80, map[string]string{ + createIngress(f, host, framework.EchoService, 80, map[string]string{ "nginx.ingress.kubernetes.io/lua-resty-waf-allow-unknown-content-types": "true", "nginx.ingress.kubernetes.io/lua-resty-waf": "active"}) @@ -99,7 +99,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() { It("should not fail a request with multipart content type when multipart body processing disabled", func() { contenttype := "multipart/form-data; boundary=alamofire.boundary.3fc2e849279e18fc" host := "foo" - createIngress(f, host, "http-svc", 80, map[string]string{ + createIngress(f, host, framework.EchoService, 80, map[string]string{ "nginx.ingress.kubernetes.io/lua-resty-waf-process-multipart-body": "false", "nginx.ingress.kubernetes.io/lua-resty-waf": "active"}) @@ -116,7 +116,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() { It("should fail a request with multipart content type when multipart body processing enabled by default", func() { contenttype := "multipart/form-data; boundary=alamofire.boundary.3fc2e849279e18fc" host := "foo" - createIngress(f, host, "http-svc", 80, map[string]string{ + createIngress(f, host, framework.EchoService, 80, map[string]string{ "nginx.ingress.kubernetes.io/lua-resty-waf": "active"}) url := fmt.Sprintf("%s?msg=my-message", f.GetURL(framework.HTTP)) @@ -131,7 +131,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() { }) It("should apply configured extra rules", func() { host := "foo" - createIngress(f, host, "http-svc", 80, map[string]string{ + createIngress(f, host, framework.EchoService, 80, map[string]string{ "nginx.ingress.kubernetes.io/lua-resty-waf": "active", "nginx.ingress.kubernetes.io/lua-resty-waf-extra-rules": `[=[ { "access": [ @@ -170,7 +170,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() { Context("when lua-resty-waf is not enabled", func() { It("should return 200 even for a malicious request", func() { host := "foo" - createIngress(f, host, "http-svc", 80, map[string]string{}) + createIngress(f, host, framework.EchoService, 80, map[string]string{}) url := fmt.Sprintf("%s?msg=XSS", f.GetURL(framework.HTTP)) resp, _, errs := gorequest.New(). @@ -183,7 +183,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() { }) It("should run in simulate mode", func() { host := "foo" - createIngress(f, host, "http-svc", 80, map[string]string{"nginx.ingress.kubernetes.io/lua-resty-waf": "simulate"}) + createIngress(f, host, framework.EchoService, 80, map[string]string{"nginx.ingress.kubernetes.io/lua-resty-waf": "simulate"}) url := fmt.Sprintf("%s?msg=XSS", f.GetURL(framework.HTTP)) resp, _, errs := gorequest.New(). diff --git a/test/e2e/annotations/mirror.go b/test/e2e/annotations/mirror.go index efb34e07e..6816f6964 100644 --- a/test/e2e/annotations/mirror.go +++ b/test/e2e/annotations/mirror.go @@ -40,7 +40,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Mirror", func() { "nginx.ingress.kubernetes.io/mirror-uri": "/mirror", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -55,7 +55,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Mirror", func() { "nginx.ingress.kubernetes.io/mirror-request-body": "off", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/modsecurity.go b/test/e2e/annotations/modsecurity.go index 60343f644..7a6771b97 100644 --- a/test/e2e/annotations/modsecurity.go +++ b/test/e2e/annotations/modsecurity.go @@ -41,7 +41,7 @@ var _ = framework.IngressNginxDescribe("Annotations - ModSecurityLocation", func "nginx.ingress.kubernetes.io/enable-modsecurity": "true", } - ing := framework.NewSingleIngress(host, "/", host, nameSpace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, nameSpace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -61,7 +61,7 @@ var _ = framework.IngressNginxDescribe("Annotations - ModSecurityLocation", func "nginx.ingress.kubernetes.io/modsecurity-transaction-id": "modsecurity-$request_id", } - ing := framework.NewSingleIngress(host, "/", host, nameSpace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, nameSpace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -80,7 +80,7 @@ var _ = framework.IngressNginxDescribe("Annotations - ModSecurityLocation", func "nginx.ingress.kubernetes.io/enable-modsecurity": "false", } - ing := framework.NewSingleIngress(host, "/", host, nameSpace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, nameSpace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -98,7 +98,7 @@ var _ = framework.IngressNginxDescribe("Annotations - ModSecurityLocation", func "nginx.ingress.kubernetes.io/modsecurity-snippet": "SecRuleEngine On", } - ing := framework.NewSingleIngress(host, "/", host, nameSpace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, nameSpace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/proxy.go b/test/e2e/annotations/proxy.go index f76cd1d2e..281de3a7a 100644 --- a/test/e2e/annotations/proxy.go +++ b/test/e2e/annotations/proxy.go @@ -42,7 +42,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() { "nginx.ingress.kubernetes.io/proxy-redirect-to": "goodbye.com", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -57,7 +57,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() { "nginx.ingress.kubernetes.io/proxy-redirect-to": "goodbye.com", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -72,7 +72,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() { "nginx.ingress.kubernetes.io/proxy-redirect-to": "goodbye.com", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -86,7 +86,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() { "nginx.ingress.kubernetes.io/proxy-body-size": "8m", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -100,7 +100,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() { "nginx.ingress.kubernetes.io/proxy-body-size": "15r", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -116,7 +116,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() { "nginx.ingress.kubernetes.io/proxy-read-timeout": "20", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -134,7 +134,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() { "nginx.ingress.kubernetes.io/proxy-read-timeout": "20k", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -152,7 +152,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() { "nginx.ingress.kubernetes.io/proxy-buffer-size": "8k", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -169,7 +169,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() { "nginx.ingress.kubernetes.io/proxy-request-buffering": "off", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -185,7 +185,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() { "nginx.ingress.kubernetes.io/proxy-next-upstream-tries": "5", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -198,7 +198,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() { It("should build proxy next upstream using configmap values", func() { annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.SetNginxConfigMapData(map[string]string{ @@ -221,7 +221,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() { "nginx.ingress.kubernetes.io/proxy-cookie-path": "/one/ /", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -236,7 +236,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() { "nginx.ingress.kubernetes.io/proxy-http-version": "1.0", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/proxyssl.go b/test/e2e/annotations/proxyssl.go index d83c11071..e1b06483f 100644 --- a/test/e2e/annotations/proxyssl.go +++ b/test/e2e/annotations/proxyssl.go @@ -44,7 +44,7 @@ var _ = framework.IngressNginxDescribe("Annotations - ProxySSL", func() { _, err := framework.CreateIngressMASecret(f.KubeClientSet, host, host, f.Namespace) Expect(err).ToNot(HaveOccurred()) - ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) assertProxySSL(f, host, "DEFAULT", "TLSv1 TLSv1.1 TLSv1.2", "off", 1) @@ -61,7 +61,7 @@ var _ = framework.IngressNginxDescribe("Annotations - ProxySSL", func() { _, err := framework.CreateIngressMASecret(f.KubeClientSet, host, host, f.Namespace) Expect(err).ToNot(HaveOccurred()) - ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) assertProxySSL(f, host, "DEFAULT", "TLSv1 TLSv1.1 TLSv1.2", "on", 2) @@ -77,7 +77,7 @@ var _ = framework.IngressNginxDescribe("Annotations - ProxySSL", func() { _, err := framework.CreateIngressMASecret(f.KubeClientSet, host, host, f.Namespace) Expect(err).ToNot(HaveOccurred()) - ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) assertProxySSL(f, host, "HIGH:!AES", "TLSv1 TLSv1.1 TLSv1.2", "off", 1) @@ -93,7 +93,7 @@ var _ = framework.IngressNginxDescribe("Annotations - ProxySSL", func() { _, err := framework.CreateIngressMASecret(f.KubeClientSet, host, host, f.Namespace) Expect(err).ToNot(HaveOccurred()) - ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) assertProxySSL(f, host, "DEFAULT", "TLSv1.2 TLSv1.3", "off", 1) diff --git a/test/e2e/annotations/redirect.go b/test/e2e/annotations/redirect.go index a165a7e5a..4009b9f7d 100644 --- a/test/e2e/annotations/redirect.go +++ b/test/e2e/annotations/redirect.go @@ -52,7 +52,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Redirect", func() { annotations := map[string]string{"nginx.ingress.kubernetes.io/permanent-redirect": redirectURL} - ing := framework.NewSingleIngress(host, redirectPath, host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, redirectPath, host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -88,7 +88,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Redirect", func() { "nginx.ingress.kubernetes.io/permanent-redirect-code": strconv.Itoa(redirectCode), } - ing := framework.NewSingleIngress(host, redirectPath, host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, redirectPath, host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/rewrite.go b/test/e2e/annotations/rewrite.go index c1baea61b..fafb81ec7 100644 --- a/test/e2e/annotations/rewrite.go +++ b/test/e2e/annotations/rewrite.go @@ -48,7 +48,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { "nginx.ingress.kubernetes.io/enable-rewrite-log": "true", } - ing := framework.NewSingleIngress(host, "/something", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/something", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -74,7 +74,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { host := "rewrite.bar.com" By("creating a regular ingress definition") - ing := framework.NewSingleIngress("kube-lego", "/.well-known/acme/challenge", host, f.Namespace, "http-svc", 80, &map[string]string{}) + ing := framework.NewSingleIngress("kube-lego", "/.well-known/acme/challenge", host, f.Namespace, framework.EchoService, 80, &map[string]string{}) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -87,7 +87,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { Get(f.GetURL(framework.HTTP)+"/.well-known/acme/challenge"). Set("Host", host). End() - expectBodyRequestURI := fmt.Sprintf("request_uri=http://%v:8080/.well-known/acme/challenge", host) + expectBodyRequestURI := fmt.Sprintf("request_uri=http://%v:80/.well-known/acme/challenge", host) Expect(len(errs)).Should(Equal(0)) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) Expect(body).Should(ContainSubstring(expectBodyRequestURI)) @@ -96,7 +96,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { annotations := map[string]string{ "nginx.ingress.kubernetes.io/rewrite-target": "/new/backend", } - rewriteIng := framework.NewSingleIngress("rewrite-index", "/", host, f.Namespace, "http-svc", 80, &annotations) + rewriteIng := framework.NewSingleIngress("rewrite-index", "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(rewriteIng) @@ -119,7 +119,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { host := "rewrite.bar.com" By("creating a regular ingress definition") - ing := framework.NewSingleIngress("foo", "/foo", host, f.Namespace, "http-svc", 80, &map[string]string{}) + ing := framework.NewSingleIngress("foo", "/foo", host, f.Namespace, framework.EchoService, 80, &map[string]string{}) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -132,7 +132,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { "nginx.ingress.kubernetes.io/use-regex": "true", "nginx.ingress.kubernetes.io/rewrite-target": "/new/backend", } - ing = framework.NewSingleIngress("regex", "/foo.+", host, f.Namespace, "http-svc", 80, &annotations) + ing = framework.NewSingleIngress("regex", "/foo.+", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -145,7 +145,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { Get(f.GetURL(framework.HTTP)+"/foo"). Set("Host", host). End() - expectBodyRequestURI := fmt.Sprintf("request_uri=http://%v:8080/foo", host) + expectBodyRequestURI := fmt.Sprintf("request_uri=http://%v:80/foo", host) Expect(len(errs)).Should(Equal(0)) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) Expect(body).Should(ContainSubstring(expectBodyRequestURI)) @@ -155,7 +155,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { Get(f.GetURL(framework.HTTP)+"/foo/bar"). Set("Host", host). End() - expectBodyRequestURI = fmt.Sprintf("request_uri=http://%v:8080/new/backend", host) + expectBodyRequestURI = fmt.Sprintf("request_uri=http://%v:80/new/backend", host) Expect(len(errs)).Should(Equal(0)) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) Expect(body).Should(ContainSubstring(expectBodyRequestURI)) @@ -165,7 +165,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { host := "rewrite.bar.com" By("creating a regular ingress definition") - ing := framework.NewSingleIngress("foo", "/foo/bar/bar", host, f.Namespace, "http-svc", 80, &map[string]string{}) + ing := framework.NewSingleIngress("foo", "/foo/bar/bar", host, f.Namespace, framework.EchoService, 80, &map[string]string{}) f.EnsureIngress(ing) By(`creating an ingress definition with the use-regex annotation`) @@ -173,7 +173,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { "nginx.ingress.kubernetes.io/use-regex": "true", "nginx.ingress.kubernetes.io/rewrite-target": "/new/backend", } - ing = framework.NewSingleIngress("regex", "/foo/bar/[a-z]{3}", host, f.Namespace, "http-svc", 80, &annotations) + ing = framework.NewSingleIngress("regex", "/foo/bar/[a-z]{3}", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -186,7 +186,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { Get(f.GetURL(framework.HTTP)+"/foo/bar/bar"). Set("Host", host). End() - expectBodyRequestURI := fmt.Sprintf("request_uri=http://%v:8080/new/backend", host) + expectBodyRequestURI := fmt.Sprintf("request_uri=http://%v:80/new/backend", host) Expect(len(errs)).Should(Equal(0)) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) Expect(body).Should(ContainSubstring(expectBodyRequestURI)) @@ -200,7 +200,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { "nginx.ingress.kubernetes.io/use-regex": "true", "nginx.ingress.kubernetes.io/rewrite-target": "/new/backend/$1", } - ing := framework.NewSingleIngress("regex", "/foo/bar/(.+)", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress("regex", "/foo/bar/(.+)", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -213,7 +213,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { Get(f.GetURL(framework.HTTP)+"/foo/bar/bar"). Set("Host", host). End() - expectBodyRequestURI := fmt.Sprintf("request_uri=http://%v:8080/new/backend/bar", host) + expectBodyRequestURI := fmt.Sprintf("request_uri=http://%v:80/new/backend/bar", host) Expect(len(errs)).Should(Equal(0)) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) Expect(body).Should(ContainSubstring(expectBodyRequestURI)) diff --git a/test/e2e/annotations/satisfy.go b/test/e2e/annotations/satisfy.go index 5fbfde31d..aa67a3ea4 100644 --- a/test/e2e/annotations/satisfy.go +++ b/test/e2e/annotations/satisfy.go @@ -58,7 +58,7 @@ var _ = framework.IngressNginxDescribe("Annotations - SATISFY", func() { annotationKey: "all", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &initAnnotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &initAnnotations) f.EnsureIngress(ing) for key, result := range results { @@ -91,10 +91,10 @@ var _ = framework.IngressNginxDescribe("Annotations - SATISFY", func() { // setup external auth f.NewHttpbinDeployment() - err := framework.WaitForEndpoints(f.KubeClientSet, framework.DefaultTimeout, "httpbin", f.Namespace, 1) + err := framework.WaitForEndpoints(f.KubeClientSet, framework.DefaultTimeout, framework.HTTPBinService, f.Namespace, 1) Expect(err).NotTo(HaveOccurred()) - e, err := f.KubeClientSet.CoreV1().Endpoints(f.Namespace).Get("httpbin", metav1.GetOptions{}) + e, err := f.KubeClientSet.CoreV1().Endpoints(f.Namespace).Get(framework.HTTPBinService, metav1.GetOptions{}) Expect(err).NotTo(HaveOccurred()) httpbinIP := e.Subsets[0].Addresses[0].IP @@ -116,7 +116,7 @@ var _ = framework.IngressNginxDescribe("Annotations - SATISFY", func() { "nginx.ingress.kubernetes.io/satisfy": "any", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, func(server string) bool { diff --git a/test/e2e/annotations/serversnippet.go b/test/e2e/annotations/serversnippet.go index 6995d6c22..1a1f7f1df 100644 --- a/test/e2e/annotations/serversnippet.go +++ b/test/e2e/annotations/serversnippet.go @@ -42,7 +42,7 @@ var _ = framework.IngressNginxDescribe("Annotations - ServerSnippet", func() { more_set_headers "Content-Type: $content_type";`, } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/snippet.go b/test/e2e/annotations/snippet.go index 13da543ae..dc029dc94 100644 --- a/test/e2e/annotations/snippet.go +++ b/test/e2e/annotations/snippet.go @@ -39,7 +39,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Configurationsnippet", fun more_set_headers "Request-Id: $req_id";`, } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/sslciphers.go b/test/e2e/annotations/sslciphers.go index 5ea01f57b..ae8f75530 100644 --- a/test/e2e/annotations/sslciphers.go +++ b/test/e2e/annotations/sslciphers.go @@ -39,7 +39,7 @@ var _ = framework.IngressNginxDescribe("Annotations - SSL CIPHERS", func() { "nginx.ingress.kubernetes.io/ssl-ciphers": "ALL:!aNULL:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP", } - ing := framework.NewSingleIngress(host, "/something", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/something", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/upstreamhashby.go b/test/e2e/annotations/upstreamhashby.go index 59c2c765e..301262129 100644 --- a/test/e2e/annotations/upstreamhashby.go +++ b/test/e2e/annotations/upstreamhashby.go @@ -33,7 +33,7 @@ import ( func startIngress(f *framework.Framework, annotations *map[string]string) map[string]bool { host := "upstream-hash-by.foo.com" - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, func(server string) bool { @@ -52,7 +52,7 @@ func startIngress(f *framework.Framework, annotations *map[string]string) map[st }) Expect(err).Should(BeNil()) - re, _ := regexp.Compile(`Hostname: http-svc.*`) + re, _ := regexp.Compile(fmt.Sprintf(`Hostname: %v.*`, framework.EchoService)) podMap := map[string]bool{} for i := 0; i < 100; i++ { diff --git a/test/e2e/annotations/upstreamvhost.go b/test/e2e/annotations/upstreamvhost.go index 594eca9d1..dca09ed42 100644 --- a/test/e2e/annotations/upstreamvhost.go +++ b/test/e2e/annotations/upstreamvhost.go @@ -38,7 +38,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Upstreamvhost", func() { "nginx.ingress.kubernetes.io/upstream-vhost": "upstreamvhost.bar.com", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/xforwardedprefix.go b/test/e2e/annotations/xforwardedprefix.go index ddbdc6822..872b3de42 100644 --- a/test/e2e/annotations/xforwardedprefix.go +++ b/test/e2e/annotations/xforwardedprefix.go @@ -42,7 +42,7 @@ var _ = framework.IngressNginxDescribe("Annotations - X-Forwarded-Prefix", func( "nginx.ingress.kubernetes.io/rewrite-target": "/foo", } - f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations)) + f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations)) f.WaitForNginxServer(host, func(server string) bool { return Expect(server).Should(ContainSubstring("proxy_set_header X-Forwarded-Prefix \"/test/value\";")) @@ -66,7 +66,7 @@ var _ = framework.IngressNginxDescribe("Annotations - X-Forwarded-Prefix", func( "nginx.ingress.kubernetes.io/rewrite-target": "/foo", } - f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations)) + f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations)) f.WaitForNginxServer(host, func(server string) bool { return Expect(server).Should(And(ContainSubstring(host), Not(ContainSubstring("proxy_set_header X-Forwarded-Prefix")))) diff --git a/test/e2e/dbg/main.go b/test/e2e/dbg/main.go index f405ecc76..0c6e3a99a 100644 --- a/test/e2e/dbg/main.go +++ b/test/e2e/dbg/main.go @@ -40,7 +40,7 @@ var _ = framework.IngressNginxDescribe("Debug Tool", func() { It("should list the backend servers", func() { annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxConfiguration(func(cfg string) bool { @@ -60,7 +60,7 @@ var _ = framework.IngressNginxDescribe("Debug Tool", func() { It("should get information for a specific backend server", func() { annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxConfiguration(func(cfg string) bool { @@ -89,7 +89,7 @@ var _ = framework.IngressNginxDescribe("Debug Tool", func() { It("should produce valid JSON for /dbg general", func() { annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) cmd := "/dbg general" diff --git a/test/e2e/defaultbackend/custom_default_backend.go b/test/e2e/defaultbackend/custom_default_backend.go index a6e4ab0bc..fc9a580d3 100644 --- a/test/e2e/defaultbackend/custom_default_backend.go +++ b/test/e2e/defaultbackend/custom_default_backend.go @@ -17,6 +17,7 @@ limitations under the License. package defaultbackend import ( + "fmt" "net/http" "strings" @@ -39,7 +40,7 @@ var _ = framework.IngressNginxDescribe("Custom Default Backend", func() { framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 1, func(deployment *appsv1.Deployment) error { args := deployment.Spec.Template.Spec.Containers[0].Args - args = append(args, "--default-backend-service=$(POD_NAMESPACE)/http-svc") + args = append(args, fmt.Sprintf("--default-backend-service=$(POD_NAMESPACE)/%v", framework.EchoService)) deployment.Spec.Template.Spec.Containers[0].Args = args _, err := f.KubeClientSet.AppsV1().Deployments(f.Namespace).Update(deployment) diff --git a/test/e2e/defaultbackend/with_hosts.go b/test/e2e/defaultbackend/with_hosts.go index ce74374a1..1c4830da5 100644 --- a/test/e2e/defaultbackend/with_hosts.go +++ b/test/e2e/defaultbackend/with_hosts.go @@ -54,8 +54,8 @@ var _ = framework.IngressNginxDescribe("Default backend with hosts", func() { }, Spec: extensions.IngressSpec{ Backend: &extensions.IngressBackend{ - ServiceName: "http-svc", - ServicePort: intstr.FromInt(8080), + ServiceName: framework.EchoService, + ServicePort: intstr.FromInt(80), }, Rules: []extensions.IngressRule{ { diff --git a/test/e2e/framework/deployment.go b/test/e2e/framework/deployment.go index 3beb1fe7e..f9c4aecc1 100644 --- a/test/e2e/framework/deployment.go +++ b/test/e2e/framework/deployment.go @@ -27,6 +27,15 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" ) +// EchoService name of the deployment for the echo app +const EchoService = "echo" + +// SlowEchoService name of the deployment for the echo app +const SlowEchoService = "slow-echo" + +// HTTPBinService name of the deployment for the httpbin app +const HTTPBinService = "httpbin" + // NewEchoDeployment creates a new single replica deployment of the echoserver image in a particular namespace func (f *Framework) NewEchoDeployment() { f.NewEchoDeploymentWithReplicas(1) @@ -34,32 +43,266 @@ func (f *Framework) NewEchoDeployment() { // NewEchoDeploymentWithReplicas creates a new deployment of the echoserver image in a particular namespace. Number of // replicas is configurable -func (f *Framework) NewEchoDeploymentWithReplicas(replicas int32) { - f.NewEchoDeploymentWithNameAndReplicas("http-svc", replicas) +func (f *Framework) NewEchoDeploymentWithReplicas(replicas int) { + f.NewEchoDeploymentWithNameAndReplicas(EchoService, replicas) } // NewEchoDeploymentWithNameAndReplicas creates a new deployment of the echoserver image in a particular namespace. Number of // replicas is configurable and // name is configurable -func (f *Framework) NewEchoDeploymentWithNameAndReplicas(name string, replicas int32) { - f.NewDeployment(name, "gcr.io/kubernetes-e2e-test-images/echoserver:2.2", 8080, replicas) +func (f *Framework) NewEchoDeploymentWithNameAndReplicas(name string, replicas int) { + + data := map[string]string{} + data["nginx.conf"] = `# + +env HOSTNAME; +env NODE_NAME; +env POD_NAME; +env POD_NAMESPACE; +env POD_IP; + +daemon off; + +events { + worker_connections 1024; +} + +http { + default_type 'text/plain'; + client_max_body_size 0; + + init_by_lua_block { + local template = require "resty.template" + + tmpl = template.compile([[ + +Hostname: {*os.getenv("HOSTNAME") or "N/A"*} + +Pod Information: +{% if os.getenv("POD_NAME") then %} + node name: {*os.getenv("NODE_NAME") or "N/A"*} + pod name: {*os.getenv("POD_NAME") or "N/A"*} + pod namespace: {*os.getenv("POD_NAMESPACE") or "N/A"*} + pod IP: {*os.getenv("POD_IP") or "N/A"*} +{% else %} + -no pod information available- +{% end %} + +Server values: + server_version=nginx: {*ngx.var.nginx_version*} - lua: {*ngx.config.ngx_lua_version*} + +Request Information: + client_address={*ngx.var.remote_addr*} + method={*ngx.req.get_method()*} + real path={*ngx.var.request_uri*} + query={*ngx.var.query_string or ""*} + request_version={*ngx.req.http_version()*} + request_scheme={*ngx.var.scheme*} + request_uri={*ngx.var.scheme.."://"..ngx.var.host..":"..ngx.var.server_port..ngx.var.request_uri*} + +Request Headers: +{% for i, key in ipairs(keys) do %} + {% local val = headers[key] %} + {% if type(val) == "table" then %} + {% for i = 1,#val do %} + {*key*}={*val[i]*} + {% end %} + {% else %} + {*key*}={*val*} + {% end %} +{% end %} + +Request Body: +{*ngx.var.request_body or " -no body in request-"*} +]]) + } + + server { + listen 80 default_server reuseport; + + server_name _; + + keepalive_timeout 620s; + + location / { + lua_need_request_body on; + + content_by_lua_block { + ngx.header["Server"] = "echoserver" + + local headers = ngx.req.get_headers() + local keys = {} + for key, val in pairs(headers) do + table.insert(keys, key) + end + table.sort(keys) + + ngx.say(tmpl({os=os, ngx=ngx, keys=keys, headers=headers})) + } + } + } +} +` + + _, err := f.KubeClientSet.CoreV1().ConfigMaps(f.Namespace).Create(&corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: f.Namespace, + }, + Data: data, + }) + Expect(err).NotTo(HaveOccurred(), "failed to create a deployment") + + deployment := newDeployment(name, f.Namespace, "openresty/openresty:1.15.8.2-alpine", 80, int32(replicas), + []string{ + "/bin/sh", + "-c", + "apk add -U perl curl && opm get bungle/lua-resty-template && openresty", + }, + []corev1.VolumeMount{ + { + Name: name, + MountPath: "/usr/local/openresty/nginx/conf/nginx.conf", + SubPath: "nginx.conf", + ReadOnly: true, + }, + }, + []corev1.Volume{ + { + Name: name, + VolumeSource: corev1.VolumeSource{ + ConfigMap: &corev1.ConfigMapVolumeSource{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: name, + }, + }, + }, + }, + }, + ) + + d, err := f.EnsureDeployment(deployment) + Expect(err).NotTo(HaveOccurred(), "failed to create a deployment") + Expect(d).NotTo(BeNil(), "expected a deployment but none returned") + + service := &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: f.Namespace, + }, + Spec: corev1.ServiceSpec{ + Ports: []corev1.ServicePort{ + { + Name: "http", + Port: 80, + TargetPort: intstr.FromInt(80), + Protocol: corev1.ProtocolTCP, + }, + }, + Selector: map[string]string{ + "app": name, + }, + }, + } + + s := f.EnsureService(service) + Expect(s).NotTo(BeNil(), "expected a service but none returned") + + err = WaitForEndpoints(f.KubeClientSet, DefaultTimeout, name, f.Namespace, replicas) + Expect(err).NotTo(HaveOccurred(), "failed to wait for endpoints to become ready") } // NewSlowEchoDeployment creates a new deployment of the slow echo server image in a particular namespace. func (f *Framework) NewSlowEchoDeployment() { - f.NewDeployment("slowecho", "breunigs/slowechoserver", 8080, 1) + data := map[string]string{} + data["default.conf"] = `# + +server { + access_log on; + access_log /dev/stdout; + + listen 80; + + location / { + echo ok; + } + + location ~ ^/sleep/(?[0-9]+)$ { + echo_sleep $sleepTime; + echo "ok after $sleepTime seconds"; + } } -// NewHttpbinDeployment creates a new single replica deployment of the httpbin image in a particular namespace. -func (f *Framework) NewHttpbinDeployment() { - f.NewDeployment("httpbin", "kennethreitz/httpbin", 80, 1) +` + + _, err := f.KubeClientSet.CoreV1().ConfigMaps(f.Namespace).Create(&corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: SlowEchoService, + Namespace: f.Namespace, + }, + Data: data, + }) + Expect(err).NotTo(HaveOccurred(), "failed to create a deployment") + + deployment := newDeployment(SlowEchoService, f.Namespace, "openresty/openresty:1.15.8.2-alpine", 80, 1, + nil, + []corev1.VolumeMount{ + { + Name: SlowEchoService, + MountPath: "/etc/nginx/conf.d", + ReadOnly: true, + }, + }, + []corev1.Volume{ + { + Name: SlowEchoService, + VolumeSource: corev1.VolumeSource{ + ConfigMap: &corev1.ConfigMapVolumeSource{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: SlowEchoService, + }, + }, + }, + }, + }, + ) + + d, err := f.EnsureDeployment(deployment) + Expect(err).NotTo(HaveOccurred(), "failed to create a deployment") + Expect(d).NotTo(BeNil(), "expected a deployment but none returned") + + service := &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Name: SlowEchoService, + Namespace: f.Namespace, + }, + Spec: corev1.ServiceSpec{ + Ports: []corev1.ServicePort{ + { + Name: "http", + Port: 80, + TargetPort: intstr.FromInt(80), + Protocol: corev1.ProtocolTCP, + }, + }, + Selector: map[string]string{ + "app": SlowEchoService, + }, + }, + } + + s := f.EnsureService(service) + Expect(s).NotTo(BeNil(), "expected a service but none returned") + + err = WaitForEndpoints(f.KubeClientSet, DefaultTimeout, SlowEchoService, f.Namespace, 1) + Expect(err).NotTo(HaveOccurred(), "failed to wait for endpoints to become ready") } -// NewDeployment creates a new deployment in a particular namespace. -func (f *Framework) NewDeployment(name, image string, port int32, replicas int32) { +func newDeployment(name, namespace, image string, port int32, replicas int32, command []string, + volumeMounts []corev1.VolumeMount, volumes []corev1.Volume) *appsv1.Deployment { probe := &corev1.Probe{ - InitialDelaySeconds: 5, - PeriodSeconds: 10, + InitialDelaySeconds: 1, + PeriodSeconds: 5, SuccessThreshold: 1, TimeoutSeconds: 1, Handler: corev1.Handler{ @@ -70,10 +313,10 @@ func (f *Framework) NewDeployment(name, image string, port int32, replicas int32 }, } - deployment := &appsv1.Deployment{ + d := &appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ Name: name, - Namespace: f.Namespace, + Namespace: namespace, }, Spec: appsv1.DeploymentSpec{ Replicas: NewInt32(replicas), @@ -103,13 +346,31 @@ func (f *Framework) NewDeployment(name, image string, port int32, replicas int32 }, ReadinessProbe: probe, LivenessProbe: probe, + VolumeMounts: volumeMounts, }, }, + Volumes: volumes, }, }, }, } + if len(command) > 0 { + d.Spec.Template.Spec.Containers[0].Command = command + } + + return d +} + +// NewHttpbinDeployment creates a new single replica deployment of the httpbin image in a particular namespace. +func (f *Framework) NewHttpbinDeployment() { + f.NewDeployment(HTTPBinService, "ingress-controller/httpbin:dev", 80, 1) +} + +// NewDeployment creates a new deployment in a particular namespace. +func (f *Framework) NewDeployment(name, image string, port int32, replicas int32) { + deployment := newDeployment(name, f.Namespace, image, port, replicas, nil, nil, nil) + d, err := f.EnsureDeployment(deployment) Expect(err).NotTo(HaveOccurred(), "failed to create a deployment") Expect(d).NotTo(BeNil(), "expected a deployment but none returned") @@ -151,3 +412,16 @@ func (f *Framework) DeleteDeployment(name string) error { LabelSelector: labelSelectorToString(d.Spec.Selector.MatchLabels), }) } + +// ScaleDeploymentToZero scales a deployment with a particular name and waits for the pods to be deleted +func (f *Framework) ScaleDeploymentToZero(name string) { + d, err := f.KubeClientSet.AppsV1().Deployments(f.Namespace).Get(name, metav1.GetOptions{}) + Expect(err).NotTo(HaveOccurred(), "failed to get a deployment") + Expect(d).NotTo(BeNil(), "expected a deployment but none returned") + + d.Spec.Replicas = NewInt32(0) + + d, err = f.EnsureDeployment(d) + Expect(err).NotTo(HaveOccurred(), "waiting deployment scale to 0") + Expect(d).NotTo(BeNil(), "expected a deployment but none returned") +} diff --git a/test/e2e/framework/framework.go b/test/e2e/framework/framework.go index 2a05e4862..8b3a09f35 100644 --- a/test/e2e/framework/framework.go +++ b/test/e2e/framework/framework.go @@ -110,9 +110,6 @@ func (f *Framework) BeforeEach() { LabelSelector: "app.kubernetes.io/name=ingress-nginx", }) Expect(err).NotTo(HaveOccurred()) - - // we wait for any change in the informers and SSL certificate generation - time.Sleep(5 * time.Second) } // AfterEach deletes the namespace, after reading its events. diff --git a/test/e2e/framework/k8s.go b/test/e2e/framework/k8s.go index 5d9b8f7d9..b5fd1c688 100644 --- a/test/e2e/framework/k8s.go +++ b/test/e2e/framework/k8s.go @@ -122,7 +122,7 @@ func (f *Framework) EnsureDeployment(deployment *appsv1.Deployment) (*appsv1.Dep // WaitForPodsReady waits for a given amount of time until a group of Pods is running in the given namespace. func WaitForPodsReady(kubeClientSet kubernetes.Interface, timeout time.Duration, expectedReplicas int, namespace string, opts metav1.ListOptions) error { - return wait.Poll(2*time.Second, timeout, func() (bool, error) { + return wait.Poll(Poll, timeout, func() (bool, error) { pl, err := kubeClientSet.CoreV1().Pods(namespace).List(opts) if err != nil { return false, nil @@ -145,7 +145,7 @@ func WaitForPodsReady(kubeClientSet kubernetes.Interface, timeout time.Duration, // WaitForPodsDeleted waits for a given amount of time until a group of Pods are deleted in the given namespace. func WaitForPodsDeleted(kubeClientSet kubernetes.Interface, timeout time.Duration, namespace string, opts metav1.ListOptions) error { - return wait.Poll(2*time.Second, timeout, func() (bool, error) { + return wait.Poll(Poll, timeout, func() (bool, error) { pl, err := kubeClientSet.CoreV1().Pods(namespace).List(opts) if err != nil { return false, nil @@ -163,12 +163,15 @@ func WaitForEndpoints(kubeClientSet kubernetes.Interface, timeout time.Duration, if expectedEndpoints == 0 { return nil } - return wait.Poll(2*time.Second, timeout, func() (bool, error) { + + return wait.Poll(Poll, timeout, func() (bool, error) { endpoint, err := kubeClientSet.CoreV1().Endpoints(ns).Get(name, metav1.GetOptions{}) if k8sErrors.IsNotFound(err) { return false, nil } + Expect(err).NotTo(HaveOccurred()) + if len(endpoint.Subsets) == 0 || len(endpoint.Subsets[0].Addresses) == 0 { return false, nil } diff --git a/test/e2e/gracefulshutdown/shutdown.go b/test/e2e/gracefulshutdown/shutdown.go new file mode 100755 index 000000000..05bf15410 --- /dev/null +++ b/test/e2e/gracefulshutdown/shutdown.go @@ -0,0 +1,186 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package gracefulshutdown + +import ( + "net/http" + "time" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + "github.com/parnurzeal/gorequest" + appsv1 "k8s.io/api/apps/v1" + + "k8s.io/ingress-nginx/test/e2e/framework" +) + +var _ = framework.IngressNginxDescribe("Shutdown ingress controller", func() { + f := framework.NewDefaultFramework("shutdown-ingress-controller") + + host := "shutdown" + + BeforeEach(func() { + f.UpdateNginxConfigMapData("worker-shutdown-timeout", "600s") + + f.NewSlowEchoDeployment() + }) + + AfterEach(func() { + }) + + It("should shutdown in less than 60 secons without pending connections", func() { + f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, framework.SlowEchoService, 80, nil)) + + f.WaitForNginxServer(host, + func(server string) bool { + return Expect(server).Should(ContainSubstring("server_name shutdown")) + }) + + resp, _, _ := gorequest.New(). + Get(f.GetURL(framework.HTTP)+"/sleep/1"). + Set("Host", host). + End() + Expect(resp.StatusCode).Should(Equal(http.StatusOK)) + + startTime := time.Now() + + f.ScaleDeploymentToZero("nginx-ingress-controller") + + Expect(time.Since(startTime).Seconds()).To(BeNumerically("<=", 60), "waiting shutdown") + }) + + type asyncResult struct { + errs []error + status int + } + + It("should shutdown after waiting 60 seconds for pending connections to be closed", func() { + framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 1, + func(deployment *appsv1.Deployment) error { + grace := int64(3600) + deployment.Spec.Template.Spec.TerminationGracePeriodSeconds = &grace + _, err := f.KubeClientSet.AppsV1().Deployments(f.Namespace).Update(deployment) + return err + }) + + annotations := map[string]string{ + "nginx.ingress.kubernetes.io/proxy-send-timeout": "600", + "nginx.ingress.kubernetes.io/proxy-read-timeout": "600", + } + f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, framework.SlowEchoService, 80, &annotations)) + + f.WaitForNginxServer(host, + func(server string) bool { + return Expect(server).Should(ContainSubstring("server_name shutdown")) + }) + + result := make(chan *asyncResult) + + startTime := time.Now() + + go func(host string, c chan *asyncResult) { + resp, _, errs := gorequest.New(). + Get(f.GetURL(framework.HTTP)+"/sleep/70"). + Set("Host", host). + End() + + code := 0 + if resp != nil { + code = resp.StatusCode + } + + c <- &asyncResult{errs, code} + }(host, result) + + time.Sleep(5 * time.Second) + + f.ScaleDeploymentToZero("nginx-ingress-controller") + + ticker := time.NewTicker(time.Second * 10) + + for { + select { + case res := <-result: + Expect(res.errs).Should(BeEmpty()) + Expect(res.status).To(Equal(http.StatusOK), "expecting a valid response from HTTP request") + Expect(time.Since(startTime).Seconds()).To(BeNumerically(">", 70), "waiting shutdown") + ticker.Stop() + return + case <-ticker.C: + framework.Logf("waiting for request completion after shutdown") + } + } + }) + + It("should shutdown after waiting 150 seconds for pending connections to be closed", func() { + framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 1, + func(deployment *appsv1.Deployment) error { + grace := int64(3600) + deployment.Spec.Template.Spec.TerminationGracePeriodSeconds = &grace + _, err := f.KubeClientSet.AppsV1().Deployments(f.Namespace).Update(deployment) + return err + }) + + annotations := map[string]string{ + "nginx.ingress.kubernetes.io/proxy-send-timeout": "600", + "nginx.ingress.kubernetes.io/proxy-read-timeout": "600", + } + f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, framework.SlowEchoService, 80, &annotations)) + + f.WaitForNginxServer(host, + func(server string) bool { + return Expect(server).Should(ContainSubstring("server_name shutdown")) + }) + + result := make(chan *asyncResult) + + startTime := time.Now() + + go func(host string, c chan *asyncResult) { + resp, _, errs := gorequest.New(). + Get(f.GetURL(framework.HTTP)+"/sleep/150"). + Set("Host", host). + End() + + code := 0 + if resp != nil { + code = resp.StatusCode + } + + c <- &asyncResult{errs, code} + }(host, result) + + time.Sleep(5 * time.Second) + + f.ScaleDeploymentToZero("nginx-ingress-controller") + + ticker := time.NewTicker(time.Second * 10) + + for { + select { + case res := <-result: + Expect(res.errs).Should(BeEmpty()) + Expect(res.status).To(Equal(http.StatusOK), "expecting a valid response from HTTP request") + Expect(time.Since(startTime).Seconds()).To(BeNumerically(">", 150), "waiting shutdown") + ticker.Stop() + return + case <-ticker.C: + framework.Logf("waiting for request completion after shutdown") + } + } + }) +}) diff --git a/test/e2e/gracefulshutdown/slow_requests.go b/test/e2e/gracefulshutdown/slow_requests.go index 793881b96..adbd95467 100644 --- a/test/e2e/gracefulshutdown/slow_requests.go +++ b/test/e2e/gracefulshutdown/slow_requests.go @@ -38,7 +38,7 @@ var _ = framework.IngressNginxDescribe("Graceful Shutdown - Slow Requests", func It("should let slow requests finish before shutting down", func() { host := "graceful-shutdown" - f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, "slowecho", 8080, nil)) + f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, framework.SlowEchoService, 80, nil)) f.WaitForNginxConfiguration( func(conf string) bool { return strings.Contains(conf, "worker_shutdown_timeout") diff --git a/test/e2e/leaks/lua_ssl.go b/test/e2e/leaks/lua_ssl.go index ee95d4ef3..ecd11c7cb 100644 --- a/test/e2e/leaks/lua_ssl.go +++ b/test/e2e/leaks/lua_ssl.go @@ -74,7 +74,7 @@ var _ = framework.IngressNginxDescribe("DynamicCertificates", func() { }) func privisionIngress(hostname string, f *framework.Framework) { - ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(hostname, "/", hostname, []string{hostname}, f.Namespace, "http-svc", 80, nil)) + ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(hostname, "/", hostname, []string{hostname}, f.Namespace, framework.EchoService, 80, nil)) _, err := framework.CreateIngressTLSSecret(f.KubeClientSet, ing.Spec.TLS[0].Hosts, ing.Spec.TLS[0].SecretName, diff --git a/test/e2e/loadbalance/configmap.go b/test/e2e/loadbalance/configmap.go index fbc8c0c7c..bd4da851e 100644 --- a/test/e2e/loadbalance/configmap.go +++ b/test/e2e/loadbalance/configmap.go @@ -45,14 +45,14 @@ var _ = framework.IngressNginxDescribe("Load Balance - Configmap value", func() f.UpdateNginxConfigMapData("load-balance", "ewma") - f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil)) + f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil)) f.WaitForNginxServer(host, func(server string) bool { return strings.Contains(server, "server_name load-balance.com") }) time.Sleep(waitForLuaSync) - algorithm, err := f.GetLbAlgorithm("http-svc", 80) + algorithm, err := f.GetLbAlgorithm(framework.EchoService, 80) Expect(err).Should(BeNil()) Expect(algorithm).Should(Equal("ewma")) }) diff --git a/test/e2e/loadbalance/ewma.go b/test/e2e/loadbalance/ewma.go index dc5b60416..8f12aac22 100644 --- a/test/e2e/loadbalance/ewma.go +++ b/test/e2e/loadbalance/ewma.go @@ -17,6 +17,7 @@ limitations under the License. package loadbalance import ( + "fmt" "regexp" "strings" "time" @@ -41,18 +42,18 @@ var _ = framework.IngressNginxDescribe("Load Balance - EWMA", func() { It("does not fail requests", func() { host := "load-balance.com" - f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil)) + f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil)) f.WaitForNginxServer(host, func(server string) bool { return strings.Contains(server, "server_name load-balance.com") }) time.Sleep(waitForLuaSync) - algorithm, err := f.GetLbAlgorithm("http-svc", 80) + algorithm, err := f.GetLbAlgorithm(framework.EchoService, 80) Expect(err).Should(BeNil()) Expect(algorithm).Should(Equal("ewma")) - re, _ := regexp.Compile(`http-svc.*`) + re, _ := regexp.Compile(fmt.Sprintf(`%v.*`, framework.EchoService)) replicaRequestCount := map[string]int{} for i := 0; i < 30; i++ { diff --git a/test/e2e/loadbalance/round_robin.go b/test/e2e/loadbalance/round_robin.go index 5b16f2ad9..a16a9ddf0 100644 --- a/test/e2e/loadbalance/round_robin.go +++ b/test/e2e/loadbalance/round_robin.go @@ -17,6 +17,7 @@ limitations under the License. package loadbalance import ( + "fmt" "regexp" "strings" @@ -43,13 +44,13 @@ var _ = framework.IngressNginxDescribe("Load Balance - Round Robin", func() { It("should evenly distribute requests with round-robin (default algorithm)", func() { host := "load-balance.com" - f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil)) + f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil)) f.WaitForNginxServer(host, func(server string) bool { return strings.Contains(server, "server_name load-balance.com") }) - re, _ := regexp.Compile(`http-svc.*`) + re, _ := regexp.Compile(fmt.Sprintf(`%v.*`, framework.EchoService)) replicaRequestCount := map[string]int{} for i := 0; i < 600; i++ { diff --git a/test/e2e/lua/dynamic_certificates.go b/test/e2e/lua/dynamic_certificates.go index d484a2220..d79ee1e31 100644 --- a/test/e2e/lua/dynamic_certificates.go +++ b/test/e2e/lua/dynamic_certificates.go @@ -42,7 +42,7 @@ var _ = framework.IngressNginxDescribe("Dynamic Certificate", func() { }) It("picks up the certificate when we add TLS spec to existing ingress", func() { - ensureIngress(f, host, "http-svc") + ensureIngress(f, host, framework.EchoService) ing, err := f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.Namespace).Get(host, metav1.GetOptions{}) Expect(err).ToNot(HaveOccurred()) @@ -65,7 +65,7 @@ var _ = framework.IngressNginxDescribe("Dynamic Certificate", func() { }) It("picks up the previously missing secret for a given ingress without reloading", func() { - ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "http-svc", 80, nil) + ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, framework.EchoService, 80, nil) f.EnsureIngress(ing) time.Sleep(waitForLuaSync) @@ -109,7 +109,7 @@ var _ = framework.IngressNginxDescribe("Dynamic Certificate", func() { Context("given an ingress with TLS correctly configured", func() { BeforeEach(func() { - ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "http-svc", 80, nil)) + ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, framework.EchoService, 80, nil)) time.Sleep(waitForLuaSync) diff --git a/test/e2e/lua/dynamic_configuration.go b/test/e2e/lua/dynamic_configuration.go index 9ce46aa88..811ac036e 100644 --- a/test/e2e/lua/dynamic_configuration.go +++ b/test/e2e/lua/dynamic_configuration.go @@ -48,7 +48,7 @@ var _ = framework.IngressNginxDescribe("Dynamic Configuration", func() { BeforeEach(func() { f.NewEchoDeploymentWithReplicas(1) - ensureIngress(f, "foo.com", "http-svc") + ensureIngress(f, "foo.com", framework.EchoService) }) It("configures balancer Lua middleware correctly", func() { @@ -71,7 +71,7 @@ var _ = framework.IngressNginxDescribe("Dynamic Configuration", func() { }) replicas := 2 - err := framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "http-svc", replicas, nil) + err := framework.UpdateDeployment(f.KubeClientSet, f.Namespace, framework.EchoService, replicas, nil) Expect(err).NotTo(HaveOccurred()) time.Sleep(waitForLuaSync) @@ -93,7 +93,7 @@ var _ = framework.IngressNginxDescribe("Dynamic Configuration", func() { }) replicas := 2 - err := framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "http-svc", replicas, nil) + err := framework.UpdateDeployment(f.KubeClientSet, f.Namespace, framework.EchoService, replicas, nil) Expect(err).NotTo(HaveOccurred()) time.Sleep(waitForLuaSync * 2) @@ -106,7 +106,7 @@ var _ = framework.IngressNginxDescribe("Dynamic Configuration", func() { }) Expect(nginxConfig).Should(Equal(newNginxConfig)) - err = framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "http-svc", 0, nil) + err = framework.UpdateDeployment(f.KubeClientSet, f.Namespace, framework.EchoService, 0, nil) Expect(err).NotTo(HaveOccurred()) time.Sleep(waitForLuaSync * 2) diff --git a/test/e2e/run.sh b/test/e2e/run.sh index f7f999674..30641bb04 100755 --- a/test/e2e/run.sh +++ b/test/e2e/run.sh @@ -57,6 +57,8 @@ make -C ${DIR}/../../ build container make -C ${DIR}/../../ e2e-test-image make -C ${DIR}/../../images/fastcgi-helloserver/ build container +make -C ${DIR}/../../images/httpbin/ container + # Remove after https://github.com/kubernetes/ingress-nginx/pull/4271 is merged docker tag ${REGISTRY}/nginx-ingress-controller-${ARCH}:${TAG} ${REGISTRY}/nginx-ingress-controller:${TAG} @@ -65,6 +67,12 @@ kind load docker-image --name="${KIND_CLUSTER_NAME}" nginx-ingress-controller:e2 kind load docker-image --name="${KIND_CLUSTER_NAME}" ${REGISTRY}/nginx-ingress-controller:${TAG} kind load docker-image --name="${KIND_CLUSTER_NAME}" ${REGISTRY}/fastcgi-helloserver:${TAG} +# Preload images used in e2e tests +docker pull openresty/openresty:1.15.8.2-alpine + +kind load docker-image --name="${KIND_CLUSTER_NAME}" openresty/openresty:1.15.8.2-alpine +kind load docker-image --name="${KIND_CLUSTER_NAME}" ${REGISTRY}/httpbin:${TAG} + echo "[dev-env] running e2e tests..." make -C ${DIR}/../../ e2e-test diff --git a/test/e2e/servicebackend/service_externalname.go b/test/e2e/servicebackend/service_externalname.go index 61e1abeec..c8aff2e39 100644 --- a/test/e2e/servicebackend/service_externalname.go +++ b/test/e2e/servicebackend/service_externalname.go @@ -48,18 +48,18 @@ var _ = framework.IngressNginxDescribe("Service Type ExternalName", func() { svc := &core.Service{ ObjectMeta: metav1.ObjectMeta{ - Name: "httpbin", + Name: framework.HTTPBinService, Namespace: f.Namespace, }, Spec: corev1.ServiceSpec{ - ExternalName: "http-svc", + ExternalName: framework.EchoService, Type: corev1.ServiceTypeExternalName, }, } f.EnsureService(svc) - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "httpbin", 80, nil) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.HTTPBinService, 80, nil) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -80,7 +80,7 @@ var _ = framework.IngressNginxDescribe("Service Type ExternalName", func() { svc := &core.Service{ ObjectMeta: metav1.ObjectMeta{ - Name: "httpbin", + Name: framework.HTTPBinService, Namespace: f.Namespace, }, Spec: corev1.ServiceSpec{ @@ -91,7 +91,7 @@ var _ = framework.IngressNginxDescribe("Service Type ExternalName", func() { f.EnsureService(svc) - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "httpbin", 80, nil) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.HTTPBinService, 80, nil) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -112,7 +112,7 @@ var _ = framework.IngressNginxDescribe("Service Type ExternalName", func() { svc := &core.Service{ ObjectMeta: metav1.ObjectMeta{ - Name: "httpbin", + Name: framework.HTTPBinService, Namespace: f.Namespace, }, Spec: corev1.ServiceSpec{ @@ -130,7 +130,7 @@ var _ = framework.IngressNginxDescribe("Service Type ExternalName", func() { } f.EnsureService(svc) - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "httpbin", 80, nil) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.HTTPBinService, 80, nil) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -151,7 +151,7 @@ var _ = framework.IngressNginxDescribe("Service Type ExternalName", func() { svc := &core.Service{ ObjectMeta: metav1.ObjectMeta{ - Name: "httpbin", + Name: framework.HTTPBinService, Namespace: f.Namespace, }, Spec: corev1.ServiceSpec{ @@ -162,7 +162,7 @@ var _ = framework.IngressNginxDescribe("Service Type ExternalName", func() { f.EnsureService(svc) - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "httpbin", 80, nil) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.HTTPBinService, 80, nil) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -183,7 +183,7 @@ var _ = framework.IngressNginxDescribe("Service Type ExternalName", func() { svc := &core.Service{ ObjectMeta: metav1.ObjectMeta{ - Name: "httpbin", + Name: framework.HTTPBinService, Namespace: f.Namespace, }, Spec: corev1.ServiceSpec{ @@ -201,7 +201,7 @@ var _ = framework.IngressNginxDescribe("Service Type ExternalName", func() { } f.EnsureService(svc) - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "httpbin", 80, nil) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.HTTPBinService, 80, nil) ing.Spec.Rules[0].HTTP.Paths[0].Backend.ServicePort = intstr.FromString(host) f.EnsureIngress(ing) diff --git a/test/e2e/settings/configmap_change.go b/test/e2e/settings/configmap_change.go index 640e21a49..927b702eb 100644 --- a/test/e2e/settings/configmap_change.go +++ b/test/e2e/settings/configmap_change.go @@ -39,7 +39,7 @@ var _ = framework.IngressNginxDescribe("Configmap change", func() { It("should reload after an update in the configuration", func() { host := "configmap-change" - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil) f.EnsureIngress(ing) wlKey := "whitelist-source-range" diff --git a/test/e2e/settings/default_ssl_certificate.go b/test/e2e/settings/default_ssl_certificate.go index 0ea399f98..78e0a0fff 100644 --- a/test/e2e/settings/default_ssl_certificate.go +++ b/test/e2e/settings/default_ssl_certificate.go @@ -33,7 +33,7 @@ var _ = framework.IngressNginxDescribe("default-ssl-certificate", func() { f := framework.NewDefaultFramework("default-ssl-certificate") var tlsConfig *tls.Config secretName := "my-custom-cert" - service := "http-svc" + service := framework.EchoService port := 80 BeforeEach(func() { diff --git a/test/e2e/settings/disable_catch_all.go b/test/e2e/settings/disable_catch_all.go index a24623142..f5a56f089 100644 --- a/test/e2e/settings/disable_catch_all.go +++ b/test/e2e/settings/disable_catch_all.go @@ -54,10 +54,10 @@ var _ = framework.IngressNginxDescribe("Disabled catch-all", func() { It("should ignore catch all Ingress", func() { host := "foo" - ing := framework.NewSingleCatchAllIngress("catch-all", f.Namespace, "http-svc", 80, nil) + ing := framework.NewSingleCatchAllIngress("catch-all", f.Namespace, framework.EchoService, 80, nil) f.EnsureIngress(ing) - ing = framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil) + ing = framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil) f.EnsureIngress(ing) f.WaitForNginxServer(host, func(cfg string) bool { @@ -73,7 +73,7 @@ var _ = framework.IngressNginxDescribe("Disabled catch-all", func() { It("should delete Ingress updated to catch-all", func() { host := "foo" - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -91,7 +91,7 @@ var _ = framework.IngressNginxDescribe("Disabled catch-all", func() { err := framework.UpdateIngress(f.KubeClientSet, f.Namespace, host, func(ingress *extensions.Ingress) error { ingress.Spec.Rules = nil ingress.Spec.Backend = &extensions.IngressBackend{ - ServiceName: "http-svc", + ServiceName: framework.EchoService, ServicePort: intstr.FromInt(80), } return nil @@ -113,7 +113,7 @@ var _ = framework.IngressNginxDescribe("Disabled catch-all", func() { It("should allow Ingress with both a default backend and rules", func() { host := "foo" - ing := framework.NewSingleIngressWithBackendAndRules("not-catch-all", "/rulepath", host, f.Namespace, "http-svc", 80, "http-svc", 80, nil) + ing := framework.NewSingleIngressWithBackendAndRules("not-catch-all", "/rulepath", host, f.Namespace, framework.EchoService, 80, framework.EchoService, 80, nil) f.EnsureIngress(ing) f.WaitForNginxServer(host, func(cfg string) bool { diff --git a/test/e2e/settings/forwarded_headers.go b/test/e2e/settings/forwarded_headers.go index 3a4832c6c..49aa910e7 100644 --- a/test/e2e/settings/forwarded_headers.go +++ b/test/e2e/settings/forwarded_headers.go @@ -46,7 +46,7 @@ var _ = framework.IngressNginxDescribe("X-Forwarded headers", func() { f.UpdateNginxConfigMapData(setting, "true") - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -93,7 +93,7 @@ var _ = framework.IngressNginxDescribe("X-Forwarded headers", func() { f.UpdateNginxConfigMapData(setting, "false") - f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil)) + f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil)) f.WaitForNginxServer(host, func(server string) bool { diff --git a/test/e2e/settings/geoip2.go b/test/e2e/settings/geoip2.go index 6c464c78d..cf9ad075c 100644 --- a/test/e2e/settings/geoip2.go +++ b/test/e2e/settings/geoip2.go @@ -61,7 +61,7 @@ var _ = framework.IngressNginxDescribe("Geoip2", func() { "nginx.ingress.kubernetes.io/configuration-snippet": configSnippet, } - f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations)) + f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations)) f.WaitForNginxConfiguration( func(cfg string) bool { diff --git a/test/e2e/settings/global_access_block.go b/test/e2e/settings/global_access_block.go index 3e1abb94f..6a7cd739e 100644 --- a/test/e2e/settings/global_access_block.go +++ b/test/e2e/settings/global_access_block.go @@ -34,7 +34,7 @@ var _ = framework.IngressNginxDescribe("Global access block", func() { BeforeEach(func() { f.NewEchoDeploymentWithReplicas(1) - f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil)) + f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil)) }) AfterEach(func() { diff --git a/test/e2e/settings/global_external_auth.go b/test/e2e/settings/global_external_auth.go index 938537191..1f8d49f2a 100755 --- a/test/e2e/settings/global_external_auth.go +++ b/test/e2e/settings/global_external_auth.go @@ -33,7 +33,7 @@ var _ = framework.IngressNginxDescribe("Global External Auth", func() { host := "global-external-auth" - echoServiceName := "http-svc" + echoServiceName := framework.EchoService globalExternalAuthURLSetting := "global-auth-url" @@ -56,7 +56,7 @@ var _ = framework.IngressNginxDescribe("Global External Auth", func() { Context("when global external authentication is configured", func() { BeforeEach(func() { - globalExternalAuthURL := fmt.Sprintf("http://httpbin.%s.svc.cluster.local:80/status/401", f.Namespace) + globalExternalAuthURL := fmt.Sprintf("http://%s.%s.svc.cluster.local:80/status/401", framework.HTTPBinService, f.Namespace) By("Adding an ingress rule for /foo") fooIng := framework.NewSingleIngress("foo-ingress", fooPath, host, f.Namespace, echoServiceName, 80, nil) @@ -153,7 +153,7 @@ var _ = framework.IngressNginxDescribe("Global External Auth", func() { globalExternalAuthCacheKey := "foo" globalExternalAuthCacheDurationSetting := "global-auth-cache-duration" globalExternalAuthCacheDuration := "200 201 401 30m" - globalExternalAuthURL := fmt.Sprintf("http://httpbin.%s.svc.cluster.local:80/status/200", f.Namespace) + globalExternalAuthURL := fmt.Sprintf("http://%s.%s.svc.cluster.local:80/status/200", framework.HTTPBinService, f.Namespace) By("Adding a global-auth-cache-key to configMap") f.UpdateNginxConfigMapData(globalExternalAuthCacheKeySetting, globalExternalAuthCacheKey) @@ -178,7 +178,7 @@ var _ = framework.IngressNginxDescribe("Global External Auth", func() { } Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - err := f.DeleteDeployment("httpbin") + err := f.DeleteDeployment(framework.HTTPBinService) Expect(err).NotTo(HaveOccurred()) _, _, errs = gorequest.New(). diff --git a/test/e2e/settings/ingress_class.go b/test/e2e/settings/ingress_class.go index eed41cff9..be95b2657 100644 --- a/test/e2e/settings/ingress_class.go +++ b/test/e2e/settings/ingress_class.go @@ -45,11 +45,11 @@ var _ = framework.IngressNginxDescribe("Ingress class", func() { annotations := map[string]string{ "kubernetes.io/ingress.class": "testclass", } - ing := framework.NewSingleIngress(invalidHost, "/", invalidHost, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(invalidHost, "/", invalidHost, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) validHost := "bar" - ing = framework.NewSingleIngress(validHost, "/", validHost, f.Namespace, "http-svc", 80, nil) + ing = framework.NewSingleIngress(validHost, "/", validHost, f.Namespace, framework.EchoService, 80, nil) f.EnsureIngress(ing) f.WaitForNginxConfiguration(func(cfg string) bool { @@ -89,14 +89,14 @@ var _ = framework.IngressNginxDescribe("Ingress class", func() { It("should ignore Ingress with no class", func() { invalidHost := "bar" - ing := framework.NewSingleIngress(invalidHost, "/", invalidHost, f.Namespace, "http-svc", 80, nil) + ing := framework.NewSingleIngress(invalidHost, "/", invalidHost, f.Namespace, framework.EchoService, 80, nil) f.EnsureIngress(ing) validHost := "foo" annotations := map[string]string{ "kubernetes.io/ingress.class": "testclass", } - ing = framework.NewSingleIngress(validHost, "/", validHost, f.Namespace, "http-svc", 80, &annotations) + ing = framework.NewSingleIngress(validHost, "/", validHost, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(validHost, func(cfg string) bool { @@ -127,7 +127,7 @@ var _ = framework.IngressNginxDescribe("Ingress class", func() { annotations := map[string]string{ "kubernetes.io/ingress.class": "testclass", } - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations) ing = f.EnsureIngress(ing) f.WaitForNginxServer(host, func(cfg string) bool { diff --git a/test/e2e/settings/listen_nondefault_ports.go b/test/e2e/settings/listen_nondefault_ports.go index 980f8a04f..8acb6c71b 100644 --- a/test/e2e/settings/listen_nondefault_ports.go +++ b/test/e2e/settings/listen_nondefault_ports.go @@ -48,7 +48,7 @@ var _ = framework.IngressNginxDescribe("Listen on nondefault ports", func() { Context("with a plain HTTP ingress", func() { It("should set X-Forwarded-Port headers accordingly when listening on a non-default HTTP port", func() { - ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -71,7 +71,7 @@ var _ = framework.IngressNginxDescribe("Listen on nondefault ports", func() { It("should set X-Forwarded-Port header to 443", func() { - ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "http-svc", 80, nil) + ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, framework.EchoService, 80, nil) f.EnsureIngress(ing) tlsConfig, err := framework.CreateIngressTLSSecret(f.KubeClientSet, @@ -105,10 +105,10 @@ var _ = framework.IngressNginxDescribe("Listen on nondefault ports", func() { var httpbinIP string - err := framework.WaitForEndpoints(f.KubeClientSet, framework.DefaultTimeout, "httpbin", f.Namespace, 1) + err := framework.WaitForEndpoints(f.KubeClientSet, framework.DefaultTimeout, framework.HTTPBinService, f.Namespace, 1) Expect(err).NotTo(HaveOccurred()) - e, err := f.KubeClientSet.CoreV1().Endpoints(f.Namespace).Get("httpbin", metav1.GetOptions{}) + e, err := f.KubeClientSet.CoreV1().Endpoints(f.Namespace).Get(framework.HTTPBinService, metav1.GetOptions{}) Expect(err).NotTo(HaveOccurred()) httpbinIP = e.Subsets[0].Addresses[0].IP @@ -118,7 +118,7 @@ var _ = framework.IngressNginxDescribe("Listen on nondefault ports", func() { "nginx.ingress.kubernetes.io/auth-signin": "http://$host/auth/start", } - ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, framework.EchoService, 80, &annotations) f.EnsureIngress(ing) tlsConfig, err := framework.CreateIngressTLSSecret(f.KubeClientSet, diff --git a/test/e2e/settings/lua_shared_dicts.go b/test/e2e/settings/lua_shared_dicts.go index f00891463..d76ca87ad 100644 --- a/test/e2e/settings/lua_shared_dicts.go +++ b/test/e2e/settings/lua_shared_dicts.go @@ -35,7 +35,7 @@ var _ = framework.IngressNginxDescribe("LuaSharedDict", func() { }) It("configures lua shared dicts", func() { - ingress := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil) + ingress := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil) f.EnsureIngress(ingress) f.UpdateNginxConfigMapData("lua-shared-dicts", "configuration_data:60,certificate_data:300, my_dict: 15 , invalid: 1a") diff --git a/test/e2e/settings/no_auth_locations.go b/test/e2e/settings/no_auth_locations.go index 0612dd583..a9ea8b90d 100644 --- a/test/e2e/settings/no_auth_locations.go +++ b/test/e2e/settings/no_auth_locations.go @@ -124,14 +124,14 @@ func buildBasicAuthIngressWithSecondPath(host, namespace, secretName, pathName s { Path: "/", Backend: extensions.IngressBackend{ - ServiceName: "http-svc", + ServiceName: framework.EchoService, ServicePort: intstr.FromInt(80), }, }, { Path: pathName, Backend: extensions.IngressBackend{ - ServiceName: "http-svc", + ServiceName: framework.EchoService, ServicePort: intstr.FromInt(80), }, }, diff --git a/test/e2e/settings/proxy_host.go b/test/e2e/settings/proxy_host.go index d9789e7fd..7598feaf5 100644 --- a/test/e2e/settings/proxy_host.go +++ b/test/e2e/settings/proxy_host.go @@ -38,11 +38,11 @@ var _ = framework.IngressNginxDescribe("Proxy host variable", func() { }) It("should exist a proxy_host", func() { - upstreamName := fmt.Sprintf("%v-http-svc-80", f.Namespace) + upstreamName := fmt.Sprintf("%v-%v-80", f.Namespace, framework.EchoService) annotations := map[string]string{ "nginx.ingress.kubernetes.io/configuration-snippet": `more_set_headers "Custom-Header: $proxy_host"`, } - f.EnsureIngress(framework.NewSingleIngress(test, "/", test, f.Namespace, "http-svc", 80, &annotations)) + f.EnsureIngress(framework.NewSingleIngress(test, "/", test, f.Namespace, framework.EchoService, 80, &annotations)) f.WaitForNginxConfiguration( func(server string) bool { @@ -62,13 +62,13 @@ var _ = framework.IngressNginxDescribe("Proxy host variable", func() { }) It("should exist a proxy_host using the upstream-vhost annotation value", func() { - upstreamName := fmt.Sprintf("%v-http-svc-80", f.Namespace) + upstreamName := fmt.Sprintf("%v-%v-80", f.Namespace, framework.EchoService) upstreamVHost := "different.host" annotations := map[string]string{ "nginx.ingress.kubernetes.io/upstream-vhost": upstreamVHost, "nginx.ingress.kubernetes.io/configuration-snippet": `more_set_headers "Custom-Header: $proxy_host"`, } - f.EnsureIngress(framework.NewSingleIngress(test, "/", test, f.Namespace, "http-svc", 80, &annotations)) + f.EnsureIngress(framework.NewSingleIngress(test, "/", test, f.Namespace, framework.EchoService, 80, &annotations)) f.WaitForNginxConfiguration( func(server string) bool { diff --git a/test/e2e/settings/proxy_protocol.go b/test/e2e/settings/proxy_protocol.go index 95fdde595..82e072290 100644 --- a/test/e2e/settings/proxy_protocol.go +++ b/test/e2e/settings/proxy_protocol.go @@ -46,7 +46,7 @@ var _ = framework.IngressNginxDescribe("Proxy Protocol", func() { f.UpdateNginxConfigMapData(setting, "true") - f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil)) + f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil)) f.WaitForNginxServer(host, func(server string) bool { diff --git a/test/e2e/settings/server_tokens.go b/test/e2e/settings/server_tokens.go index 403506bf3..ca659ce97 100644 --- a/test/e2e/settings/server_tokens.go +++ b/test/e2e/settings/server_tokens.go @@ -41,7 +41,7 @@ var _ = framework.IngressNginxDescribe("Server Tokens", func() { It("should not exists Server header in the response", func() { f.UpdateNginxConfigMapData(serverTokens, "false") - f.EnsureIngress(framework.NewSingleIngress(serverTokens, "/", serverTokens, f.Namespace, "http-svc", 80, nil)) + f.EnsureIngress(framework.NewSingleIngress(serverTokens, "/", serverTokens, f.Namespace, framework.EchoService, 80, nil)) f.WaitForNginxConfiguration( func(cfg string) bool { @@ -69,7 +69,7 @@ var _ = framework.IngressNginxDescribe("Server Tokens", func() { { Path: "/", Backend: extensions.IngressBackend{ - ServiceName: "http-svc", + ServiceName: framework.EchoService, ServicePort: intstr.FromInt(80), }, }, diff --git a/test/e2e/settings/tls.go b/test/e2e/settings/tls.go index bcedd7c54..c74449553 100644 --- a/test/e2e/settings/tls.go +++ b/test/e2e/settings/tls.go @@ -54,7 +54,7 @@ var _ = framework.IngressNginxDescribe("Settings - TLS)", func() { // https://www.openssl.org/docs/man1.1.0/apps/ciphers.html - "CIPHER SUITE NAMES" testCiphers := "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA" - ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "http-svc", 80, nil)) + ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, framework.EchoService, 80, nil)) tlsConfig, err := framework.CreateIngressTLSSecret(f.KubeClientSet, ing.Spec.TLS[0].Hosts, ing.Spec.TLS[0].SecretName, @@ -107,7 +107,7 @@ var _ = framework.IngressNginxDescribe("Settings - TLS)", func() { hstsIncludeSubdomains := "hsts-include-subdomains" hstsPreload := "hsts-preload" - ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "http-svc", 80, nil)) + ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, framework.EchoService, 80, nil)) tlsConfig, err := framework.CreateIngressTLSSecret(f.KubeClientSet, ing.Spec.TLS[0].Hosts, ing.Spec.TLS[0].SecretName, @@ -172,7 +172,7 @@ var _ = framework.IngressNginxDescribe("Settings - TLS)", func() { }) It("should not use ports during the HTTP to HTTPS redirection", func() { - ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "http-svc", 80, nil)) + ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, framework.EchoService, 80, nil)) tlsConfig, err := framework.CreateIngressTLSSecret(f.KubeClientSet, ing.Spec.TLS[0].Hosts, ing.Spec.TLS[0].SecretName, @@ -196,7 +196,7 @@ var _ = framework.IngressNginxDescribe("Settings - TLS)", func() { It("should not use ports or X-Forwarded-Host during the HTTP to HTTPS redirection", func() { f.UpdateNginxConfigMapData("use-forwarded-headers", "true") - ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "http-svc", 80, nil)) + ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, framework.EchoService, 80, nil)) tlsConfig, err := framework.CreateIngressTLSSecret(f.KubeClientSet, ing.Spec.TLS[0].Hosts, ing.Spec.TLS[0].SecretName, diff --git a/test/e2e/ssl/secret_update.go b/test/e2e/ssl/secret_update.go index 628d45869..2184da7bf 100644 --- a/test/e2e/ssl/secret_update.go +++ b/test/e2e/ssl/secret_update.go @@ -55,7 +55,7 @@ var _ = framework.IngressNginxDescribe("SSL", func() { }, }) - ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "http-svc", 80, nil)) + ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, framework.EchoService, 80, nil)) _, err := framework.CreateIngressTLSSecret(f.KubeClientSet, ing.Spec.TLS[0].Hosts, ing.Spec.TLS[0].SecretName, @@ -92,7 +92,7 @@ var _ = framework.IngressNginxDescribe("SSL", func() { }, }) - f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "http-svc", 80, nil)) + f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, framework.EchoService, 80, nil)) f.WaitForNginxServer(host, func(server string) bool { diff --git a/test/e2e/status/update.go b/test/e2e/status/update.go index 5814527f8..ea77b9097 100644 --- a/test/e2e/status/update.go +++ b/test/e2e/status/update.go @@ -74,7 +74,7 @@ var _ = framework.IngressNginxDescribe("Status Update [Status]", func() { f.NewEchoDeploymentWithReplicas(1) - ing := f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil)) + ing := f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil)) f.WaitForNginxConfiguration( func(cfg string) bool { diff --git a/test/e2e/tcpudp/tcp.go b/test/e2e/tcpudp/tcp.go index 8a9fa36b8..e9910f4b2 100644 --- a/test/e2e/tcpudp/tcp.go +++ b/test/e2e/tcpudp/tcp.go @@ -62,7 +62,7 @@ var _ = framework.IngressNginxDescribe("TCP Feature", func() { config.Data = map[string]string{} } - config.Data["8080"] = fmt.Sprintf("%v/http-svc:80", f.Namespace) + config.Data["8080"] = fmt.Sprintf("%v/%v:80", f.Namespace, framework.EchoService) _, err = f.KubeClientSet. CoreV1(). @@ -78,7 +78,7 @@ var _ = framework.IngressNginxDescribe("TCP Feature", func() { Expect(svc).NotTo(BeNil(), "expected a service but none returned") svc.Spec.Ports = append(svc.Spec.Ports, corev1.ServicePort{ - Name: "http-svc", + Name: framework.EchoService, Port: 8080, TargetPort: intstr.FromInt(8080), }) @@ -90,7 +90,7 @@ var _ = framework.IngressNginxDescribe("TCP Feature", func() { f.WaitForNginxConfiguration( func(cfg string) bool { - return strings.Contains(cfg, fmt.Sprintf(`ngx.var.proxy_upstream_name="tcp-%v-http-svc-80"`, f.Namespace)) + return strings.Contains(cfg, fmt.Sprintf(`ngx.var.proxy_upstream_name="tcp-%v-%v-80"`, f.Namespace, framework.EchoService)) }) ip := f.GetNginxIP()