diff --git a/.gitignore b/.gitignore index a9bc27f7b..eda5d2aea 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,5 @@ cover.out # secret terraform variables build/images/nginx/aws.tfvars build/images/nginx/env.tfvars + +images/fastcgi-helloserver/rootfs/fastcgi-helloserver diff --git a/Makefile b/Makefile index 7c65b4251..1519b7fdf 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ endif # Allow limiting the scope of the e2e tests. By default run everything FOCUS ?= .* # number of parallel test -E2E_NODES ?= 12 +E2E_NODES ?= 15 # slow test only if takes > 50s SLOW_E2E_THRESHOLD ?= 50 # run e2e test suite with tests that check for memory leaks? (default is false) @@ -258,7 +258,7 @@ misspell: check-go-version ## Check for spelling errors. .PHONY: kind-e2e-test kind-e2e-test: check-go-version ## Run e2e tests using kind. - @DIND_TASKS=0 test/e2e/run.sh + @test/e2e/run.sh .PHONY: run-ingress-controller run-ingress-controller: ## Run the ingress controller locally using a kubectl proxy connection. @@ -272,7 +272,7 @@ check-go-version: init-docker-buildx: ifeq ($(DIND_TASKS),) ifneq ($(shell docker buildx 2>&1 >/dev/null; echo $?),) - $(error "buildx not vailable. Docker 19.03 or higher is required") + $(error "buildx not available. Docker 19.03 or higher is required with experimental features enabled") endif docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d docker buildx create --name ingress-nginx --use || true diff --git a/build/images/ingress-controller/build-ingress-controller.sh b/build/images/ingress-controller/build-ingress-controller.sh index d49f9706c..31928c299 100644 --- a/build/images/ingress-controller/build-ingress-controller.sh +++ b/build/images/ingress-controller/build-ingress-controller.sh @@ -67,7 +67,7 @@ echo ${docker_password} | docker login -u ${docker_username} --password-stdin qu curl -sL -o /usr/local/bin/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gimme chmod +x /usr/local/bin/gimme -eval "$(gimme 1.13.7)" +eval "$(gimme 1.13.8)" export GOPATH="/tmp/go" diff --git a/build/images/nginx/build-nginx.sh b/build/images/nginx/build-nginx.sh index 15205aab0..56f9e5323 100644 --- a/build/images/nginx/build-nginx.sh +++ b/build/images/nginx/build-nginx.sh @@ -70,7 +70,7 @@ echo ${docker_password} | docker login -u ${docker_username} --password-stdin qu curl -sL -o /usr/local/bin/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gimme chmod +x /usr/local/bin/gimme -eval "$(gimme 1.13.7)" +eval "$(gimme 1.13.8)" git clone https://github.com/kubernetes/ingress-nginx diff --git a/build/run-in-docker.sh b/build/run-in-docker.sh index b4e1b01c0..610657a7a 100755 --- a/build/run-in-docker.sh +++ b/build/run-in-docker.sh @@ -34,7 +34,7 @@ function cleanup { } trap cleanup EXIT -E2E_IMAGE=quay.io/kubernetes-ingress-controller/e2e:v02042020-08e19a278 +E2E_IMAGE=quay.io/kubernetes-ingress-controller/e2e:v02132020-0e2ca1cc0 DOCKER_OPTS=${DOCKER_OPTS:-} diff --git a/deploy/kind/deployment.yaml b/deploy/kind/deployment.yaml new file mode 100644 index 000000000..687e834d8 --- /dev/null +++ b/deploy/kind/deployment.yaml @@ -0,0 +1,28 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-ingress-controller +spec: + template: + spec: + containers: + - name: nginx-ingress-controller + livenessProbe: + failureThreshold: 3 + httpGet: + path: /healthz + port: 10254 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 5 + successThreshold: 1 + timeoutSeconds: 10 + readinessProbe: + failureThreshold: 3 + httpGet: + path: /healthz + port: 10254 + scheme: HTTP + periodSeconds: 5 + successThreshold: 1 + timeoutSeconds: 5 \ No newline at end of file diff --git a/deploy/kind/kustomization.yaml b/deploy/kind/kustomization.yaml index 8230fce40..a622d7940 100644 --- a/deploy/kind/kustomization.yaml +++ b/deploy/kind/kustomization.yaml @@ -9,3 +9,4 @@ images: newTag: dev patchesStrategicMerge: - service-hostport.yaml +- deployment.yaml diff --git a/docs/development.md b/docs/development.md index 34ed3f777..367123f77 100644 --- a/docs/development.md +++ b/docs/development.md @@ -19,6 +19,8 @@ cd ingress-nginx ### Initial developer environment build +Ensure docker experimental features option is enabled for [buildx](https://docs.docker.com/buildx/working-with-buildx/) + ``` $ make dev-env ``` diff --git a/images/e2e/Makefile b/images/e2e/Makefile index e10246e9b..7d432b13e 100644 --- a/images/e2e/Makefile +++ b/images/e2e/Makefile @@ -26,8 +26,8 @@ docker-build: --progress plain \ --build-arg K8S_RELEASE=v1.15.7 \ --build-arg ETCD_VERSION=v3.3.18 \ - --build-arg GOLANG_VERSION=1.13.7 \ - --build-arg GOLANG_SHA=e4ad42cc5f5c19521fbbbde3680995f2546110b5c6aa2b48c3754ff7af9b41f4 \ + --build-arg GOLANG_VERSION=1.13.8 \ + --build-arg GOLANG_SHA=b13bf04633d4d8cf53226ebeaace8d4d2fd07ae6fa676d0844a688339debec34 \ --build-arg RESTY_CLI_VERSION=0.25rc2 \ --build-arg RESTY_CLI_SHA=a38d850441384fa037a5922ca012dcce8708d0e4abe34ad2fe4164a01b28bdfb \ -t $(IMAGE):$(TAG) . diff --git a/images/fastcgi-helloserver/rootfs/fastcgi-helloserver b/images/fastcgi-helloserver/rootfs/fastcgi-helloserver deleted file mode 100755 index 563b84b3c..000000000 Binary files a/images/fastcgi-helloserver/rootfs/fastcgi-helloserver and /dev/null differ diff --git a/rootfs/etc/nginx/template/nginx.tmpl b/rootfs/etc/nginx/template/nginx.tmpl index ece6f658d..7132cae1b 100755 --- a/rootfs/etc/nginx/template/nginx.tmpl +++ b/rootfs/etc/nginx/template/nginx.tmpl @@ -952,6 +952,8 @@ stream { location {{ buildAuthSignURLLocation $location.Path $externalAuth.SigninURL }} { internal; + add_header Set-Cookie $auth_cookie; + return 302 {{ buildAuthSignURL $externalAuth.SigninURL }}; } {{ end }} diff --git a/test/e2e-image/Dockerfile b/test/e2e-image/Dockerfile index 93cf9498e..dbb374a01 100644 --- a/test/e2e-image/Dockerfile +++ b/test/e2e-image/Dockerfile @@ -1,4 +1,4 @@ -FROM quay.io/kubernetes-ingress-controller/e2e:v02042020-08e19a278 AS BASE +FROM quay.io/kubernetes-ingress-controller/e2e:v02132020-0e2ca1cc0 AS BASE FROM alpine:3.11 diff --git a/test/e2e-image/e2e.sh b/test/e2e-image/e2e.sh index 9a95b25f6..539eaa97f 100755 --- a/test/e2e-image/e2e.sh +++ b/test/e2e-image/e2e.sh @@ -39,6 +39,7 @@ ginkgo_args=( "-trace" "-slowSpecThreshold=${SLOW_E2E_THRESHOLD}" "-r" + "-timeout=45m" # Suite timeout should be lower than Prow job timeout to avoid abrupt termination ) echo -e "${BGREEN}Running e2e test suite (FOCUS=${FOCUS})...${NC}" diff --git a/test/e2e/annotations/affinity.go b/test/e2e/annotations/affinity.go index a80fba271..801ab5fec 100644 --- a/test/e2e/annotations/affinity.go +++ b/test/e2e/annotations/affinity.go @@ -40,9 +40,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", f.NewEchoDeploymentWithReplicas(2) }) - AfterEach(func() { - }) - It("should set sticky cookie SERVERID", func() { host := "sticky.foo.com" annotations := map[string]string{ diff --git a/test/e2e/annotations/alias.go b/test/e2e/annotations/alias.go index 188387fbe..30756a532 100644 --- a/test/e2e/annotations/alias.go +++ b/test/e2e/annotations/alias.go @@ -34,9 +34,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Alias", func() { f.NewEchoDeployment() }) - AfterEach(func() { - }) - It("should return status code 200 for host 'foo' and 404 for 'bar'", func() { host := "foo" annotations := map[string]string{} diff --git a/test/e2e/annotations/approot.go b/test/e2e/annotations/approot.go index 53bd181f1..9b0c65b2b 100644 --- a/test/e2e/annotations/approot.go +++ b/test/e2e/annotations/approot.go @@ -33,9 +33,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Approot", func() { f.NewEchoDeploymentWithReplicas(2) }) - AfterEach(func() { - }) - It("should redirect to /foo", func() { host := "approot.bar.com" diff --git a/test/e2e/annotations/auth.go b/test/e2e/annotations/auth.go index 66ab3d80b..6b6e897d4 100644 --- a/test/e2e/annotations/auth.go +++ b/test/e2e/annotations/auth.go @@ -332,6 +332,52 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { }) }) + It("retains cookie set by external authentication server", func() { + Skip("Skipping test until refactoring") + // TODO: this test should look like https://gist.github.com/aledbf/250645d76c080677c695929273f8fd22 + + host := "auth" + + f.NewHttpbinDeployment() + + var httpbinIP string + + 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(framework.HTTPBinService, metav1.GetOptions{}) + Expect(err).NotTo(HaveOccurred()) + + httpbinIP = e.Subsets[0].Addresses[0].IP + + annotations := map[string]string{ + "nginx.ingress.kubernetes.io/auth-url": fmt.Sprintf("http://%s/cookies/set/alma/armud", httpbinIP), + "nginx.ingress.kubernetes.io/auth-signin": "http://$host/auth/start", + } + + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations) + f.EnsureIngress(ing) + + f.WaitForNginxServer(host, func(server string) bool { + return Expect(server).Should(ContainSubstring("server_name auth")) + }) + + resp, _, errs := gorequest.New(). + Get(f.GetURL(framework.HTTP)). + Retry(10, 1*time.Second, http.StatusNotFound). + Set("Host", host). + Param("a", "b"). + Param("c", "d"). + End() + + for _, err := range errs { + Expect(err).NotTo(HaveOccurred()) + } + + framework.Logf("Cookie: %v", resp.Header) + Expect(resp.Header.Get("Set-Cookie")).Should(ContainSubstring("alma=armud")) + }) + Context("when external authentication is configured", func() { host := "auth" diff --git a/test/e2e/annotations/authtls.go b/test/e2e/annotations/authtls.go index 350e21a92..eb46397a7 100644 --- a/test/e2e/annotations/authtls.go +++ b/test/e2e/annotations/authtls.go @@ -35,9 +35,6 @@ var _ = framework.IngressNginxDescribe("Annotations - AuthTLS", func() { f.NewEchoDeploymentWithReplicas(2) }) - AfterEach(func() { - }) - It("should set valid auth-tls-secret", func() { host := "authtls.foo.com" nameSpace := f.Namespace diff --git a/test/e2e/annotations/backendprotocol.go b/test/e2e/annotations/backendprotocol.go index c7e13d958..75b1ec9ee 100644 --- a/test/e2e/annotations/backendprotocol.go +++ b/test/e2e/annotations/backendprotocol.go @@ -29,9 +29,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Backendprotocol", func() { f.NewEchoDeploymentWithReplicas(2) }) - AfterEach(func() { - }) - It("should set backend protocol to https:// and use proxy_pass", func() { host := "backendprotocol.foo.com" annotations := map[string]string{ diff --git a/test/e2e/annotations/clientbodybuffersize.go b/test/e2e/annotations/clientbodybuffersize.go index 58d368004..e718fa1aa 100644 --- a/test/e2e/annotations/clientbodybuffersize.go +++ b/test/e2e/annotations/clientbodybuffersize.go @@ -29,9 +29,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Client-Body-Buffer-Size", f.NewEchoDeploymentWithReplicas(2) }) - AfterEach(func() { - }) - It("should set client_body_buffer_size to 1000", func() { host := "proxy.foo.com" annotations := map[string]string{ diff --git a/test/e2e/annotations/connection.go b/test/e2e/annotations/connection.go index 906624ca9..36a16d78f 100644 --- a/test/e2e/annotations/connection.go +++ b/test/e2e/annotations/connection.go @@ -34,9 +34,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Connection", func() { f.NewEchoDeploymentWithReplicas(2) }) - AfterEach(func() { - }) - It("set connection header to keep-alive", func() { host := "connection.foo.com" annotations := map[string]string{ diff --git a/test/e2e/annotations/cors.go b/test/e2e/annotations/cors.go index d75b2f4f0..d5ca52e31 100644 --- a/test/e2e/annotations/cors.go +++ b/test/e2e/annotations/cors.go @@ -33,9 +33,6 @@ var _ = framework.IngressNginxDescribe("Annotations - CORS", func() { f.NewEchoDeploymentWithReplicas(2) }) - AfterEach(func() { - }) - It("should enable cors", func() { host := "cors.foo.com" annotations := map[string]string{ diff --git a/test/e2e/annotations/customhttperrors.go b/test/e2e/annotations/customhttperrors.go index b7c84b7c8..78714b029 100644 --- a/test/e2e/annotations/customhttperrors.go +++ b/test/e2e/annotations/customhttperrors.go @@ -38,9 +38,6 @@ var _ = framework.IngressNginxDescribe("Annotations - custom-http-errors", func( f.NewEchoDeploymentWithReplicas(1) }) - AfterEach(func() { - }) - It("configures Nginx correctly", func() { host := "customerrors.foo.com" diff --git a/test/e2e/annotations/forcesslredirect.go b/test/e2e/annotations/forcesslredirect.go index b4823d98c..38b584596 100644 --- a/test/e2e/annotations/forcesslredirect.go +++ b/test/e2e/annotations/forcesslredirect.go @@ -33,9 +33,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Forcesslredirect", func() f.NewEchoDeploymentWithReplicas(2) }) - AfterEach(func() { - }) - It("should redirect to https", func() { host := "forcesslredirect.bar.com" diff --git a/test/e2e/annotations/fromtowwwredirect.go b/test/e2e/annotations/fromtowwwredirect.go index 3ec45a5e5..3785cbdf6 100644 --- a/test/e2e/annotations/fromtowwwredirect.go +++ b/test/e2e/annotations/fromtowwwredirect.go @@ -36,9 +36,6 @@ var _ = framework.IngressNginxDescribe("Annotations - from-to-www-redirect", fun f.NewEchoDeploymentWithReplicas(1) }) - AfterEach(func() { - }) - It("should redirect from www HTTP to HTTP", func() { By("setting up server for redirect from www") host := "fromtowwwredirect.bar.com" diff --git a/test/e2e/annotations/grpc.go b/test/e2e/annotations/grpc.go index 225471d50..f1c767a3f 100644 --- a/test/e2e/annotations/grpc.go +++ b/test/e2e/annotations/grpc.go @@ -65,15 +65,17 @@ var _ = framework.IngressNginxDescribe("Annotations - GRPC", func() { }) It("should return OK for service with backend protocol GRPC", func() { + f.NewGRPCBinDeployment() + host := "echo" svc := &core.Service{ ObjectMeta: metav1.ObjectMeta{ - Name: "grpcbin", + Name: "grpcbin-test", Namespace: f.Namespace, }, Spec: corev1.ServiceSpec{ - ExternalName: "grpcb.in", + ExternalName: fmt.Sprintf("grpcbin.%v.svc.cluster.local", f.Namespace), Type: corev1.ServiceTypeExternalName, Ports: []corev1.ServicePort{ { @@ -91,7 +93,7 @@ var _ = framework.IngressNginxDescribe("Annotations - GRPC", func() { "nginx.ingress.kubernetes.io/backend-protocol": "GRPC", } - ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "grpcbin", 9000, annotations) + ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "grpcbin-test", 9000, annotations) f.EnsureIngress(ing) @@ -121,15 +123,19 @@ var _ = framework.IngressNginxDescribe("Annotations - GRPC", func() { }) It("should return OK for service with backend protocol GRPCS", func() { + Skip("GRPCS test temporarily disabled") + + f.NewGRPCBinDeployment() + host := "echo" svc := &core.Service{ ObjectMeta: metav1.ObjectMeta{ - Name: "grpcbin", + Name: "grpcbin-test", Namespace: f.Namespace, }, Spec: corev1.ServiceSpec{ - ExternalName: "grpcb.in", + ExternalName: fmt.Sprintf("grpcbin.%v.svc.cluster.local", f.Namespace), Type: corev1.ServiceTypeExternalName, Ports: []corev1.ServicePort{ { @@ -145,15 +151,15 @@ var _ = framework.IngressNginxDescribe("Annotations - GRPC", func() { annotations := map[string]string{ "nginx.ingress.kubernetes.io/backend-protocol": "GRPCS", - "nginx.ingress.kubernetes.io/configuration-snippet": ` + "nginx.ingress.kubernetes.io/configuration-snippet": fmt.Sprintf(` # without this setting NGINX sends echo instead - grpc_ssl_name grpcb.in; + grpc_ssl_name grpcbin.%v.svc.cluster.local; grpc_ssl_server_name on; grpc_ssl_ciphers HIGH:!aNULL:!MD5; - `, + `, f.Namespace), } - ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "grpcbin", 9001, annotations) + ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "grpcbin-test", 9001, annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/http2pushpreload.go b/test/e2e/annotations/http2pushpreload.go index 56c9c8151..2b132676f 100644 --- a/test/e2e/annotations/http2pushpreload.go +++ b/test/e2e/annotations/http2pushpreload.go @@ -29,9 +29,6 @@ var _ = framework.IngressNginxDescribe("Annotations - HTTP2 Push Preload", func( f.NewEchoDeploymentWithReplicas(2) }) - AfterEach(func() { - }) - It("enable the http2-push-preload directive", func() { host := "http2pp.foo.com" annotations := map[string]string{ diff --git a/test/e2e/annotations/influxdb.go b/test/e2e/annotations/influxdb.go index bfdecff5a..96a061165 100644 --- a/test/e2e/annotations/influxdb.go +++ b/test/e2e/annotations/influxdb.go @@ -74,7 +74,7 @@ var _ = framework.IngressNginxDescribe("Annotations - influxdb", func() { Expect(len(errs)).Should(Equal(0)) Expect(res.StatusCode).Should(Equal(http.StatusOK)) - time.Sleep(5 * time.Second) + time.Sleep(10 * time.Second) var measurements string var err error @@ -89,7 +89,7 @@ var _ = framework.IngressNginxDescribe("Annotations - influxdb", func() { Expect(err).NotTo(HaveOccurred()) var results map[string][]map[string]interface{} - jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(measurements), &results) + _ = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(measurements), &results) Expect(len(measurements)).ShouldNot(Equal(0)) for _, elem := range results["results"] { @@ -102,7 +102,7 @@ var _ = framework.IngressNginxDescribe("Annotations - influxdb", func() { func createInfluxDBService(f *framework.Framework) *corev1.Service { service := &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ - Name: "inflxudb-svc", + Name: "inflxudb", Namespace: f.Namespace, }, Spec: corev1.ServiceSpec{Ports: []corev1.ServicePort{ @@ -114,7 +114,7 @@ func createInfluxDBService(f *framework.Framework) *corev1.Service { }, }, Selector: map[string]string{ - "app": "influxdb-svc", + "app": "influxdb", }, }, } @@ -134,7 +134,7 @@ func createInfluxDBIngress(f *framework.Framework, host, service string, port in func extractInfluxDBMeasurements(f *framework.Framework) (string, error) { l, err := f.KubeClientSet.CoreV1().Pods(f.Namespace).List(metav1.ListOptions{ - LabelSelector: "app=influxdb-svc", + LabelSelector: "app=influxdb", }) if err != nil { return "", err diff --git a/test/e2e/annotations/ipwhitelist.go b/test/e2e/annotations/ipwhitelist.go index 385268046..47e3379e2 100644 --- a/test/e2e/annotations/ipwhitelist.go +++ b/test/e2e/annotations/ipwhitelist.go @@ -31,9 +31,6 @@ var _ = framework.IngressNginxDescribe("Annotations - IPWhiteList", func() { f.NewEchoDeploymentWithReplicas(2) }) - AfterEach(func() { - }) - It("should set valid ip whitelist range", func() { host := "ipwhitelist.foo.com" nameSpace := f.Namespace diff --git a/test/e2e/annotations/log.go b/test/e2e/annotations/log.go index d29c1eca4..6c6a83939 100644 --- a/test/e2e/annotations/log.go +++ b/test/e2e/annotations/log.go @@ -30,9 +30,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Log", func() { f.NewEchoDeploymentWithReplicas(2) }) - AfterEach(func() { - }) - It("set access_log off", func() { host := "log.foo.com" annotations := map[string]string{ diff --git a/test/e2e/annotations/mirror.go b/test/e2e/annotations/mirror.go index d2d809d6c..4ce64bcb0 100644 --- a/test/e2e/annotations/mirror.go +++ b/test/e2e/annotations/mirror.go @@ -33,9 +33,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Mirror", func() { f.NewEchoDeployment() }) - AfterEach(func() { - }) - It("should set mirror-target to http://localhost/mirror", func() { annotations := map[string]string{ "nginx.ingress.kubernetes.io/mirror-target": "http://localhost/mirror", diff --git a/test/e2e/annotations/modsecurity.go b/test/e2e/annotations/modsecurity.go index 8a767b967..4b3035008 100644 --- a/test/e2e/annotations/modsecurity.go +++ b/test/e2e/annotations/modsecurity.go @@ -30,9 +30,6 @@ var _ = framework.IngressNginxDescribe("Annotations - ModSecurityLocation", func f.NewEchoDeployment() }) - AfterEach(func() { - }) - It("should enable modsecurity", func() { host := "modsecurity.foo.com" nameSpace := f.Namespace diff --git a/test/e2e/annotations/proxy.go b/test/e2e/annotations/proxy.go index 602d2dc9f..f0eca994c 100644 --- a/test/e2e/annotations/proxy.go +++ b/test/e2e/annotations/proxy.go @@ -33,9 +33,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() { f.NewEchoDeploymentWithReplicas(2) }) - AfterEach(func() { - }) - It("should set proxy_redirect to off", func() { annotations := map[string]string{ "nginx.ingress.kubernetes.io/proxy-redirect-from": "off", diff --git a/test/e2e/annotations/proxyssl.go b/test/e2e/annotations/proxyssl.go index 3020c0c83..4b32a904c 100644 --- a/test/e2e/annotations/proxyssl.go +++ b/test/e2e/annotations/proxyssl.go @@ -32,9 +32,6 @@ var _ = framework.IngressNginxDescribe("Annotations - ProxySSL", func() { f.NewEchoDeploymentWithReplicas(2) }) - AfterEach(func() { - }) - It("should set valid proxy-ssl-secret", func() { host := "proxyssl.foo.com" annotations := map[string]string{ diff --git a/test/e2e/annotations/redirect.go b/test/e2e/annotations/redirect.go index 152e4b9bb..362acc483 100644 --- a/test/e2e/annotations/redirect.go +++ b/test/e2e/annotations/redirect.go @@ -37,12 +37,6 @@ func noRedirectPolicyFunc(gorequest.Request, []gorequest.Request) error { var _ = framework.IngressNginxDescribe("Annotations - Redirect", func() { f := framework.NewDefaultFramework("redirect") - BeforeEach(func() { - }) - - AfterEach(func() { - }) - It("should respond with a standard redirect code", func() { By("setting permanent-redirect annotation") diff --git a/test/e2e/annotations/rewrite.go b/test/e2e/annotations/rewrite.go index 8046a4010..0669b25b1 100644 --- a/test/e2e/annotations/rewrite.go +++ b/test/e2e/annotations/rewrite.go @@ -36,9 +36,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { f.NewEchoDeployment() }) - AfterEach(func() { - }) - It("should write rewrite logs", func() { By("setting enable-rewrite-log annotation") diff --git a/test/e2e/annotations/satisfy.go b/test/e2e/annotations/satisfy.go index 5d03e2034..cf9293d2b 100644 --- a/test/e2e/annotations/satisfy.go +++ b/test/e2e/annotations/satisfy.go @@ -37,9 +37,6 @@ var _ = framework.IngressNginxDescribe("Annotations - SATISFY", func() { f.NewEchoDeployment() }) - AfterEach(func() { - }) - It("should configure satisfy directive correctly", func() { host := "satisfy" annotationKey := "nginx.ingress.kubernetes.io/satisfy" diff --git a/test/e2e/annotations/serversnippet.go b/test/e2e/annotations/serversnippet.go index a87350dbb..594410003 100644 --- a/test/e2e/annotations/serversnippet.go +++ b/test/e2e/annotations/serversnippet.go @@ -31,9 +31,6 @@ var _ = framework.IngressNginxDescribe("Annotations - ServerSnippet", func() { f.NewEchoDeploymentWithReplicas(2) }) - AfterEach(func() { - }) - It(`add valid directives to server via server snippet"`, func() { host := "serversnippet.foo.com" annotations := map[string]string{ diff --git a/test/e2e/annotations/snippet.go b/test/e2e/annotations/snippet.go index e7b034357..7f0277bf3 100644 --- a/test/e2e/annotations/snippet.go +++ b/test/e2e/annotations/snippet.go @@ -29,9 +29,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Configurationsnippet", fun f.NewEchoDeploymentWithReplicas(2) }) - AfterEach(func() { - }) - It(`set snippet "more_set_headers "Request-Id: $req_id";" in all locations"`, func() { host := "configurationsnippet.foo.com" annotations := map[string]string{ diff --git a/test/e2e/annotations/sslciphers.go b/test/e2e/annotations/sslciphers.go index 4cded2dc4..22d948c50 100644 --- a/test/e2e/annotations/sslciphers.go +++ b/test/e2e/annotations/sslciphers.go @@ -30,9 +30,6 @@ var _ = framework.IngressNginxDescribe("Annotations - SSL CIPHERS", func() { f.NewEchoDeploymentWithReplicas(2) }) - AfterEach(func() { - }) - It("should change ssl ciphers", func() { host := "ciphers.foo.com" annotations := map[string]string{ diff --git a/test/e2e/annotations/upstreamhashby.go b/test/e2e/annotations/upstreamhashby.go index 90549949b..ea997295c 100644 --- a/test/e2e/annotations/upstreamhashby.go +++ b/test/e2e/annotations/upstreamhashby.go @@ -79,9 +79,6 @@ var _ = framework.IngressNginxDescribe("Annotations - UpstreamHashBy", func() { f.NewEchoDeploymentWithReplicas(6) }) - AfterEach(func() { - }) - It("should connect to the same pod", func() { annotations := map[string]string{ "nginx.ingress.kubernetes.io/upstream-hash-by": "$request_uri", @@ -101,6 +98,5 @@ var _ = framework.IngressNginxDescribe("Annotations - UpstreamHashBy", func() { podMap := startIngress(f, annotations) Expect(len(podMap)).Should(Equal(3)) - }) }) diff --git a/test/e2e/annotations/upstreamvhost.go b/test/e2e/annotations/upstreamvhost.go index 34e66f33e..08235f30c 100644 --- a/test/e2e/annotations/upstreamvhost.go +++ b/test/e2e/annotations/upstreamvhost.go @@ -29,9 +29,6 @@ var _ = framework.IngressNginxDescribe("Annotations - Upstreamvhost", func() { f.NewEchoDeploymentWithReplicas(2) }) - AfterEach(func() { - }) - It("set host to upstreamvhost.bar.com", func() { host := "upstreamvhost.foo.com" annotations := map[string]string{ diff --git a/test/e2e/annotations/xforwardedprefix.go b/test/e2e/annotations/xforwardedprefix.go index 6057e86b1..b0871e9e9 100644 --- a/test/e2e/annotations/xforwardedprefix.go +++ b/test/e2e/annotations/xforwardedprefix.go @@ -32,9 +32,6 @@ var _ = framework.IngressNginxDescribe("Annotations - X-Forwarded-Prefix", func( f.NewEchoDeployment() }) - AfterEach(func() { - }) - It("should set the X-Forwarded-Prefix to the annotation value", func() { host := "xfp.baz.com" annotations := map[string]string{ diff --git a/test/e2e/dbg/main.go b/test/e2e/dbg/main.go index 16e678dee..b7187b77b 100644 --- a/test/e2e/dbg/main.go +++ b/test/e2e/dbg/main.go @@ -34,9 +34,6 @@ var _ = framework.IngressNginxDescribe("Debug Tool", func() { f.NewEchoDeploymentWithReplicas(1) }) - AfterEach(func() { - }) - It("should list the backend servers", func() { annotations := map[string]string{} diff --git a/test/e2e/defaultbackend/default_backend.go b/test/e2e/defaultbackend/default_backend.go index 6f42a8172..1a8c10be0 100644 --- a/test/e2e/defaultbackend/default_backend.go +++ b/test/e2e/defaultbackend/default_backend.go @@ -30,12 +30,6 @@ import ( var _ = framework.IngressNginxDescribe("Default backend", func() { f := framework.NewDefaultFramework("default-backend") - BeforeEach(func() { - }) - - AfterEach(func() { - }) - It("should return 404 sending requests when only a default backend is running", func() { testCases := []struct { Name string diff --git a/test/e2e/defaultbackend/ssl.go b/test/e2e/defaultbackend/ssl.go index 91b52152d..ae01c01e8 100644 --- a/test/e2e/defaultbackend/ssl.go +++ b/test/e2e/defaultbackend/ssl.go @@ -29,12 +29,6 @@ import ( var _ = framework.IngressNginxDescribe("Default backend - SSL", func() { f := framework.NewDefaultFramework("default-backend") - BeforeEach(func() { - }) - - AfterEach(func() { - }) - It("should return a self generated SSL certificate", func() { By("checking SSL Certificate using the NGINX IP address") resp, _, errs := gorequest.New(). diff --git a/test/e2e/defaultbackend/with_hosts.go b/test/e2e/defaultbackend/with_hosts.go index 9cf47abf8..2d7af3bc5 100644 --- a/test/e2e/defaultbackend/with_hosts.go +++ b/test/e2e/defaultbackend/with_hosts.go @@ -38,9 +38,6 @@ var _ = framework.IngressNginxDescribe("Default backend with hosts", func() { f.NewEchoDeploymentWithReplicas(1) }) - AfterEach(func() { - }) - It("should apply the annotation to the default backend", func() { annotations := map[string]string{ "nginx.ingress.kubernetes.io/proxy-buffer-size": "8k", diff --git a/test/e2e/e2e.go b/test/e2e/e2e.go index 8ee9cb881..f8634a7a0 100644 --- a/test/e2e/e2e.go +++ b/test/e2e/e2e.go @@ -66,9 +66,3 @@ func RunE2ETests(t *testing.T) { framework.Logf("Starting e2e run %q on Ginkgo node %d", framework.RunID, config.GinkgoConfig.ParallelNode) ginkgo.RunSpecs(t, "nginx-ingress-controller e2e suite") } - -var _ = ginkgo.SynchronizedAfterSuite(func() { - // Run on all Ginkgo nodes - framework.Logf("Running AfterSuite actions on all nodes") - framework.RunCleanupActions() -}, func() {}) diff --git a/test/e2e/framework/cleanup.go b/test/e2e/framework/cleanup.go deleted file mode 100644 index c8da7d1fb..000000000 --- a/test/e2e/framework/cleanup.go +++ /dev/null @@ -1,61 +0,0 @@ -/* -Copyright 2016 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 framework - -import "sync" - -// CleanupActionHandle is a handle used to perform a cleanup action. -type CleanupActionHandle *int - -var cleanupActionsLock sync.Mutex -var cleanupActions = map[CleanupActionHandle]func(){} - -// AddCleanupAction installs a function that will be called in the event of the -// whole test being terminated. This allows arbitrary pieces of the overall -// test to hook into SynchronizedAfterSuite(). -func AddCleanupAction(fn func()) CleanupActionHandle { - p := CleanupActionHandle(new(int)) - cleanupActionsLock.Lock() - defer cleanupActionsLock.Unlock() - cleanupActions[p] = fn - return p -} - -// RemoveCleanupAction removes a function that was installed by AddCleanupAction. -func RemoveCleanupAction(p CleanupActionHandle) { - cleanupActionsLock.Lock() - defer cleanupActionsLock.Unlock() - delete(cleanupActions, p) -} - -// RunCleanupActions runs all functions installed by AddCleanupAction. It does -// not remove them (see RemoveCleanupAction) but it does run unlocked, so they -// may remove themselves. -func RunCleanupActions() { - list := []func(){} - func() { - cleanupActionsLock.Lock() - defer cleanupActionsLock.Unlock() - for _, fn := range cleanupActions { - list = append(list, fn) - } - }() - // Run unlocked. - for _, fn := range list { - fn() - } -} diff --git a/test/e2e/framework/deployment.go b/test/e2e/framework/deployment.go index e68a31565..a12608430 100644 --- a/test/e2e/framework/deployment.go +++ b/test/e2e/framework/deployment.go @@ -59,8 +59,7 @@ func (f *Framework) NewEchoDeploymentWithNameAndReplicas(name string, replicas i []corev1.Volume{}, ) - d := f.EnsureDeployment(deployment) - Expect(d).NotTo(BeNil(), "expected a deployment but none returned") + f.EnsureDeployment(deployment) service := &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ @@ -82,8 +81,7 @@ func (f *Framework) NewEchoDeploymentWithNameAndReplicas(name string, replicas i }, } - s := f.EnsureService(service) - Expect(s).NotTo(BeNil(), "expected a service but none returned") + f.EnsureService(service) err := WaitForEndpoints(f.KubeClientSet, DefaultTimeout, name, f.Namespace, replicas) Expect(err).NotTo(HaveOccurred(), "failed to wait for endpoints to become ready") @@ -144,8 +142,7 @@ server { }, ) - d := f.EnsureDeployment(deployment) - Expect(d).NotTo(BeNil(), "expected a deployment but none returned") + f.EnsureDeployment(deployment) service := &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ @@ -167,13 +164,105 @@ server { }, } - s := f.EnsureService(service) - Expect(s).NotTo(BeNil(), "expected a service but none returned") + f.EnsureService(service) err = WaitForEndpoints(f.KubeClientSet, DefaultTimeout, SlowEchoService, f.Namespace, 1) Expect(err).NotTo(HaveOccurred(), "failed to wait for endpoints to become ready") } +// NewGRPCBinDeployment creates a new deployment of the +// moul/grpcbin image for GRPC tests +func (f *Framework) NewGRPCBinDeployment() { + name := "grpcbin" + + probe := &corev1.Probe{ + InitialDelaySeconds: 5, + PeriodSeconds: 10, + SuccessThreshold: 1, + TimeoutSeconds: 1, + Handler: corev1.Handler{ + TCPSocket: &corev1.TCPSocketAction{ + Port: intstr.FromInt(9000), + }, + }, + } + + sel := map[string]string{ + "app": name, + } + + f.EnsureDeployment(&appsv1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: f.Namespace, + }, + Spec: appsv1.DeploymentSpec{ + Replicas: NewInt32(1), + Selector: &metav1.LabelSelector{ + MatchLabels: sel, + }, + Template: corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: sel, + }, + Spec: corev1.PodSpec{ + TerminationGracePeriodSeconds: NewInt64(0), + Containers: []corev1.Container{ + { + Name: name, + Image: "moul/grpcbin", + Env: []corev1.EnvVar{}, + Ports: []corev1.ContainerPort{ + { + Name: "insecure", + ContainerPort: 9000, + Protocol: corev1.ProtocolTCP, + }, + { + Name: "secure", + ContainerPort: 9001, + Protocol: corev1.ProtocolTCP, + }, + }, + ReadinessProbe: probe, + LivenessProbe: probe, + }, + }, + }, + }, + }, + }) + + service := &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: f.Namespace, + }, + Spec: corev1.ServiceSpec{ + Ports: []corev1.ServicePort{ + { + Name: "insecure", + Port: 9000, + TargetPort: intstr.FromInt(9000), + Protocol: corev1.ProtocolTCP, + }, + { + Name: "secure", + Port: 9001, + TargetPort: intstr.FromInt(9000), + Protocol: corev1.ProtocolTCP, + }, + }, + Selector: sel, + }, + } + + f.EnsureService(service) + + err := WaitForEndpoints(f.KubeClientSet, DefaultTimeout, name, f.Namespace, 1) + Expect(err).NotTo(HaveOccurred(), "failed to wait for endpoints to become ready") +} + func newDeployment(name, namespace, image string, port int32, replicas int32, command []string, volumeMounts []corev1.VolumeMount, volumes []corev1.Volume) *appsv1.Deployment { probe := &corev1.Probe{ @@ -247,8 +336,7 @@ func (f *Framework) NewHttpbinDeployment() { func (f *Framework) NewDeployment(name, image string, port int32, replicas int32) { deployment := newDeployment(name, f.Namespace, image, port, replicas, nil, nil, nil) - d := f.EnsureDeployment(deployment) - Expect(d).NotTo(BeNil(), "expected a deployment but none returned") + f.EnsureDeployment(deployment) service := &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ @@ -270,8 +358,7 @@ func (f *Framework) NewDeployment(name, image string, port int32, replicas int32 }, } - s := f.EnsureService(service) - Expect(s).NotTo(BeNil(), "expected a service but none returned") + f.EnsureService(service) err := WaitForEndpoints(f.KubeClientSet, DefaultTimeout, name, f.Namespace, int(replicas)) Expect(err).NotTo(HaveOccurred(), "failed to wait for endpoints to become ready") @@ -295,7 +382,10 @@ func (f *Framework) ScaleDeploymentToZero(name string) { Expect(d).NotTo(BeNil(), "expected a deployment but none returned") d.Spec.Replicas = NewInt32(0) - f.EnsureDeployment(d) + + d, err = f.KubeClientSet.AppsV1().Deployments(f.Namespace).Update(d) + Expect(err).NotTo(HaveOccurred(), "failed to get a deployment") + Expect(d).NotTo(BeNil(), "expected a deployment but none returned") err = WaitForEndpoints(f.KubeClientSet, DefaultTimeout, name, f.Namespace, 0) Expect(err).NotTo(HaveOccurred(), "failed to wait for no endpoints") diff --git a/test/e2e/framework/exec.go b/test/e2e/framework/exec.go index 062d91ec0..ee6bfbed0 100644 --- a/test/e2e/framework/exec.go +++ b/test/e2e/framework/exec.go @@ -87,8 +87,34 @@ func (f *Framework) ExecCommand(pod *corev1.Pod, command string) (string, error) return execOut.String(), nil } -// NewIngressController deploys a new NGINX Ingress controller in a namespace -func (f *Framework) NewIngressController(namespace string, namespaceOverlay string) error { +// NamespaceContent executes a kubectl command that returns information about +// pods, services, endpoint and deployments inside the current namespace +func (f *Framework) NamespaceContent() (string, error) { + var ( + execOut bytes.Buffer + execErr bytes.Buffer + ) + + cmd := exec.Command("/bin/bash", "-c", fmt.Sprintf("%v get pods,services,endpoints,deployments --namespace %s", KubectlPath, f.Namespace)) + cmd.Stdout = &execOut + cmd.Stderr = &execErr + + err := cmd.Run() + if err != nil { + return "", fmt.Errorf("could not execute '%s %s': %v", cmd.Path, cmd.Args, err) + + } + + eout := strings.TrimSpace(execErr.String()) + if len(eout) > 0 { + return "", fmt.Errorf("stderr: %v", eout) + } + + return execOut.String(), nil +} + +// newIngressController deploys a new NGINX Ingress controller in a namespace +func (f *Framework) newIngressController(namespace string, namespaceOverlay string) error { // Creates an nginx deployment cmd := exec.Command("./wait-for-nginx.sh", namespace, namespaceOverlay) out, err := cmd.CombinedOutput() diff --git a/test/e2e/framework/fastcgi_helloserver.go b/test/e2e/framework/fastcgi_helloserver.go index dc7388186..e7b3aca62 100644 --- a/test/e2e/framework/fastcgi_helloserver.go +++ b/test/e2e/framework/fastcgi_helloserver.go @@ -74,7 +74,6 @@ func (f *Framework) NewNewFastCGIHelloServerDeploymentWithReplicas(replicas int3 } d := f.EnsureDeployment(deployment) - Expect(d).NotTo(BeNil(), "expected a fastcgi-helloserver deployment") err := WaitForPodsReady(f.KubeClientSet, DefaultTimeout, int(replicas), f.Namespace, metav1.ListOptions{ LabelSelector: fields.SelectorFromSet(fields.Set(d.Spec.Template.ObjectMeta.Labels)).String(), diff --git a/test/e2e/framework/framework.go b/test/e2e/framework/framework.go index 2656bacbe..686ceec50 100644 --- a/test/e2e/framework/framework.go +++ b/test/e2e/framework/framework.go @@ -31,8 +31,8 @@ import ( restclient "k8s.io/client-go/rest" "k8s.io/klog" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" + "github.com/onsi/ginkgo" + "github.com/onsi/gomega" ) // RequestScheme define a scheme used in a test request. @@ -58,11 +58,6 @@ type Framework struct { KubeConfig *restclient.Config APIExtensionsClientSet apiextcs.Interface - // To make sure that this framework cleans up after itself, no matter what, - // we install a Cleanup action before each test and clear it after. If we - // should abort, the AfterSuite hook should run all Cleanup actions. - cleanupHandle CleanupActionHandle - Namespace string } @@ -73,82 +68,89 @@ func NewDefaultFramework(baseName string) *Framework { BaseName: baseName, } - BeforeEach(f.BeforeEach) - AfterEach(f.AfterEach) + ginkgo.BeforeEach(f.BeforeEach) + ginkgo.AfterEach(f.AfterEach) return f } // BeforeEach gets a client and makes a namespace. func (f *Framework) BeforeEach() { - f.cleanupHandle = AddCleanupAction(f.AfterEach) - - By("Creating a kubernetes client") kubeConfig, err := restclient.InClusterConfig() if err != nil { panic(err.Error()) } - Expect(err).NotTo(HaveOccurred()) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) f.KubeConfig = kubeConfig f.KubeClientSet, err = kubernetes.NewForConfig(kubeConfig) - Expect(err).NotTo(HaveOccurred()) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) - By("Building a namespace api object") ingressNamespace, err := CreateKubeNamespace(f.BaseName, f.KubeClientSet) - Expect(err).NotTo(HaveOccurred()) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) f.Namespace = ingressNamespace - By("Starting new ingress controller") - err = f.NewIngressController(f.Namespace, f.BaseName) - Expect(err).NotTo(HaveOccurred()) + err = f.newIngressController(f.Namespace, f.BaseName) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) err = WaitForPodsReady(f.KubeClientSet, DefaultTimeout, 1, f.Namespace, metav1.ListOptions{ LabelSelector: "app.kubernetes.io/name=ingress-nginx", }) - Expect(err).NotTo(HaveOccurred()) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) } // AfterEach deletes the namespace, after reading its events. func (f *Framework) AfterEach() { - RemoveCleanupAction(f.cleanupHandle) - - By("Waiting for test namespace to no longer exist") - err := DeleteKubeNamespace(f.KubeClientSet, f.Namespace) - Expect(err).NotTo(HaveOccurred()) - - if CurrentGinkgoTestDescription().Failed { - log, err := f.NginxLogs() - Expect(err).ToNot(HaveOccurred()) - By("Dumping NGINX logs after a failure running a test") - Logf("%v", log) - + if ginkgo.CurrentGinkgoTestDescription().Failed { pod, err := getIngressNGINXPod(f.Namespace, f.KubeClientSet) if err != nil { + Logf("Unexpected error searching for ingress controller pod: %v", err) return } cmd := fmt.Sprintf("cat /etc/nginx/nginx.conf") o, err := f.ExecCommand(pod, cmd) if err != nil { + Logf("Unexpected error obtaining nginx.conf file: %v", err) return } - By("Dumping NGINX configuration after a failure running a test") + ginkgo.By("Dumping NGINX configuration after failure") + Logf("%v", o) + + log, err := f.NginxLogs() + if err != nil { + Logf("Unexpected error obtaining NGINX logs: %v", err) + return + } + + ginkgo.By("Dumping NGINX logs") + Logf("%v", log) + + o, err = f.NamespaceContent() + if err != nil { + Logf("Unexpected error obtaining namespace information: %v", err) + return + } + + ginkgo.By("Dumping namespace content") Logf("%v", o) } + + err := DeleteKubeNamespace(f.KubeClientSet, f.Namespace) + gomega.Expect(err).NotTo(gomega.HaveOccurred(), "unexpected error deleting namespace %v", f.Namespace) } // IngressNginxDescribe wrapper function for ginkgo describe. Adds namespacing. func IngressNginxDescribe(text string, body func()) bool { - return Describe("[ingress-nginx] "+text, body) + return ginkgo.Describe("[ingress-nginx] "+text, body) } // MemoryLeakIt is wrapper function for ginkgo It. Adds "[MemoryLeak]" tag and makes static analysis easier. func MemoryLeakIt(text string, body interface{}, timeout ...float64) bool { - return It(text+" [MemoryLeak]", body, timeout...) + return ginkgo.It(text+" [MemoryLeak]", body, timeout...) } // GetNginxIP returns the number of TCP port where NGINX is running @@ -157,7 +159,7 @@ func (f *Framework) GetNginxIP() string { CoreV1(). Services(f.Namespace). Get("ingress-nginx", metav1.GetOptions{}) - Expect(err).NotTo(HaveOccurred(), "unexpected error obtaining NGINX IP address") + gomega.Expect(err).NotTo(gomega.HaveOccurred(), "unexpected error obtaining NGINX IP address") return s.Spec.ClusterIP } @@ -167,7 +169,7 @@ func (f *Framework) GetNginxPodIP() []string { CoreV1(). Endpoints(f.Namespace). Get("ingress-nginx", metav1.GetOptions{}) - Expect(err).NotTo(HaveOccurred(), "unexpected error obtaining NGINX IP address") + gomega.Expect(err).NotTo(gomega.HaveOccurred(), "unexpected error obtaining NGINX IP address") eips := make([]string, 0) for _, s := range e.Subsets { for _, a := range s.Addresses { @@ -187,14 +189,14 @@ func (f *Framework) GetURL(scheme RequestScheme) string { // WaitForNginxServer waits until the nginx configuration contains a particular server section func (f *Framework) WaitForNginxServer(name string, matcher func(cfg string) bool) { err := wait.Poll(Poll, DefaultTimeout, f.matchNginxConditions(name, matcher)) - Expect(err).NotTo(HaveOccurred(), "unexpected error waiting for nginx server condition/s") + gomega.Expect(err).NotTo(gomega.HaveOccurred(), "unexpected error waiting for nginx server condition/s") time.Sleep(5 * time.Second) } // WaitForNginxConfiguration waits until the nginx configuration contains a particular configuration func (f *Framework) WaitForNginxConfiguration(matcher func(cfg string) bool) { err := wait.Poll(Poll, DefaultTimeout, f.matchNginxConditions("", matcher)) - Expect(err).NotTo(HaveOccurred(), "unexpected error waiting for nginx server condition/s") + gomega.Expect(err).NotTo(gomega.HaveOccurred(), "unexpected error waiting for nginx server condition/s") time.Sleep(5 * time.Second) } @@ -236,7 +238,7 @@ func (f *Framework) matchNginxConditions(name string, matcher func(cfg string) b } var match bool - errs := InterceptGomegaFailures(func() { + errs := gomega.InterceptGomegaFailures(func() { if klog.V(10) && len(o) > 0 { klog.Infof("nginx.conf:\n%v", o) } @@ -299,8 +301,8 @@ func (f *Framework) SetNginxConfigMapData(cmData map[string]string) { func (f *Framework) SetConfigMapData(name string, cmData map[string]string) { config, err := f.getConfigMap(name) - Expect(err).NotTo(HaveOccurred()) - Expect(config).NotTo(BeNil(), "expected a configmap but none returned") + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + gomega.Expect(config).NotTo(gomega.BeNil(), "expected a configmap but none returned") config.Data = cmData @@ -308,7 +310,7 @@ func (f *Framework) SetConfigMapData(name string, cmData map[string]string) { CoreV1(). ConfigMaps(f.Namespace). Update(config) - Expect(err).NotTo(HaveOccurred()) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) time.Sleep(5 * time.Second) } @@ -321,13 +323,13 @@ func (f *Framework) CreateConfigMap(name string, data map[string]string) { }, Data: data, }) - Expect(err).NotTo(HaveOccurred(), "failed to create configMap") + gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to create configMap") } // UpdateNginxConfigMapData updates single field in ingress-nginx's nginx-configuration map data func (f *Framework) UpdateNginxConfigMapData(key string, value string) { config, err := f.GetNginxConfigMapData() - Expect(err).NotTo(HaveOccurred(), "unexpected error reading configmap") + gomega.Expect(err).NotTo(gomega.HaveOccurred(), "unexpected error reading configmap") config[key] = value @@ -340,10 +342,10 @@ func (f *Framework) UpdateNginxConfigMapData(key string, value string) { func (f *Framework) DeleteNGINXPod(grace int64) { ns := f.Namespace pod, err := getIngressNGINXPod(ns, f.KubeClientSet) - Expect(err).NotTo(HaveOccurred(), "expected ingress nginx pod to be running") + gomega.Expect(err).NotTo(gomega.HaveOccurred(), "expected ingress nginx pod to be running") err = f.KubeClientSet.CoreV1().Pods(ns).Delete(pod.GetName(), metav1.NewDeleteOptions(grace)) - Expect(err).NotTo(HaveOccurred(), "unexpected error deleting ingress nginx pod") + gomega.Expect(err).NotTo(gomega.HaveOccurred(), "unexpected error deleting ingress nginx pod") err = wait.Poll(Poll, DefaultTimeout, func() (bool, error) { pod, err := getIngressNGINXPod(ns, f.KubeClientSet) @@ -352,7 +354,7 @@ func (f *Framework) DeleteNGINXPod(grace int64) { } return pod.GetName() != "", nil }) - Expect(err).NotTo(HaveOccurred(), "unexpected error while waiting for ingress nginx pod to come up again") + gomega.Expect(err).NotTo(gomega.HaveOccurred(), "unexpected error while waiting for ingress nginx pod to come up again") } // UpdateDeployment runs the given updateFunc on the deployment and waits for it to be updated diff --git a/test/e2e/framework/grpc_fortune_teller.go b/test/e2e/framework/grpc_fortune_teller.go index 4bbeee65b..b61395e51 100644 --- a/test/e2e/framework/grpc_fortune_teller.go +++ b/test/e2e/framework/grpc_fortune_teller.go @@ -74,7 +74,6 @@ func (f *Framework) NewNewGRPCFortuneTellerDeploymentWithReplicas(replicas int32 } d := f.EnsureDeployment(deployment) - Expect(d).NotTo(BeNil(), "expected a fortune-teller deployment") err := WaitForPodsReady(f.KubeClientSet, DefaultTimeout, int(replicas), f.Namespace, metav1.ListOptions{ LabelSelector: fields.SelectorFromSet(fields.Set(d.Spec.Template.ObjectMeta.Labels)).String(), diff --git a/test/e2e/framework/influxdb.go b/test/e2e/framework/influxdb.go index c38bf9c4a..82411b1fc 100644 --- a/test/e2e/framework/influxdb.go +++ b/test/e2e/framework/influxdb.go @@ -75,20 +75,20 @@ func (f *Framework) NewInfluxDBDeployment() { deployment := &appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ - Name: "influxdb-svc", + Name: "influxdb", Namespace: f.Namespace, }, Spec: appsv1.DeploymentSpec{ Replicas: NewInt32(1), Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{ - "app": "influxdb-svc", + "app": "influxdb", }, }, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ - "app": "influxdb-svc", + "app": "influxdb", }, }, Spec: corev1.PodSpec{ @@ -107,7 +107,7 @@ func (f *Framework) NewInfluxDBDeployment() { }, Containers: []corev1.Container{ { - Name: "influxdb-svc", + Name: "influxdb", Image: "docker.io/influxdb:1.5", Env: []corev1.EnvVar{}, Command: []string{"influxd", "-config", "/influxdb-config/influxd.conf"}, @@ -136,7 +136,6 @@ func (f *Framework) NewInfluxDBDeployment() { } d := f.EnsureDeployment(deployment) - Expect(d).NotTo(BeNil(), "unexpected error creating deployment for influxdb") err = WaitForPodsReady(f.KubeClientSet, DefaultTimeout, 1, f.Namespace, metav1.ListOptions{ LabelSelector: fields.SelectorFromSet(fields.Set(d.Spec.Template.ObjectMeta.Labels)).String(), diff --git a/test/e2e/framework/k8s.go b/test/e2e/framework/k8s.go index 47612bed3..03edf8464 100644 --- a/test/e2e/framework/k8s.go +++ b/test/e2e/framework/k8s.go @@ -26,9 +26,11 @@ import ( appsv1 "k8s.io/api/apps/v1" api "k8s.io/api/core/v1" core "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" networking "k8s.io/api/networking/v1beta1" k8sErrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + utilnet "k8s.io/apimachinery/pkg/util/net" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/kubernetes" "k8s.io/client-go/util/retry" @@ -37,18 +39,10 @@ import ( // EnsureSecret creates a Secret object or returns it if it already exists. func (f *Framework) EnsureSecret(secret *api.Secret) *api.Secret { - s, err := f.KubeClientSet.CoreV1().Secrets(secret.Namespace).Create(secret) - if err != nil { - if k8sErrors.IsAlreadyExists(err) { - s, err := f.KubeClientSet.CoreV1().Secrets(secret.Namespace).Update(secret) - Expect(err).NotTo(HaveOccurred(), "unexpected error updating secret") - - return s - } - - Expect(err).NotTo(HaveOccurred(), "unexpected error creating secret") - } + err := createSecretWithRetries(f.KubeClientSet, f.Namespace, secret) + Expect(err).To(BeNil(), "unexpected error creating secret") + s, err := f.KubeClientSet.CoreV1().Secrets(secret.Namespace).Get(secret.Name, metav1.GetOptions{}) Expect(s).NotTo(BeNil()) Expect(s.ObjectMeta).NotTo(BeNil()) @@ -57,10 +51,10 @@ func (f *Framework) EnsureSecret(secret *api.Secret) *api.Secret { // EnsureConfigMap creates a ConfigMap object or returns it if it already exists. func (f *Framework) EnsureConfigMap(configMap *api.ConfigMap) (*api.ConfigMap, error) { - cm, err := f.KubeClientSet.CoreV1().ConfigMaps(configMap.Namespace).Create(configMap) + cm, err := f.KubeClientSet.CoreV1().ConfigMaps(f.Namespace).Create(configMap) if err != nil { if k8sErrors.IsAlreadyExists(err) { - return f.KubeClientSet.CoreV1().ConfigMaps(configMap.Namespace).Update(configMap) + return f.KubeClientSet.CoreV1().ConfigMaps(f.Namespace).Update(configMap) } return nil, err } @@ -70,12 +64,12 @@ func (f *Framework) EnsureConfigMap(configMap *api.ConfigMap) (*api.ConfigMap, e // EnsureIngress creates an Ingress object or returns it if it already exists. func (f *Framework) EnsureIngress(ingress *networking.Ingress) *networking.Ingress { - ing, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(ingress.Namespace).Create(ingress) + ing, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Create(ingress) if err != nil { if k8sErrors.IsAlreadyExists(err) { err = retry.RetryOnConflict(retry.DefaultRetry, func() error { var err error - ing, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(ingress.Namespace).Update(ingress) + ing, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Update(ingress) if err != nil { return err } @@ -100,47 +94,28 @@ func (f *Framework) EnsureIngress(ingress *networking.Ingress) *networking.Ingre // EnsureService creates a Service object or returns it if it already exists. func (f *Framework) EnsureService(service *core.Service) *core.Service { - s, err := f.KubeClientSet.CoreV1().Services(service.Namespace).Create(service) - if err != nil { - if k8sErrors.IsAlreadyExists(err) { - err = retry.RetryOnConflict(retry.DefaultRetry, func() error { - var err error - s, err = f.KubeClientSet.CoreV1().Services(service.Namespace).Update(service) - if err != nil { - return err - } + err := createServiceWithRetries(f.KubeClientSet, f.Namespace, service) + Expect(err).To(BeNil(), "unexpected error creating service") - return nil - }) + s, err := f.KubeClientSet.CoreV1().Services(f.Namespace).Get(service.Name, metav1.GetOptions{}) + Expect(err).To(BeNil(), "unexpected error searching service") + Expect(s).NotTo(BeNil()) + Expect(s.ObjectMeta).NotTo(BeNil()) - Expect(err).NotTo(HaveOccurred()) - } - } - - Expect(s).NotTo(BeNil(), "expected a service but none returned") return s } // EnsureDeployment creates a Deployment object or returns it if it already exists. func (f *Framework) EnsureDeployment(deployment *appsv1.Deployment) *appsv1.Deployment { - d, err := f.KubeClientSet.AppsV1().Deployments(deployment.Namespace).Create(deployment) - if err != nil { - if k8sErrors.IsAlreadyExists(err) { - err = retry.RetryOnConflict(retry.DefaultRetry, func() error { - d, err = f.KubeClientSet.AppsV1().Deployments(deployment.Namespace).Update(deployment) - if err != nil { - return err - } + err := createDeploymentWithRetries(f.KubeClientSet, f.Namespace, deployment) + Expect(err).To(BeNil(), "unexpected error creating deployment") - return nil - }) + s, err := f.KubeClientSet.AppsV1().Deployments(deployment.Namespace).Get(deployment.Name, metav1.GetOptions{}) + Expect(err).To(BeNil(), "unexpected error searching deployment") + Expect(s).NotTo(BeNil()) + Expect(s.ObjectMeta).NotTo(BeNil()) - Expect(err).NotTo(HaveOccurred()) - } - } - - Expect(d).NotTo(BeNil(), "expected a deployment but none returned") - return d + return s } // WaitForPodsReady waits for a given amount of time until a group of Pods is running in the given namespace. @@ -257,3 +232,88 @@ func getIngressNGINXPod(ns string, kubeClientSet kubernetes.Interface) (*core.Po return pod, nil } + +func createDeploymentWithRetries(c kubernetes.Interface, namespace string, obj *appsv1.Deployment) error { + if obj == nil { + return fmt.Errorf("Object provided to create is empty") + } + createFunc := func() (bool, error) { + _, err := c.AppsV1().Deployments(namespace).Create(obj) + if err == nil || k8sErrors.IsAlreadyExists(err) { + return true, nil + } + if isRetryableAPIError(err) { + return false, nil + } + return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err) + } + + return retryWithExponentialBackOff(createFunc) +} + +func createSecretWithRetries(c kubernetes.Interface, namespace string, obj *v1.Secret) error { + if obj == nil { + return fmt.Errorf("Object provided to create is empty") + } + createFunc := func() (bool, error) { + _, err := c.CoreV1().Secrets(namespace).Create(obj) + if err == nil || k8sErrors.IsAlreadyExists(err) { + return true, nil + } + if isRetryableAPIError(err) { + return false, nil + } + return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err) + } + return retryWithExponentialBackOff(createFunc) +} + +func createServiceWithRetries(c kubernetes.Interface, namespace string, obj *v1.Service) error { + if obj == nil { + return fmt.Errorf("Object provided to create is empty") + } + createFunc := func() (bool, error) { + _, err := c.CoreV1().Services(namespace).Create(obj) + if err == nil || k8sErrors.IsAlreadyExists(err) { + return true, nil + } + if isRetryableAPIError(err) { + return false, nil + } + return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err) + } + + return retryWithExponentialBackOff(createFunc) +} + +const ( + // Parameters for retrying with exponential backoff. + retryBackoffInitialDuration = 100 * time.Millisecond + retryBackoffFactor = 3 + retryBackoffJitter = 0 + retryBackoffSteps = 6 +) + +// Utility for retrying the given function with exponential backoff. +func retryWithExponentialBackOff(fn wait.ConditionFunc) error { + backoff := wait.Backoff{ + Duration: retryBackoffInitialDuration, + Factor: retryBackoffFactor, + Jitter: retryBackoffJitter, + Steps: retryBackoffSteps, + } + return wait.ExponentialBackoff(backoff, fn) +} + +func isRetryableAPIError(err error) bool { + // These errors may indicate a transient error that we can retry in tests. + if k8sErrors.IsInternalError(err) || k8sErrors.IsTimeout(err) || k8sErrors.IsServerTimeout(err) || + k8sErrors.IsTooManyRequests(err) || utilnet.IsProbableEOF(err) || utilnet.IsConnectionReset(err) { + return true + } + // If the error sends the Retry-After header, we respect it as an explicit confirmation we should retry. + if _, shouldRetry := k8sErrors.SuggestsClientDelay(err); shouldRetry { + return true + } + return false +} diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index e28419334..d64dcf233 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -107,7 +107,6 @@ func CreateKubeNamespace(baseName string, c kubernetes.Interface) (string, error Logf("Unexpected error while creating namespace: %v", err) return false, nil } - Logf("Created namespace: %v", got.Name) return true, nil }) if err != nil { @@ -118,7 +117,12 @@ func CreateKubeNamespace(baseName string, c kubernetes.Interface) (string, error // DeleteKubeNamespace deletes a namespace and all the objects inside func DeleteKubeNamespace(c kubernetes.Interface, namespace string) error { - return c.CoreV1().Namespaces().Delete(namespace, metav1.NewDeleteOptions(0)) + grace := int64(0) + pb := metav1.DeletePropagationBackground + return c.CoreV1().Namespaces().Delete(namespace, &metav1.DeleteOptions{ + GracePeriodSeconds: &grace, + PropagationPolicy: &pb, + }) } // ExpectNoError tests whether an error occurred. diff --git a/test/e2e/gracefulshutdown/shutdown.go b/test/e2e/gracefulshutdown/shutdown.go index 4f3b53ae1..46d4a6f45 100755 --- a/test/e2e/gracefulshutdown/shutdown.go +++ b/test/e2e/gracefulshutdown/shutdown.go @@ -39,9 +39,6 @@ var _ = framework.IngressNginxDescribe("Shutdown ingress controller", func() { 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)) @@ -118,7 +115,7 @@ var _ = framework.IngressNginxDescribe("Shutdown ingress controller", func() { 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") + Expect(time.Since(startTime).Seconds()).To(BeNumerically(">", 60), "waiting shutdown") ticker.Stop() return case <-ticker.C: diff --git a/test/e2e/leaks/lua_ssl.go b/test/e2e/leaks/lua_ssl.go index 2ab9e0b39..2b91ac40d 100644 --- a/test/e2e/leaks/lua_ssl.go +++ b/test/e2e/leaks/lua_ssl.go @@ -40,9 +40,6 @@ var _ = framework.IngressNginxDescribe("DynamicCertificates", func() { f.NewEchoDeployment() }) - AfterEach(func() { - }) - framework.MemoryLeakIt("should not leak memory from ingress SSL certificates or configuration updates", func() { hostCount := 1000 iterations := 10 diff --git a/test/e2e/loadbalance/configmap.go b/test/e2e/loadbalance/configmap.go index b769ab494..236d1e875 100644 --- a/test/e2e/loadbalance/configmap.go +++ b/test/e2e/loadbalance/configmap.go @@ -32,9 +32,6 @@ var _ = framework.IngressNginxDescribe("Load Balance - Configmap value", func() f.NewEchoDeploymentWithReplicas(1) }) - AfterEach(func() { - }) - It("should apply the configmap load-balance setting", func() { host := "load-balance.com" diff --git a/test/e2e/run.sh b/test/e2e/run.sh index 369dd9c8a..97ebea1ad 100755 --- a/test/e2e/run.sh +++ b/test/e2e/run.sh @@ -100,7 +100,7 @@ kind load docker-image --name="${KIND_CLUSTER_NAME}" ${REGISTRY}/fastcgi-hellose 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} kind load docker-image --name="${KIND_CLUSTER_NAME}" ${REGISTRY}/echo:${TAG} - +kind load docker-image --name="${KIND_CLUSTER_NAME}" moul/grpcbin " | parallel --joblog /tmp/log {} || cat /tmp/log echo "[dev-env] running e2e tests..." diff --git a/test/e2e/security/request_smuggling.go b/test/e2e/security/request_smuggling.go index 2b80a77c1..09bb6d909 100644 --- a/test/e2e/security/request_smuggling.go +++ b/test/e2e/security/request_smuggling.go @@ -36,9 +36,6 @@ var _ = framework.IngressNginxDescribe("Request smuggling", func() { f.NewEchoDeployment() }) - AfterEach(func() { - }) - It("should not return body content from error_page", func() { host := "foo.bar.com" diff --git a/test/e2e/servicebackend/service_backend.go b/test/e2e/servicebackend/service_backend.go index 3a6dba086..79db74f32 100644 --- a/test/e2e/servicebackend/service_backend.go +++ b/test/e2e/servicebackend/service_backend.go @@ -35,12 +35,6 @@ import ( var _ = framework.IngressNginxDescribe("Service backend - 503", func() { f := framework.NewDefaultFramework("service-backend") - BeforeEach(func() { - }) - - AfterEach(func() { - }) - It("should return 503 when backend service does not exist", func() { host := "nonexistent.svc.com" @@ -65,9 +59,7 @@ var _ = framework.IngressNginxDescribe("Service backend - 503", func() { bi, bs := buildIngressWithUnavailableServiceEndpoints(host, f.Namespace, "/") - svc := f.EnsureService(bs) - Expect(svc).NotTo(BeNil()) - + f.EnsureService(bs) f.EnsureIngress(bi) f.WaitForNginxServer(host, diff --git a/test/e2e/servicebackend/service_externalname.go b/test/e2e/servicebackend/service_externalname.go index d02104b08..51d83273b 100644 --- a/test/e2e/servicebackend/service_externalname.go +++ b/test/e2e/servicebackend/service_externalname.go @@ -35,12 +35,6 @@ import ( var _ = framework.IngressNginxDescribe("Service Type ExternalName", func() { f := framework.NewDefaultFramework("type-externalname") - BeforeEach(func() { - }) - - AfterEach(func() { - }) - It("works with external name set to incomplete fdqn", func() { f.NewEchoDeployment() diff --git a/test/e2e/settings/configmap_change.go b/test/e2e/settings/configmap_change.go index 927b702eb..5565565c9 100644 --- a/test/e2e/settings/configmap_change.go +++ b/test/e2e/settings/configmap_change.go @@ -33,9 +33,6 @@ var _ = framework.IngressNginxDescribe("Configmap change", func() { f.NewEchoDeployment() }) - AfterEach(func() { - }) - It("should reload after an update in the configuration", func() { host := "configmap-change" diff --git a/test/e2e/settings/disable_catch_all.go b/test/e2e/settings/disable_catch_all.go index c389b36cf..37b9dba6c 100644 --- a/test/e2e/settings/disable_catch_all.go +++ b/test/e2e/settings/disable_catch_all.go @@ -49,9 +49,6 @@ var _ = framework.IngressNginxDescribe("Disabled catch-all", func() { Expect(err).NotTo(HaveOccurred(), "unexpected error updating ingress controller deployment flags") }) - AfterEach(func() { - }) - It("should ignore catch all Ingress", func() { host := "foo" diff --git a/test/e2e/settings/forwarded_headers.go b/test/e2e/settings/forwarded_headers.go index 49aa910e7..dcfbd4de6 100644 --- a/test/e2e/settings/forwarded_headers.go +++ b/test/e2e/settings/forwarded_headers.go @@ -38,9 +38,6 @@ var _ = framework.IngressNginxDescribe("X-Forwarded headers", func() { f.UpdateNginxConfigMapData(setting, "false") }) - AfterEach(func() { - }) - It("should trust X-Forwarded headers when setting is true", func() { host := "forwarded-headers" diff --git a/test/e2e/settings/global_access_block.go b/test/e2e/settings/global_access_block.go index 6a7cd739e..61d1a1b5a 100644 --- a/test/e2e/settings/global_access_block.go +++ b/test/e2e/settings/global_access_block.go @@ -37,9 +37,6 @@ var _ = framework.IngressNginxDescribe("Global access block", func() { f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil)) }) - AfterEach(func() { - }) - It("should block CIDRs defined in the ConfigMap", func() { f.UpdateNginxConfigMapData("block-cidrs", "172.16.0.0/12,192.168.0.0/16,10.0.0.0/8") diff --git a/test/e2e/settings/global_external_auth.go b/test/e2e/settings/global_external_auth.go index c944c9697..c6ae0bc38 100755 --- a/test/e2e/settings/global_external_auth.go +++ b/test/e2e/settings/global_external_auth.go @@ -50,9 +50,6 @@ var _ = framework.IngressNginxDescribe("Global External Auth", func() { f.NewHttpbinDeployment() }) - AfterEach(func() { - }) - Context("when global external authentication is configured", func() { BeforeEach(func() { diff --git a/test/e2e/settings/ingress_class.go b/test/e2e/settings/ingress_class.go index 9e9be4ae8..e96916c58 100644 --- a/test/e2e/settings/ingress_class.go +++ b/test/e2e/settings/ingress_class.go @@ -37,9 +37,6 @@ var _ = framework.IngressNginxDescribe("Ingress class", func() { f.NewEchoDeploymentWithReplicas(1) }) - AfterEach(func() { - }) - Context("Without a specific ingress-class", func() { It("should ignore Ingress with class", func() { diff --git a/test/e2e/settings/lua_shared_dicts.go b/test/e2e/settings/lua_shared_dicts.go index d76ca87ad..01aeaffb3 100644 --- a/test/e2e/settings/lua_shared_dicts.go +++ b/test/e2e/settings/lua_shared_dicts.go @@ -31,9 +31,6 @@ var _ = framework.IngressNginxDescribe("LuaSharedDict", func() { f.NewEchoDeployment() }) - AfterEach(func() { - }) - It("configures lua shared dicts", func() { ingress := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil) f.EnsureIngress(ingress) diff --git a/test/e2e/settings/no_auth_locations.go b/test/e2e/settings/no_auth_locations.go index da52222f1..95bef6c02 100644 --- a/test/e2e/settings/no_auth_locations.go +++ b/test/e2e/settings/no_auth_locations.go @@ -53,9 +53,6 @@ var _ = framework.IngressNginxDescribe("No Auth locations", func() { f.EnsureIngress(bi) }) - AfterEach(func() { - }) - It("should return status code 401 when accessing '/' unauthentication", func() { f.WaitForNginxServer(host, func(server string) bool { diff --git a/test/e2e/settings/proxy_protocol.go b/test/e2e/settings/proxy_protocol.go index e0348c4ed..60038a735 100644 --- a/test/e2e/settings/proxy_protocol.go +++ b/test/e2e/settings/proxy_protocol.go @@ -38,9 +38,6 @@ var _ = framework.IngressNginxDescribe("Proxy Protocol", func() { f.UpdateNginxConfigMapData(setting, "false") }) - AfterEach(func() { - }) - It("should respect port passed by the PROXY Protocol", func() { host := "proxy-protocol" diff --git a/test/e2e/settings/server_tokens.go b/test/e2e/settings/server_tokens.go index 0ef4b46c6..27f96ff74 100644 --- a/test/e2e/settings/server_tokens.go +++ b/test/e2e/settings/server_tokens.go @@ -35,9 +35,6 @@ var _ = framework.IngressNginxDescribe("Server Tokens", func() { f.NewEchoDeployment() }) - AfterEach(func() { - }) - It("should not exists Server header in the response", func() { f.UpdateNginxConfigMapData(serverTokens, "false") diff --git a/test/e2e/settings/tls.go b/test/e2e/settings/tls.go index 4daa0d544..b692e496d 100644 --- a/test/e2e/settings/tls.go +++ b/test/e2e/settings/tls.go @@ -43,9 +43,6 @@ var _ = framework.IngressNginxDescribe("Settings - TLS)", func() { f.UpdateNginxConfigMapData("use-forwarded-headers", "false") }) - AfterEach(func() { - }) - It("should configure TLS protocol", func() { sslCiphers := "ssl-ciphers" sslProtocols := "ssl-protocols" diff --git a/test/e2e/ssl/http_redirect.go b/test/e2e/ssl/http_redirect.go index 5f26284e9..9274d93ec 100644 --- a/test/e2e/ssl/http_redirect.go +++ b/test/e2e/ssl/http_redirect.go @@ -34,9 +34,6 @@ var _ = framework.IngressNginxDescribe("sslredirect", func() { f.NewEchoDeployment() }) - AfterEach(func() { - }) - It("should redirect from HTTP to HTTPS when secret is missing", func() { host := "redirect.com" diff --git a/test/e2e/ssl/secret_update.go b/test/e2e/ssl/secret_update.go index 2184da7bf..407f1548c 100644 --- a/test/e2e/ssl/secret_update.go +++ b/test/e2e/ssl/secret_update.go @@ -39,9 +39,6 @@ var _ = framework.IngressNginxDescribe("SSL", func() { f.NewEchoDeployment() }) - AfterEach(func() { - }) - It("should not appear references to secret updates not used in ingress rules", func() { host := "ssl-update" diff --git a/test/e2e/status/update.go b/test/e2e/status/update.go index 0515a83e6..c744c33cf 100644 --- a/test/e2e/status/update.go +++ b/test/e2e/status/update.go @@ -39,12 +39,6 @@ var _ = framework.IngressNginxDescribe("Status Update [Status]", func() { host := "status-update" address := getHostIP() - BeforeEach(func() { - }) - - AfterEach(func() { - }) - It("should update status field after client-go reconnection", func() { port, cmd, err := f.KubectlProxy(0) Expect(err).NotTo(HaveOccurred(), "unexpected error starting kubectl proxy") diff --git a/test/e2e/tcpudp/tcp.go b/test/e2e/tcpudp/tcp.go index 2855a4982..20e82c7c6 100644 --- a/test/e2e/tcpudp/tcp.go +++ b/test/e2e/tcpudp/tcp.go @@ -37,12 +37,6 @@ import ( var _ = framework.IngressNginxDescribe("TCP Feature", func() { f := framework.NewDefaultFramework("tcp") - BeforeEach(func() { - }) - - AfterEach(func() { - }) - It("should expose a TCP service", func() { f.NewEchoDeploymentWithReplicas(1)