From 5e249d336684dbbe8ceb77545677a78c0655f101 Mon Sep 17 00:00:00 2001 From: Manuel Alejandro de Brito Fontes Date: Fri, 22 Feb 2019 11:03:42 -0300 Subject: [PATCH] Refactor e2e tests to use the service ClusterIP --- .travis.yml | 105 ++++++++-------- Makefile | 41 +++++-- build/build-e2e.sh | 21 ++++ build/e2e-tests.sh | 69 ----------- build/go-in-docker.sh | 5 - test/e2e-image/.gitignore | 3 + test/e2e-image/Dockerfile | 17 +++ test/e2e-image/Makefile | 23 ++++ test/e2e-image/e2e.sh | 61 ++++++++++ .../manifests}/mandatory.yaml | 55 --------- test/e2e-image/manifests/rbac.yaml | 54 +++++++++ .../manifests/service.yaml} | 17 ++- test/e2e-image/wait-for-nginx.sh | 44 +++++++ test/e2e/annotations/affinity.go | 50 ++++---- test/e2e/annotations/alias.go | 10 +- test/e2e/annotations/approot.go | 4 +- test/e2e/annotations/auth.go | 46 +++---- test/e2e/annotations/authtls.go | 22 ++-- test/e2e/annotations/backendprotocol.go | 8 +- test/e2e/annotations/canary.go | 114 +++++++++--------- test/e2e/annotations/clientbodybuffersize.go | 12 +- test/e2e/annotations/connection.go | 4 +- test/e2e/annotations/cors.go | 14 +-- test/e2e/annotations/customhttperrors.go | 6 +- test/e2e/annotations/default_backend.go | 4 +- test/e2e/annotations/forcesslredirect.go | 4 +- test/e2e/annotations/fromtowwwredirect.go | 10 +- test/e2e/annotations/grpc.go | 2 +- test/e2e/annotations/http2pushpreload.go | 2 +- test/e2e/annotations/influxdb.go | 8 +- test/e2e/annotations/ipwhitelist.go | 2 +- test/e2e/annotations/log.go | 4 +- test/e2e/annotations/luarestywaf.go | 24 ++-- test/e2e/annotations/modsecurity.go | 8 +- test/e2e/annotations/proxy.go | 22 ++-- test/e2e/annotations/redirect.go | 8 +- test/e2e/annotations/rewrite.go | 30 ++--- test/e2e/annotations/satisfy.go | 6 +- test/e2e/annotations/serversnippet.go | 2 +- test/e2e/annotations/snippet.go | 2 +- test/e2e/annotations/sslciphers.go | 2 +- test/e2e/annotations/upstreamhashby.go | 6 +- test/e2e/annotations/upstreamvhost.go | 2 +- test/e2e/dbg/main.go | 6 +- .../defaultbackend/custom_default_backend.go | 8 +- test/e2e/defaultbackend/default_backend.go | 4 +- test/e2e/defaultbackend/ssl.go | 4 +- test/e2e/defaultbackend/with_hosts.go | 4 +- test/e2e/e2e_test.go | 9 +- test/e2e/framework/deployment.go | 6 +- test/e2e/framework/exec.go | 2 +- test/e2e/framework/framework.go | 86 +++++-------- test/e2e/framework/grpc_fortune_teller.go | 6 +- test/e2e/framework/influxdb.go | 6 +- test/e2e/framework/k8s.go | 8 +- test/e2e/framework/ssl.go | 17 ++- test/e2e/framework/test_context.go | 9 +- test/e2e/framework/util.go | 27 ++--- test/e2e/gracefulshutdown/slow_requests.go | 4 +- test/e2e/loadbalance/round_robin.go | 4 +- test/e2e/lua/dynamic_certificates.go | 44 +++---- test/e2e/lua/dynamic_configuration.go | 28 ++--- test/e2e/servicebackend/service_backend.go | 8 +- test/e2e/settings/configmap_change.go | 2 +- test/e2e/settings/disable_catch_all.go | 20 +-- test/e2e/settings/forwarded_headers.go | 8 +- test/e2e/settings/geoip2.go | 6 +- test/e2e/settings/global_access_block.go | 16 +-- test/e2e/settings/ingress_class.go | 26 ++-- test/e2e/settings/no_auth_locations.go | 10 +- test/e2e/settings/pod_security_policy.go | 6 +- test/e2e/settings/proxy_host.go | 15 ++- test/e2e/settings/proxy_protocol.go | 9 +- test/e2e/settings/server_tokens.go | 4 +- test/e2e/settings/tls.go | 30 ++--- test/e2e/ssl/secret_update.go | 12 +- test/e2e/status/update.go | 18 +-- test/e2e/tcpudp/tcp.go | 39 +++--- test/e2e/up.sh | 12 +- test/e2e/wait-for-nginx.sh | 7 +- 80 files changed, 777 insertions(+), 706 deletions(-) create mode 100755 build/build-e2e.sh delete mode 100755 build/e2e-tests.sh create mode 100644 test/e2e-image/.gitignore create mode 100644 test/e2e-image/Dockerfile create mode 100644 test/e2e-image/Makefile create mode 100755 test/e2e-image/e2e.sh rename test/{manifests/ingress-controller => e2e-image/manifests}/mandatory.yaml (85%) create mode 100644 test/e2e-image/manifests/rbac.yaml rename test/{manifests/ingress-controller/service-nodeport.yaml => e2e-image/manifests/service.yaml} (53%) create mode 100755 test/e2e-image/wait-for-nginx.sh diff --git a/.travis.yml b/.travis.yml index d0b39a25f..9dfad7dfb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,59 +22,58 @@ notifications: # New secure variables can be added using travis encrypt -r kubernetes/ingress-nginx --add K=V env: global: - - DOCKER=docker - - SKIP_SNAPSHOT=true - - NODE_IP=10.192.0.3 - - E2E_NODES=6 - - GH_REF=github.com/kubernetes/ingress-nginx - - secure: LIS2XpZufWTcJ53jiRsSZy2Gi1EUJ1XmLg7z3f2ZHeMnyG2Jhk3GW4vod1FNru+PY4PWgddLdCdIl+jqOYXndFlbdAWF3/Oy5fEkYLXdYV7tdlHcPWDkqNFrfiyZ4guChN+b2Nk6FqU7o5fsZAIR7VAbgqNRF5XMo9Mhn/vhDCQRcnbXy7uq7JTrYUkqDbQoyYvT6b480GCY5gags1zp/xZfPDNZEe936o8i5IPTyiykRyNOXN/AH6kd3pR5e1xYgcvJ9KpSVPghcwFE7kJ4fOVMRhRG5ML+IyML+xD0jX43EMNoqRKZ/HS42kIMCInFbJEcxVde7DPNBZ7Y3GAqh7HO6qrE70Dn3ha6DID6zCoH2ArW39BxG4zempjn2VxYoMRGREyZszWQb++dwGoHmo5FHt6zvIrYBG0dA0H8ja9VkZkjFwtYTGHU1ooPzUfJK4O4VBayV8LqZibyZQR+GrmyQc0aagUY7J/fe4A2PJyI4DbkeZ7GX1ELj0ciDz4urQSzUc8l/T3aU3X+FuJItjgYtMLPmqcjA5uifDCtutE8Z9L2gSpanqUdvLSOozuxPho/KNl+2YlF7fXqPW3LnRf5mHD+NbOff306pvKlHJOb2Vmth+HBQ1XDzt/Cy5+sfwS3E0Vmh6UTq/NtkUXxwH10BDMF7FMVlQ4zdHQvyZ0= - - secure: rKDoy9IYYYy0fYBs4+9mwuBVq/TcxfFwMfE0ywYWhUUdgzrUYSJAwpoe/96EQ4YmESUefwC2nDNq4G3XzJKYOWf83PaIveb9Z//zmMrCQXjDuDBDLpwV3sXSh7evXiVDohJz4ogBCeMRUCMKYsyKBM9yWfa/iu+yI92dbphpK9peOKW6yBc0uspJlln4swN3GS2WT9LVuPY2Azv9U2UqrXufOPDKG/qEb/Vrn4yZ2lR/50r2k45e9nSvDoByvr10V8ubM5Zc0iP0vBuAUVRdByv6N53Q4gaBGapY6SxhIjIPC/h0rNnuT9EXp7MWaPT5FmBxLt9wnyleT9QhZJnFyaBYqFgcz/DKifYQkryY4M5dLMo/Rt3yATyAy8Y0df1TOoV2dKdqwOOwQ8bXB1wDfyrGxmQj9HY4Ffnphx3wPE1a+Sjuh+S5Epm7XJbPx5pZJqNO2hd4sTbk0Xp3gpPbihny2r/jtNwHl0wpFCfOM68RNrsVRlIwG3UhzbZvblbQ/M/mmWCdgzINjt07I2SGCJxfKG0e98Q49SKUoDoOgQTTRDqTC9IgOEDxyfAkT0Vr6BtlP88Nsgnf6kmboyigBrRAiaDQGTxn3SP6LnQI3CeopaRDYvFZe/rTwPXE9XlKoTn9FTWnAqF3MuWaLslDcDKYEh7OaYJjF01piu6g4Nc= - - secure: qCCk7HIEnOph2q8mQ55MKS2MM0RSpCbwDZx7csF6NHRr5khVRyhg2r8jN0iUW+peoAChRYV91YOnl5v8K49O38IEQpzgADixiLu4VPFcYddwKrtTJF+AGvFGzBKtqDksRuUTqfJ+PdxGnO9iNkS0MFzF1ImSQGp1QfkegC8wSrZF8svAedjNOC9XV+FX0tTyj14eTSy3KUYafIyuhjG+nSjhlQxAI1Tq4EClcTZOzAIYNhkeZ4Gcu1nHPQMTQT5AQgRAhG8i7rNKfghqX8OccKNWUhvFB3eOFFf4dlb02IA2L/b8Fl4NnZpyAWcwF+CBZrzQoFARBE1xIvGfaNa9i6noyrpJ/g+0g7EyKgTsixaQInBmZ7ECVpQkSO+/3leWfwssZs7H4cqy2HeXH6dkE+JUeI0WDjYV7YwdVNoFm8wXszDu+MCQTGXJ4moO4F/jMvY4w+tNo8ISJiNZ/+uQaIlPaijCdwu9FPvAY59lJXORGVHd1Fq2pKkGkNjQVHtu9BH7ufO1fX5a6FtYbclMwm7w9BE5jnJNoP+y8Yq0bVwbGONSUFTyMWCbSCYDsyUPzmaZLkFpZPbnJua5y9c1x0/OYijNizBW0UVQDZauortsTPzwYlZ1J7TywVtpUEoI8CGuUb2QEWh+O/IwrogtiKvFtPrrYakIwV/lr7mO294= - - secure: ZZlcwdr4X2ZeIuA4f5wiT04qNCpSiNQb9d3dITG7MdtxIpiC1mi9rUFAkMDDlNjKumHO82O/a/X4RYKjXny7eixeHl5lgQ++IV9APwvWfsCiREFhiQFspfL+j0d9sZ5I4pfyPC671984We1T4G+ltuMcN3nQdPm3mP4xPT3h0IBQ9iAHonKck0TdLieNZ47vPPB8C8oxbx5NpdW8aSfQJGo3bFGiXNxWWFZ4P7BsMBDrBZaXuh0rAml/0nCJBGohgSqC8h/UObBOHeehEWnF1zzfQPRezHwVkUaMf2+xQtLGhB5rPjFhBKX0C/JZeqDgHEQ0auC2bLbfG5QCYQauy7jCq5kc6XPT7xFxCUd/sS7Wu2gg6KcgFeTE+Rnn4KWFZx2jMP2EPQYP2+LrM/VbfY1HW4QkpIkPVSFBatciuePUnIkEX6+jVM+GEZOhOOEqZ89zwjsGpa2GkFAJrwX/dphXXtn6oS20mLbu1kqocWTbGUJl/fYztTxCdOt/NoH/hiQMxy+TOGFF3Dx85MJiMUOlgk/NbPqUwBn5RbuD71L69vFZZLpU09V4PuablWW8ACQxgp8BMeqLhaLRn/I3r0ntRc8AdQ1xubPlrVWO9DDbhGfj44YPNoLUAC/7QHkRyCbP98Yv2FTXrJFcx9isA2viFx2UxzTsvXcAKHbCSAw= + - DOCKER=docker + - SKIP_SNAPSHOT=true + - GH_REF=github.com/kubernetes/ingress-nginx + - secure: LIS2XpZufWTcJ53jiRsSZy2Gi1EUJ1XmLg7z3f2ZHeMnyG2Jhk3GW4vod1FNru+PY4PWgddLdCdIl+jqOYXndFlbdAWF3/Oy5fEkYLXdYV7tdlHcPWDkqNFrfiyZ4guChN+b2Nk6FqU7o5fsZAIR7VAbgqNRF5XMo9Mhn/vhDCQRcnbXy7uq7JTrYUkqDbQoyYvT6b480GCY5gags1zp/xZfPDNZEe936o8i5IPTyiykRyNOXN/AH6kd3pR5e1xYgcvJ9KpSVPghcwFE7kJ4fOVMRhRG5ML+IyML+xD0jX43EMNoqRKZ/HS42kIMCInFbJEcxVde7DPNBZ7Y3GAqh7HO6qrE70Dn3ha6DID6zCoH2ArW39BxG4zempjn2VxYoMRGREyZszWQb++dwGoHmo5FHt6zvIrYBG0dA0H8ja9VkZkjFwtYTGHU1ooPzUfJK4O4VBayV8LqZibyZQR+GrmyQc0aagUY7J/fe4A2PJyI4DbkeZ7GX1ELj0ciDz4urQSzUc8l/T3aU3X+FuJItjgYtMLPmqcjA5uifDCtutE8Z9L2gSpanqUdvLSOozuxPho/KNl+2YlF7fXqPW3LnRf5mHD+NbOff306pvKlHJOb2Vmth+HBQ1XDzt/Cy5+sfwS3E0Vmh6UTq/NtkUXxwH10BDMF7FMVlQ4zdHQvyZ0= + - secure: rKDoy9IYYYy0fYBs4+9mwuBVq/TcxfFwMfE0ywYWhUUdgzrUYSJAwpoe/96EQ4YmESUefwC2nDNq4G3XzJKYOWf83PaIveb9Z//zmMrCQXjDuDBDLpwV3sXSh7evXiVDohJz4ogBCeMRUCMKYsyKBM9yWfa/iu+yI92dbphpK9peOKW6yBc0uspJlln4swN3GS2WT9LVuPY2Azv9U2UqrXufOPDKG/qEb/Vrn4yZ2lR/50r2k45e9nSvDoByvr10V8ubM5Zc0iP0vBuAUVRdByv6N53Q4gaBGapY6SxhIjIPC/h0rNnuT9EXp7MWaPT5FmBxLt9wnyleT9QhZJnFyaBYqFgcz/DKifYQkryY4M5dLMo/Rt3yATyAy8Y0df1TOoV2dKdqwOOwQ8bXB1wDfyrGxmQj9HY4Ffnphx3wPE1a+Sjuh+S5Epm7XJbPx5pZJqNO2hd4sTbk0Xp3gpPbihny2r/jtNwHl0wpFCfOM68RNrsVRlIwG3UhzbZvblbQ/M/mmWCdgzINjt07I2SGCJxfKG0e98Q49SKUoDoOgQTTRDqTC9IgOEDxyfAkT0Vr6BtlP88Nsgnf6kmboyigBrRAiaDQGTxn3SP6LnQI3CeopaRDYvFZe/rTwPXE9XlKoTn9FTWnAqF3MuWaLslDcDKYEh7OaYJjF01piu6g4Nc= + - secure: qCCk7HIEnOph2q8mQ55MKS2MM0RSpCbwDZx7csF6NHRr5khVRyhg2r8jN0iUW+peoAChRYV91YOnl5v8K49O38IEQpzgADixiLu4VPFcYddwKrtTJF+AGvFGzBKtqDksRuUTqfJ+PdxGnO9iNkS0MFzF1ImSQGp1QfkegC8wSrZF8svAedjNOC9XV+FX0tTyj14eTSy3KUYafIyuhjG+nSjhlQxAI1Tq4EClcTZOzAIYNhkeZ4Gcu1nHPQMTQT5AQgRAhG8i7rNKfghqX8OccKNWUhvFB3eOFFf4dlb02IA2L/b8Fl4NnZpyAWcwF+CBZrzQoFARBE1xIvGfaNa9i6noyrpJ/g+0g7EyKgTsixaQInBmZ7ECVpQkSO+/3leWfwssZs7H4cqy2HeXH6dkE+JUeI0WDjYV7YwdVNoFm8wXszDu+MCQTGXJ4moO4F/jMvY4w+tNo8ISJiNZ/+uQaIlPaijCdwu9FPvAY59lJXORGVHd1Fq2pKkGkNjQVHtu9BH7ufO1fX5a6FtYbclMwm7w9BE5jnJNoP+y8Yq0bVwbGONSUFTyMWCbSCYDsyUPzmaZLkFpZPbnJua5y9c1x0/OYijNizBW0UVQDZauortsTPzwYlZ1J7TywVtpUEoI8CGuUb2QEWh+O/IwrogtiKvFtPrrYakIwV/lr7mO294= + - secure: ZZlcwdr4X2ZeIuA4f5wiT04qNCpSiNQb9d3dITG7MdtxIpiC1mi9rUFAkMDDlNjKumHO82O/a/X4RYKjXny7eixeHl5lgQ++IV9APwvWfsCiREFhiQFspfL+j0d9sZ5I4pfyPC671984We1T4G+ltuMcN3nQdPm3mP4xPT3h0IBQ9iAHonKck0TdLieNZ47vPPB8C8oxbx5NpdW8aSfQJGo3bFGiXNxWWFZ4P7BsMBDrBZaXuh0rAml/0nCJBGohgSqC8h/UObBOHeehEWnF1zzfQPRezHwVkUaMf2+xQtLGhB5rPjFhBKX0C/JZeqDgHEQ0auC2bLbfG5QCYQauy7jCq5kc6XPT7xFxCUd/sS7Wu2gg6KcgFeTE+Rnn4KWFZx2jMP2EPQYP2+LrM/VbfY1HW4QkpIkPVSFBatciuePUnIkEX6+jVM+GEZOhOOEqZ89zwjsGpa2GkFAJrwX/dphXXtn6oS20mLbu1kqocWTbGUJl/fYztTxCdOt/NoH/hiQMxy+TOGFF3Dx85MJiMUOlgk/NbPqUwBn5RbuD71L69vFZZLpU09V4PuablWW8ACQxgp8BMeqLhaLRn/I3r0ntRc8AdQ1xubPlrVWO9DDbhGfj44YPNoLUAC/7QHkRyCbP98Yv2FTXrJFcx9isA2viFx2UxzTsvXcAKHbCSAw= jobs: include: - - stage: Static Check - script: - - make static-check - - stage: Lua Unit Test - script: - - make lua-test - - stage: Coverage - script: - - make cover - - stage: e2e - if: (branch = master AND env(COMPONENT) != "docs") OR (type = pull_request AND commit_message !~ /(skip-e2e)/) - before_script: - - test/e2e/up.sh - script: - - make e2e-test - # split builds to avoid job timeouts - - stage: publish amd64 - if: type = api AND branch = master AND repo = kubernetes/ingress-nginx AND env(COMPONENT) = "ingress-controller" - script: - - .travis/publish.sh amd64 - - stage: publish arm - if: type = api AND branch = master AND repo = kubernetes/ingress-nginx AND env(COMPONENT) = "ingress-controller" - script: - - make register-qemu - - .travis/publish.sh arm - - stage: publish arm64 - if: type = api AND branch = master AND repo = kubernetes/ingress-nginx AND env(COMPONENT) = "ingress-controller" - script: - - make register-qemu - - .travis/publish.sh arm64 - - stage: publish ppc64le - if: type = api AND branch = master AND repo = kubernetes/ingress-nginx AND env(COMPONENT) = "ingress-controller" - script: - - make register-qemu - - .travis/publish.sh ppc64le - - stage: publish s390x - if: type = api AND branch = master AND repo = kubernetes/ingress-nginx AND env(COMPONENT) = "ingress-controller" - script: - - make register-qemu - - .travis/publish.sh s390x - - stage: Publish docs - if: type = api AND branch = master AND repo = kubernetes/ingress-nginx AND env(COMPONENT) = "docs" - script: - - .travis/publish-docs.sh + - stage: Static Check + script: + - make static-check + - stage: Lua Unit Test + script: + - make lua-test + - stage: Coverage + script: + - make cover + - stage: e2e + if: (branch = master AND env(COMPONENT) != "docs") OR (type = pull_request AND commit_message !~ /(skip-e2e)/) + before_script: + - make e2e-test-image + - test/e2e/up.sh + script: + - KUBECONFIG=$(cat /tmp/kubeconfig) make e2e-test + # split builds to avoid job timeouts + - stage: publish amd64 + if: type = api AND branch = master AND repo = kubernetes/ingress-nginx AND env(COMPONENT) = "ingress-controller" + script: + - .travis/publish.sh amd64 + - stage: publish arm + if: type = api AND branch = master AND repo = kubernetes/ingress-nginx AND env(COMPONENT) = "ingress-controller" + script: + - make register-qemu + - .travis/publish.sh arm + - stage: publish arm64 + if: type = api AND branch = master AND repo = kubernetes/ingress-nginx AND env(COMPONENT) = "ingress-controller" + script: + - make register-qemu + - .travis/publish.sh arm64 + - stage: publish ppc64le + if: type = api AND branch = master AND repo = kubernetes/ingress-nginx AND env(COMPONENT) = "ingress-controller" + script: + - make register-qemu + - .travis/publish.sh ppc64le + - stage: publish s390x + if: type = api AND branch = master AND repo = kubernetes/ingress-nginx AND env(COMPONENT) = "ingress-controller" + script: + - make register-qemu + - .travis/publish.sh s390x + - stage: Publish docs + if: type = api AND branch = master AND repo = kubernetes/ingress-nginx AND env(COMPONENT) = "docs" + script: + - .travis/publish-docs.sh diff --git a/Makefile b/Makefile index 9523de136..c89672a26 100644 --- a/Makefile +++ b/Makefile @@ -26,11 +26,9 @@ GOHOSTOS ?= $(shell go env GOHOSTOS) # Allow limiting the scope of the e2e tests. By default run everything FOCUS ?= .* # number of parallel test -E2E_NODES ?= 4 -# slow test only if takes > 40s -SLOW_E2E_THRESHOLD ?= 40 - -NODE_IP ?= $(shell minikube ip) +E2E_NODES ?= 8 +# slow test only if takes > 50s +SLOW_E2E_THRESHOLD ?= 50 ifeq ($(GOHOSTOS),darwin) SED_I=sed -i '' @@ -167,7 +165,6 @@ static-check: .PHONY: test test: @$(DEF_VARS) \ - NODE_IP=$(NODE_IP) \ DOCKER_OPTS="-i --net=host" \ build/go-in-docker.sh build/test.sh @@ -179,13 +176,31 @@ lua-test: .PHONY: e2e-test e2e-test: - @$(DEF_VARS) \ - FOCUS=$(FOCUS) \ - E2E_NODES=$(E2E_NODES) \ - DOCKER_OPTS="-i --net=host" \ - NODE_IP=$(NODE_IP) \ - SLOW_E2E_THRESHOLD=$(SLOW_E2E_THRESHOLD) \ - build/go-in-docker.sh build/e2e-tests.sh + echo "Granting permissions to ingress-nginx e2e service account..." + kubectl create serviceaccount ingress-nginx-e2e || true + kubectl create clusterrolebinding permissive-binding \ + --clusterrole=cluster-admin \ + --user=admin \ + --user=kubelet \ + --serviceaccount=default:ingress-nginx-e2e || true + + kubectl run --rm -i --tty \ + --attach \ + --restart=Never \ + --generator=run-pod/v1 \ + --env="E2E_NODES=$(E2E_NODES)" \ + --env="FOCUS=$(FOCUS)" \ + --env="SLOW_E2E_THRESHOLD=$(SLOW_E2E_THRESHOLD)" \ + --overrides='{ "apiVersion": "v1", "spec":{"serviceAccountName": "ingress-nginx-e2e"}}' \ + e2e --image=nginx-ingress-controller:e2e + +.PHONY: e2e-test-image +e2e-test-image: + @$(DEF_VARS) \ + DOCKER_OPTS="-i --net=host" \ + build/go-in-docker.sh build/build-e2e.sh + + make -C test/e2e-image .PHONY: cover cover: diff --git a/build/build-e2e.sh b/build/build-e2e.sh new file mode 100755 index 000000000..bf73e34c9 --- /dev/null +++ b/build/build-e2e.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# 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. + +set -o errexit +set -o nounset +set -o pipefail + +ginkgo build ./test/e2e diff --git a/build/e2e-tests.sh b/build/e2e-tests.sh deleted file mode 100755 index cdd6f939d..000000000 --- a/build/e2e-tests.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash - -# Copyright 2018 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. - -set -o errexit -set -o nounset -set -o pipefail - -declare -a mandatory -mandatory=( - NODE_IP - SLOW_E2E_THRESHOLD - PKG - FOCUS - E2E_NODES -) - -missing=false -for var in ${mandatory[@]}; do - if [[ -z "${!var+x}" ]]; then - echo "Environment variable $var must be set" - missing=true - fi -done - -if [ "$missing" = true ];then - exit 1 -fi - -SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/.. - -ginkgo build ./test/e2e - -echo "Running e2e test suite..." -ginkgo \ - -randomizeSuites \ - -randomizeAllSpecs \ - -flakeAttempts=2 \ - -focus=${FOCUS} \ - -skip="\[Serial\]" \ - -p \ - -trace \ - -nodes=${E2E_NODES} \ - -slowSpecThreshold=${SLOW_E2E_THRESHOLD} \ - test/e2e/e2e.test - -echo "Running e2e test suite with tests that require serial execution..." -ginkgo \ - -randomizeSuites \ - -randomizeAllSpecs \ - -flakeAttempts=2 \ - -focus="\[Serial\]" \ - -p \ - -trace \ - -nodes=1 \ - -slowSpecThreshold=${SLOW_E2E_THRESHOLD} \ - test/e2e/e2e.test diff --git a/build/go-in-docker.sh b/build/go-in-docker.sh index 64b002cdc..dfb9c2336 100755 --- a/build/go-in-docker.sh +++ b/build/go-in-docker.sh @@ -50,18 +50,13 @@ tee .env << EOF PKG=${PKG:-""} ARCH=${ARCH:-""} GIT_COMMIT=${GIT_COMMIT:-""} -E2E_NODES=${E2E_NODES:-4} -FOCUS=${FOCUS:-.*} TAG=${TAG:-"0.0"} HOME=${HOME:-/root} -KUBECONFIG=${HOME}/.kube/config GOARCH=${GOARCH} GOBUILD_FLAGS=${GOBUILD_FLAGS:-"-v"} PWD=${PWD} BUSTED_ARGS=${BUSTED_ARGS:-""} REPO_INFO=${REPO_INFO:-local} -NODE_IP=${NODE_IP:-127.0.0.1} -SLOW_E2E_THRESHOLD=${SLOW_E2E_THRESHOLD:-40} EOF MINIKUBE_PATH=${HOME}/.minikube diff --git a/test/e2e-image/.gitignore b/test/e2e-image/.gitignore new file mode 100644 index 000000000..811b620e0 --- /dev/null +++ b/test/e2e-image/.gitignore @@ -0,0 +1,3 @@ +e2e.test +ginkgo +kubectl diff --git a/test/e2e-image/Dockerfile b/test/e2e-image/Dockerfile new file mode 100644 index 000000000..593c59c5a --- /dev/null +++ b/test/e2e-image/Dockerfile @@ -0,0 +1,17 @@ +FROM quay.io/kubernetes-ingress-controller/debian-base-amd64:0.1 + +RUN clean-install \ + ca-certificates \ + bash \ + tzdata + +COPY ginkgo /usr/local/bin/ +COPY kubectl /usr/local/bin/ +COPY e2e.sh /e2e.sh + +COPY manifests /manifests + +COPY wait-for-nginx.sh / +COPY e2e.test / + +CMD [ "/e2e.sh" ] diff --git a/test/e2e-image/Makefile b/test/e2e-image/Makefile new file mode 100644 index 000000000..494a21c68 --- /dev/null +++ b/test/e2e-image/Makefile @@ -0,0 +1,23 @@ +IMAGE=nginx-ingress-controller:e2e +KUBE_VERSION ?= 1.13.3 + +.PHONY: all container getbins clean + +all: container + +container: + ./kubectl > /dev/null 2>&1 || curl -Lo ./kubectl \ + https://storage.googleapis.com/kubernetes-release/release/v$(KUBE_VERSION)/bin/linux/amd64/kubectl \ + && chmod +x ./kubectl + + $(GOPATH)/bin/ginkgo > /dev/null 2>&1 || go get github.com/onsi/ginkgo/ginkgo + cp $(GOPATH)/bin/ginkgo . + + cp ../e2e/e2e.test . + cp ../e2e/wait-for-nginx.sh . + + docker build -t $(IMAGE) . + +clean: + rm -rf _cache e2e.test kubectl cluster ginkgo + docker rmi -f $(IMAGE) || true diff --git a/test/e2e-image/e2e.sh b/test/e2e-image/e2e.sh new file mode 100755 index 000000000..1434020c6 --- /dev/null +++ b/test/e2e-image/e2e.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +# 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. + +set -e + +SLOW_E2E_THRESHOLD=${SLOW_E2E_THRESHOLD:-50} +FOCUS=${FOCUS:-.*} +E2E_NODES=${E2E_NODES:-5} + +if [ ! -f ${HOME}/.kube/config ]; then + kubectl config set-cluster dev --certificate-authority=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt --embed-certs=true --server="https://kubernetes.default/" + kubectl config set-credentials user --token="$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" + kubectl config set-context default --cluster=dev --user=user + kubectl config use-context default +fi + +echo "Granting permissions to ingress-nginx e2e service account..." +kubectl create serviceaccount ingress-nginx-e2e || true +kubectl create clusterrolebinding permissive-binding \ +--clusterrole=cluster-admin \ +--user=admin \ +--user=kubelet \ +--serviceaccount=default:ingress-nginx-e2e || true + +kubectl apply -f manifests/rbac.yaml + +ginkgo_args=( + "-randomizeSuites" + "-randomizeAllSpecs" + "-flakeAttempts=2" + "-p" + "-trace" + "--noColor=true" + "-slowSpecThreshold=${SLOW_E2E_THRESHOLD}" +) + +echo "Running e2e test suite..." +ginkgo "${ginkgo_args[@]}" \ + -focus=${FOCUS} \ + -skip="\[Serial\]" \ + -nodes=${E2E_NODES} \ + /e2e.test + +echo "Running e2e test suite with tests that require serial execution..." +ginkgo "${ginkgo_args[@]}" \ + -focus="\[Serial\]" \ + -nodes=1 \ + /e2e.test diff --git a/test/manifests/ingress-controller/mandatory.yaml b/test/e2e-image/manifests/mandatory.yaml similarity index 85% rename from test/manifests/ingress-controller/mandatory.yaml rename to test/e2e-image/manifests/mandatory.yaml index 5ae6489db..02e404d1f 100644 --- a/test/manifests/ingress-controller/mandatory.yaml +++ b/test/e2e-image/manifests/mandatory.yaml @@ -32,61 +32,6 @@ metadata: labels: app.kubernetes.io/name: ingress-nginx app.kubernetes.io/part-of: ingress-nginx ---- -apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: ClusterRole -metadata: - name: nginx-ingress-clusterrole - labels: - app.kubernetes.io/name: ingress-nginx - app.kubernetes.io/part-of: ingress-nginx -rules: - - apiGroups: - - "" - resources: - - configmaps - - endpoints - - nodes - - pods - - secrets - verbs: - - list - - watch - - apiGroups: - - "" - resources: - - nodes - verbs: - - get - - apiGroups: - - "" - resources: - - services - verbs: - - get - - list - - watch - - apiGroups: - - "extensions" - resources: - - ingresses - verbs: - - get - - list - - watch - - apiGroups: - - "" - resources: - - events - verbs: - - create - - patch - - apiGroups: - - "extensions" - resources: - - ingresses/status - verbs: - - update --- apiVersion: rbac.authorization.k8s.io/v1beta1 diff --git a/test/e2e-image/manifests/rbac.yaml b/test/e2e-image/manifests/rbac.yaml new file mode 100644 index 000000000..7f4f79fe8 --- /dev/null +++ b/test/e2e-image/manifests/rbac.yaml @@ -0,0 +1,54 @@ +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRole +metadata: + name: nginx-ingress-clusterrole + labels: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx +rules: + - apiGroups: + - "" + resources: + - configmaps + - endpoints + - nodes + - pods + - secrets + verbs: + - list + - watch + - apiGroups: + - "" + resources: + - nodes + verbs: + - get + - apiGroups: + - "" + resources: + - services + verbs: + - get + - list + - watch + - apiGroups: + - "extensions" + resources: + - ingresses + verbs: + - get + - list + - watch + - apiGroups: + - "" + resources: + - events + verbs: + - create + - patch + - apiGroups: + - "extensions" + resources: + - ingresses/status + verbs: + - update diff --git a/test/manifests/ingress-controller/service-nodeport.yaml b/test/e2e-image/manifests/service.yaml similarity index 53% rename from test/manifests/ingress-controller/service-nodeport.yaml rename to test/e2e-image/manifests/service.yaml index 471b9685d..4226bb0e0 100644 --- a/test/manifests/ingress-controller/service-nodeport.yaml +++ b/test/e2e-image/manifests/service.yaml @@ -3,16 +3,15 @@ kind: Service metadata: name: ingress-nginx spec: - type: NodePort ports: - - name: http - port: 80 - targetPort: 80 - protocol: TCP - - name: https - port: 443 - targetPort: 443 - protocol: TCP + - name: http + port: 80 + targetPort: 80 + protocol: TCP + - name: https + port: 443 + targetPort: 443 + protocol: TCP selector: app.kubernetes.io/name: ingress-nginx app.kubernetes.io/part-of: ingress-nginx diff --git a/test/e2e-image/wait-for-nginx.sh b/test/e2e-image/wait-for-nginx.sh new file mode 100755 index 000000000..250c32c6b --- /dev/null +++ b/test/e2e-image/wait-for-nginx.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Copyright 2017 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. + +set -e +set -x + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +export NAMESPACE=$1 + +echo "deploying NGINX Ingress controller in namespace $NAMESPACE" + +function on_exit { + local error_code="$?" + + test $error_code == 0 && return; + + echo "Obtaining ingress controller pod logs..." + kubectl logs -l app.kubernetes.io/name=ingress-nginx -n $NAMESPACE +} +trap on_exit EXIT + +kubectl apply --f $DIR/manifests/service.yaml +sed "s@\${NAMESPACE}@${NAMESPACE}@" $DIR/manifests/mandatory.yaml | kubectl apply --namespace=$NAMESPACE -f - +cat $DIR/manifests/service.yaml | kubectl apply --namespace=$NAMESPACE -f - + +# wait for the deployment and fail if there is an error before starting the execution of any test +kubectl rollout status \ + --request-timeout=3m \ + --namespace $NAMESPACE \ + deployment nginx-ingress-controller diff --git a/test/e2e/annotations/affinity.go b/test/e2e/annotations/affinity.go index bc65f90eb..ef7a915f7 100644 --- a/test/e2e/annotations/affinity.go +++ b/test/e2e/annotations/affinity.go @@ -51,7 +51,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", "nginx.ingress.kubernetes.io/session-cookie-name": "SERVERID", } - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -61,7 +61,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", time.Sleep(waitForLuaSync) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() @@ -81,7 +81,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", "nginx.ingress.kubernetes.io/session-cookie-name": "SERVERID", } - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -91,7 +91,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", time.Sleep(waitForLuaSync) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() @@ -105,7 +105,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", time.Sleep(waitForLuaSync) resp, _, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() @@ -121,7 +121,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", "nginx.ingress.kubernetes.io/session-cookie-hash": "sha1", } - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -131,7 +131,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", time.Sleep(waitForLuaSync) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() @@ -151,7 +151,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", "nginx.ingress.kubernetes.io/session-cookie-name": "SERVERID", } - ing := framework.NewSingleIngress(host, "/something", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/something", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -161,7 +161,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", time.Sleep(waitForLuaSync) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL+"/something"). + Get(f.GetURL(framework.HTTP)+"/something"). Set("Host", host). End() @@ -180,7 +180,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", f.EnsureIngress(&v1beta1.Ingress{ ObjectMeta: metav1.ObjectMeta{ Name: host, - Namespace: f.IngressController.Namespace, + Namespace: f.Namespace, Annotations: annotations, }, Spec: v1beta1.IngressSpec{ @@ -219,7 +219,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", time.Sleep(waitForLuaSync) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL+"/something"). + Get(f.GetURL(framework.HTTP)+"/something"). Set("Host", host). End() @@ -228,7 +228,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", Expect(resp.Header.Get("Set-Cookie")).Should(ContainSubstring("Path=/something;")) resp, _, errs = gorequest.New(). - Get(f.IngressController.HTTPURL+"/somewhereelese"). + Get(f.GetURL(framework.HTTP)+"/somewhereelese"). Set("Host", host). End() @@ -246,7 +246,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", "nginx.ingress.kubernetes.io/session-cookie-max-age": "259200", } - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -256,15 +256,19 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", time.Sleep(waitForLuaSync) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - local, _ := time.LoadLocation("GMT") + local, err := time.LoadLocation("GMT") + Expect(err).ToNot(HaveOccurred()) + Expect(local).ShouldNot(BeNil()) + duration, _ := time.ParseDuration("48h") expected := time.Now().In(local).Add(duration).Format("Mon, 02-Jan-06 15:04") + Expect(resp.Header.Get("Set-Cookie")).Should(ContainSubstring(fmt.Sprintf("Expires=%s", expected))) Expect(resp.Header.Get("Set-Cookie")).Should(ContainSubstring("Max-Age=259200")) }) @@ -278,7 +282,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", "nginx.ingress.kubernetes.io/session-cookie-path": "/foo/bar", } - ing := framework.NewSingleIngress(host, "/foo/.*", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/foo/.*", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -288,7 +292,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", time.Sleep(waitForLuaSync) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL+"/foo/bar"). + Get(f.GetURL(framework.HTTP)+"/foo/bar"). Set("Host", host). End() @@ -310,7 +314,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", "nginx.ingress.kubernetes.io/use-regex": "true", } - ing := framework.NewSingleIngress(host, "/foo/.*", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/foo/.*", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -320,7 +324,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", time.Sleep(waitForLuaSync) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL+"/foo/bar"). + Get(f.GetURL(framework.HTTP)+"/foo/bar"). Set("Host", host). End() @@ -338,10 +342,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.IngressController.Namespace, "http-svc", 80, &annotations) + ing1 := framework.NewSingleIngress("ingress1", "/foo/bar", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing1) - ing2 := framework.NewSingleIngress("ingress2", "/foo", host, f.IngressController.Namespace, "http-svc", 80, &map[string]string{}) + ing2 := framework.NewSingleIngress("ingress2", "/foo", host, f.Namespace, "http-svc", 80, &map[string]string{}) f.EnsureIngress(ing2) f.WaitForNginxServer(host, @@ -351,7 +355,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", time.Sleep(waitForLuaSync) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL+"/foo"). + Get(f.GetURL(framework.HTTP)+"/foo"). Set("Host", host). End() @@ -360,7 +364,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", Expect(resp.Header.Get("Set-Cookie")).Should(Equal("")) resp, _, errs = gorequest.New(). - Get(f.IngressController.HTTPURL+"/foo/bar"). + Get(f.GetURL(framework.HTTP)+"/foo/bar"). Set("Host", host). End() diff --git a/test/e2e/annotations/alias.go b/test/e2e/annotations/alias.go index f15db1253..96d281a30 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -50,7 +50,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Alias", func() { }) resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() @@ -59,7 +59,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Alias", func() { Expect(body).Should(ContainSubstring(fmt.Sprintf("host=%v", host))) resp, body, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", "bar"). End() @@ -74,7 +74,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Alias", func() { "nginx.ingress.kubernetes.io/server-alias": "bar", } - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -85,7 +85,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Alias", func() { hosts := []string{"foo", "bar"} for _, host := range hosts { resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() diff --git a/test/e2e/annotations/approot.go b/test/e2e/annotations/approot.go index 9a325202d..8d5621b37 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -53,7 +53,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Approot", func() { }) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Retry(10, 1*time.Second, http.StatusNotFound). RedirectPolicy(noRedirectPolicyFunc). Set("Host", host). diff --git a/test/e2e/annotations/auth.go b/test/e2e/annotations/auth.go index 01eb7b638..6a9dec4b4 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.IngressController.Namespace, "http-svc", 80, nil) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -55,7 +55,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { }) resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Retry(10, 1*time.Second, http.StatusNotFound). Set("Host", host). End() @@ -73,7 +73,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { "nginx.ingress.kubernetes.io/auth-realm": "test auth", } - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -82,7 +82,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { }) resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Retry(10, 1*time.Second, http.StatusNotFound). Set("Host", host). End() @@ -95,7 +95,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { It("should return status code 401 when authentication is configured but Authorization header is not configured", func() { host := "auth" - s := f.EnsureSecret(buildSecret("foo", "bar", "test", f.IngressController.Namespace)) + s := f.EnsureSecret(buildSecret("foo", "bar", "test", f.Namespace)) annotations := map[string]string{ "nginx.ingress.kubernetes.io/auth-type": "basic", @@ -103,7 +103,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { "nginx.ingress.kubernetes.io/auth-realm": "test auth", } - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -112,7 +112,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { }) resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Retry(10, 1*time.Second, http.StatusNotFound). Set("Host", host). End() @@ -125,7 +125,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { It("should return status code 401 when authentication is configured and Authorization header is sent with invalid credentials", func() { host := "auth" - s := f.EnsureSecret(buildSecret("foo", "bar", "test", f.IngressController.Namespace)) + s := f.EnsureSecret(buildSecret("foo", "bar", "test", f.Namespace)) annotations := map[string]string{ "nginx.ingress.kubernetes.io/auth-type": "basic", @@ -133,7 +133,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { "nginx.ingress.kubernetes.io/auth-realm": "test auth", } - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -142,7 +142,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { }) resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Retry(10, 1*time.Second, http.StatusNotFound). Set("Host", host). SetBasicAuth("user", "pass"). @@ -156,7 +156,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { It("should return status code 200 when authentication is configured and Authorization header is sent", func() { host := "auth" - s := f.EnsureSecret(buildSecret("foo", "bar", "test", f.IngressController.Namespace)) + s := f.EnsureSecret(buildSecret("foo", "bar", "test", f.Namespace)) annotations := map[string]string{ "nginx.ingress.kubernetes.io/auth-type": "basic", @@ -164,7 +164,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { "nginx.ingress.kubernetes.io/auth-realm": "test auth", } - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -173,7 +173,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { }) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Retry(10, 1*time.Second, http.StatusNotFound). Set("Host", host). SetBasicAuth("foo", "bar"). @@ -190,7 +190,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ Name: "test", - Namespace: f.IngressController.Namespace, + Namespace: f.Namespace, }, Data: map[string][]byte{ // invalid content @@ -206,7 +206,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { "nginx.ingress.kubernetes.io/auth-realm": "test auth", } - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -215,7 +215,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { }) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Retry(10, 1*time.Second, http.StatusNotFound). Set("Host", host). SetBasicAuth("foo", "bar"). @@ -234,7 +234,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { proxy_set_header My-Custom-Header 42;`, } - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -251,7 +251,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { proxy_set_header My-Custom-Header 42;`, } - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -268,10 +268,10 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { var httpbinIP string - err := framework.WaitForEndpoints(f.KubeClientSet, framework.DefaultTimeout, "httpbin", f.IngressController.Namespace, 1) + err := framework.WaitForEndpoints(f.KubeClientSet, framework.DefaultTimeout, "httpbin", f.Namespace, 1) Expect(err).NotTo(HaveOccurred()) - e, err := f.KubeClientSet.CoreV1().Endpoints(f.IngressController.Namespace).Get("httpbin", metav1.GetOptions{}) + e, err := f.KubeClientSet.CoreV1().Endpoints(f.Namespace).Get("httpbin", metav1.GetOptions{}) Expect(err).NotTo(HaveOccurred()) httpbinIP = e.Subsets[0].Addresses[0].IP @@ -281,7 +281,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { "nginx.ingress.kubernetes.io/auth-signin": "http://$host/auth/start", } - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, func(server string) bool { @@ -291,7 +291,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { It("should return status code 200 when signed in", func() { resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Retry(10, 1*time.Second, http.StatusNotFound). Set("Host", host). SetBasicAuth("user", "password"). @@ -305,7 +305,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { It("should redirect to signin url when not signed in", func() { resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Retry(10, 1*time.Second, http.StatusNotFound). Set("Host", host). RedirectPolicy(func(req gorequest.Request, via []gorequest.Request) error { diff --git a/test/e2e/annotations/authtls.go b/test/e2e/annotations/authtls.go index 2c44c3450..e86f25162 100644 --- a/test/e2e/annotations/authtls.go +++ b/test/e2e/annotations/authtls.go @@ -40,7 +40,7 @@ var _ = framework.IngressNginxDescribe("Annotations - AuthTLS", func() { It("should set valid auth-tls-secret", func() { host := "authtls.foo.com" - nameSpace := f.IngressController.Namespace + nameSpace := f.Namespace clientConfig, err := framework.CreateIngressMASecret( f.KubeClientSet, @@ -76,7 +76,7 @@ var _ = framework.IngressNginxDescribe("Annotations - AuthTLS", func() { req := gorequest.New() uri := "/" resp, _, errs := req. - Get(f.IngressController.HTTPSURL+uri). + Get(f.GetURL(framework.HTTPS)+uri). TLSClientConfig(&tls.Config{ServerName: host, InsecureSkipVerify: true}). Set("Host", host). End() @@ -85,7 +85,7 @@ var _ = framework.IngressNginxDescribe("Annotations - AuthTLS", func() { // Send Request Passing the Client Certs resp, _, errs = req. - Get(f.IngressController.HTTPSURL+uri). + Get(f.GetURL(framework.HTTPS)+uri). TLSClientConfig(clientConfig). Set("Host", host). End() @@ -95,7 +95,7 @@ var _ = framework.IngressNginxDescribe("Annotations - AuthTLS", func() { It("should set valid auth-tls-secret, sslVerify to off, and sslVerifyDepth to 2", func() { host := "authtls.foo.com" - nameSpace := f.IngressController.Namespace + nameSpace := f.Namespace _, err := framework.CreateIngressMASecret( f.KubeClientSet, @@ -129,7 +129,7 @@ var _ = framework.IngressNginxDescribe("Annotations - AuthTLS", func() { req := gorequest.New() uri := "/" resp, _, errs := req. - Get(f.IngressController.HTTPSURL+uri). + Get(f.GetURL(framework.HTTPS)+uri). TLSClientConfig(&tls.Config{ServerName: host, InsecureSkipVerify: true}). Set("Host", host). End() @@ -139,7 +139,7 @@ var _ = framework.IngressNginxDescribe("Annotations - AuthTLS", func() { It("should set valid auth-tls-secret, pass certificate to upstream, and error page", func() { host := "authtls.foo.com" - nameSpace := f.IngressController.Namespace + nameSpace := f.Namespace errorPath := "/error" @@ -152,7 +152,7 @@ var _ = framework.IngressNginxDescribe("Annotations - AuthTLS", func() { annotations := map[string]string{ "nginx.ingress.kubernetes.io/auth-tls-secret": nameSpace + "/" + host, - "nginx.ingress.kubernetes.io/auth-tls-error-page": f.IngressController.HTTPURL + errorPath, + "nginx.ingress.kubernetes.io/auth-tls-error-page": f.GetURL(framework.HTTP) + errorPath, "nginx.ingress.kubernetes.io/auth-tls-pass-certificate-to-upstream": "true", } @@ -165,7 +165,7 @@ var _ = framework.IngressNginxDescribe("Annotations - AuthTLS", func() { sslVerify := "ssl_verify_client on;" sslVerifyDepth := "ssl_verify_depth 1;" - sslErrorPage := fmt.Sprintf("error_page 495 496 = %s;", f.IngressController.HTTPURL+errorPath) + sslErrorPage := fmt.Sprintf("error_page 495 496 = %s;", f.GetURL(framework.HTTP)+errorPath) sslUpstreamClientCert := "proxy_set_header ssl-client-cert $ssl_client_escaped_cert;" f.WaitForNginxServer(host, @@ -183,18 +183,18 @@ var _ = framework.IngressNginxDescribe("Annotations - AuthTLS", func() { req := gorequest.New() uri := "/" resp, _, errs := req. - Get(f.IngressController.HTTPSURL+uri). + Get(f.GetURL(framework.HTTPS)+uri). TLSClientConfig(&tls.Config{ServerName: host, InsecureSkipVerify: true}). Set("Host", host). RedirectPolicy(noRedirectPolicyFunc). End() Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusFound)) - Expect(resp.Header.Get("Location")).Should(Equal(f.IngressController.HTTPURL + errorPath)) + Expect(resp.Header.Get("Location")).Should(Equal(f.GetURL(framework.HTTP) + errorPath)) // Send Request Passing the Client Certs resp, _, errs = req. - Get(f.IngressController.HTTPSURL+uri). + Get(f.GetURL(framework.HTTPS)+uri). TLSClientConfig(clientConfig). Set("Host", host). End() diff --git a/test/e2e/annotations/backendprotocol.go b/test/e2e/annotations/backendprotocol.go index 1723e3b87..24b57cd48 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -83,7 +83,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Backendprotocol", func() { "nginx.ingress.kubernetes.io/backend-protocol": "AJP", } - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/canary.go b/test/e2e/annotations/canary.go index 15abcef1a..1c9aa9bac 100644 --- a/test/e2e/annotations/canary.go +++ b/test/e2e/annotations/canary.go @@ -48,7 +48,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { host := "foo" annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -63,14 +63,14 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", 80, &canaryAnnotations) f.EnsureIngress(canaryIng) time.Sleep(waitForLuaSync) resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() @@ -90,7 +90,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", 80, &canaryAnnotations) f.EnsureIngress(canaryIng) @@ -98,7 +98,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { time.Sleep(waitForLuaSync) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("CanaryByHeader", "always"). End() @@ -115,7 +115,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { host := "foo" annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -130,7 +130,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", 80, &canaryAnnotations) f.EnsureIngress(canaryIng) @@ -141,7 +141,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { f.NewEchoDeploymentWithReplicas(0) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("CanaryByHeader", "always"). End() @@ -155,7 +155,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { f.NewDeployment("http-svc-canary", "gcr.io/kubernetes-e2e-test-images/echoserver:2.2", 8080, 0) resp, _, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("CanaryByHeader", "never"). End() @@ -169,7 +169,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { host := "foo" annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -184,7 +184,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", 80, &canaryAnnotations) f.EnsureIngress(canaryIng) @@ -192,7 +192,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { By("routing requests destined for the mainline ingress to the maineline upstream") resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("CanaryByHeader", "never"). End() @@ -205,7 +205,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { By("routing requests destined for the canary ingress to the canary upstream") resp, body, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("CanaryByHeader", "always"). End() @@ -225,7 +225,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", 80, &canaryAnnotations) f.EnsureIngress(canaryIng) @@ -233,7 +233,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -243,7 +243,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { By("routing requests destined for the mainline ingress to the mainelin upstream") resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("CanaryByHeader", "never"). End() @@ -256,7 +256,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { By("routing requests destined for the canary ingress to the canary upstream") resp, body, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("CanaryByHeader", "always"). End() @@ -270,7 +270,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { host := "foo" annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -285,7 +285,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", 80, &canaryAnnotations) f.EnsureIngress(canaryIng) @@ -295,7 +295,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { "foo": "bar", } - modIng := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &modAnnotations) + modIng := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &modAnnotations) f.EnsureIngress(modIng) @@ -307,7 +307,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { By("routing requests destined fro the mainline ingress to the mainline upstream") resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("CanaryByHeader", "never"). End() @@ -320,7 +320,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { By("routing requests destined for the canary ingress to the canary upstream") resp, body, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("CanaryByHeader", "always"). End() @@ -334,7 +334,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { host := "foo" annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -349,7 +349,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", 80, &canaryAnnotations) f.EnsureIngress(canaryIng) @@ -360,7 +360,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { "nginx.ingress.kubernetes.io/canary-by-header": "CanaryByHeader2", } - modCanaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary", 80, &modCanaryAnnotations) + modCanaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", 80, &modCanaryAnnotations) f.EnsureIngress(modCanaryIng) time.Sleep(waitForLuaSync) @@ -368,7 +368,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { By("routing requests destined for the mainline ingress to the mainline upstream") resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("CanaryByHeader2", "never"). End() @@ -381,7 +381,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { By("routing requests destined for the canary ingress to the canary upstream") resp, body, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("CanaryByHeader2", "always"). End() @@ -397,7 +397,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { host := "foo" annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -412,7 +412,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", 80, &canaryAnnotations) f.EnsureIngress(canaryIng) @@ -421,7 +421,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { By("routing requests to the canary upstream when header is set to 'always'") resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("CanaryByHeader", "always"). End() @@ -433,7 +433,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { By("routing requests to the mainline upstream when header is set to 'never'") resp, body, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("CanaryByHeader", "never"). End() @@ -446,7 +446,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { By("routing requests to the mainline upstream when header is set to anything else") resp, body, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("CanaryByHeader", "badheadervalue"). End() @@ -463,7 +463,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { host := "foo" annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -479,7 +479,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", 80, &canaryAnnotations) f.EnsureIngress(canaryIng) @@ -488,7 +488,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { By("routing requests to the canary upstream when header is set to 'DoCanary'") resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("CanaryByHeader", "DoCanary"). End() @@ -500,7 +500,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { By("routing requests to the mainline upstream when header is set to 'always'") resp, body, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("CanaryByHeader", "always"). End() @@ -513,7 +513,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { By("routing requests to the mainline upstream when header is set to 'never'") resp, body, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("CanaryByHeader", "never"). End() @@ -526,7 +526,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { By("routing requests to the mainline upstream when header is set to anything else") resp, body, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("CanaryByHeader", "otherheadervalue"). End() @@ -543,7 +543,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { host := "foo" annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -560,7 +560,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", 80, &canaryAnnotations) f.EnsureIngress(canaryIng) @@ -568,7 +568,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { By("routing requests to the canary upstream when header value does not match and cookie is set to 'always'") resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("CanaryByHeader", "otherheadervalue"). AddCookie(&http.Cookie{Name: "CanaryByCookie", Value: "always"}). @@ -585,7 +585,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { host := "foo" annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -600,7 +600,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", 80, &canaryAnnotations) f.EnsureIngress(canaryIng) @@ -608,7 +608,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { By("routing requests to the canary upstream when cookie is set to 'always'") resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). AddCookie(&http.Cookie{Name: "Canary-By-Cookie", Value: "always"}). End() @@ -620,7 +620,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { By("routing requests to the mainline upstream when cookie is set to 'never'") resp, body, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). AddCookie(&http.Cookie{Name: "Canary-By-Cookie", Value: "never"}). End() @@ -633,7 +633,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { By("routing requests to the mainline upstream when cookie is set to anything else") resp, body, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). AddCookie(&http.Cookie{Name: "Canary-By-Cookie", Value: "badcookievalue"}). End() @@ -651,7 +651,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { host := "foo" annotations := map[string]string{} - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -666,7 +666,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { canaryIngName := fmt.Sprintf("%v-canary", host) - canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary", + canaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", 80, &canaryAnnotations) f.EnsureIngress(canaryIng) @@ -675,7 +675,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { By("returning requests from the mainline only when weight is equal to 0") resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() @@ -691,14 +691,14 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { "nginx.ingress.kubernetes.io/canary-weight": "100", } - modCanaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary", 80, &modCanaryAnnotations) + modCanaryIng := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", 80, &modCanaryAnnotations) f.EnsureIngress(modCanaryIng) time.Sleep(waitForLuaSync) resp, body, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() @@ -718,16 +718,16 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { "nginx.ingress.kubernetes.io/canary-by-header": "CanaryByHeader", } - ing := framework.NewSingleCatchAllIngress(canaryIngName, f.IngressController.Namespace, "http-svc-canary", 80, &annotations) + ing := framework.NewSingleCatchAllIngress(canaryIngName, f.Namespace, "http-svc-canary", 80, &annotations) f.EnsureIngress(ing) - ing = framework.NewSingleCatchAllIngress(host, f.IngressController.Namespace, "http-svc", 80, nil) + ing = framework.NewSingleCatchAllIngress(host, f.Namespace, "http-svc", 80, nil) f.EnsureIngress(ing) f.WaitForNginxServer("_", func(server string) bool { - upstreamName := fmt.Sprintf(`set $proxy_upstream_name "%s-%s-%s";`, f.IngressController.Namespace, "http-svc", "80") - canaryUpstreamName := fmt.Sprintf(`set $proxy_upstream_name "%s-%s-%s";`, f.IngressController.Namespace, "http-svc-canary", "80") + upstreamName := fmt.Sprintf(`set $proxy_upstream_name "%s-%s-%s";`, f.Namespace, "http-svc", "80") + canaryUpstreamName := fmt.Sprintf(`set $proxy_upstream_name "%s-%s-%s";`, f.Namespace, "http-svc-canary", "80") return Expect(server).Should(ContainSubstring(`set $ingress_name "`+host+`";`)) && Expect(server).ShouldNot(ContainSubstring(`set $proxy_upstream_name "upstream-default-backend";`)) && Expect(server).ShouldNot(ContainSubstring(canaryUpstreamName)) && @@ -743,11 +743,11 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() { "nginx.ingress.kubernetes.io/canary-by-header": "CanaryByHeader", } - ing := framework.NewSingleIngress(canaryIngName, "/", host, f.IngressController.Namespace, "http-svc-canary", 80, &annotations) + ing := framework.NewSingleIngress(canaryIngName, "/", host, f.Namespace, "http-svc-canary", 80, &annotations) f.EnsureIngress(ing) otherHost := "bar" - ing = framework.NewSingleIngress(otherHost, "/", otherHost, f.IngressController.Namespace, "http-svc", 80, nil) + ing = framework.NewSingleIngress(otherHost, "/", otherHost, f.Namespace, "http-svc", 80, nil) f.EnsureIngress(ing) time.Sleep(waitForLuaSync) diff --git a/test/e2e/annotations/clientbodybuffersize.go b/test/e2e/annotations/clientbodybuffersize.go index 621deb65d..cfaa664e1 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/connection.go b/test/e2e/annotations/connection.go index 6ca77cce7..5becd22ac 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -52,7 +52,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Connection", func() { }) resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Retry(10, 1*time.Second, http.StatusNotFound). Set("Host", host). End() diff --git a/test/e2e/annotations/cors.go b/test/e2e/annotations/cors.go index 4fb4c9d4f..ec1c5560e 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -72,7 +72,7 @@ var _ = framework.IngressNginxDescribe("Annotations - CORS", func() { uri := "/" resp, _, errs := gorequest.New(). - Options(f.IngressController.HTTPURL+uri). + Options(f.GetURL(framework.HTTP)+uri). Set("Host", host). End() Expect(errs).Should(BeEmpty()) @@ -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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/customhttperrors.go b/test/e2e/annotations/customhttperrors.go index f74a430bd..fa376a93e 100644 --- a/test/e2e/annotations/customhttperrors.go +++ b/test/e2e/annotations/customhttperrors.go @@ -47,7 +47,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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) var serverConfig string @@ -70,7 +70,7 @@ var _ = framework.IngressNginxDescribe("Annotations - custom-http-errors", func( } By("updating configuration when only custom-http-error value changes") - err := framework.UpdateIngress(f.KubeClientSet, f.IngressController.Namespace, host, func(ingress *extensions.Ingress) error { + err := framework.UpdateIngress(f.KubeClientSet, f.Namespace, host, func(ingress *extensions.Ingress) error { ingress.ObjectMeta.Annotations["nginx.ingress.kubernetes.io/custom-http-errors"] = "503" return nil }) @@ -88,7 +88,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.IngressController.Namespace, "http-svc", 80, &annotations) + ing = framework.NewSingleIngress(fmt.Sprintf("%s-else", host), "/else", host, f.Namespace, "http-svc", 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 0d105c386..d2806e0da 100644 --- a/test/e2e/annotations/default_backend.go +++ b/test/e2e/annotations/default_backend.go @@ -42,7 +42,7 @@ var _ = framework.IngressNginxDescribe("Annotations - custom default-backend", f "nginx.ingress.kubernetes.io/default-backend": "http-svc", } - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "invalid", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "invalid", 80, &annotations) f.EnsureIngress(ing) time.Sleep(5 * time.Second) @@ -54,7 +54,7 @@ var _ = framework.IngressNginxDescribe("Annotations - custom default-backend", f uri := "/alma/armud" resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL+uri). + Get(f.GetURL(framework.HTTP)+uri). Set("Host", host). End() diff --git a/test/e2e/annotations/forcesslredirect.go b/test/e2e/annotations/forcesslredirect.go index a7ec4635c..759e5392c 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -53,7 +53,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Forcesslredirect", func() }) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Retry(10, 1*time.Second, http.StatusNotFound). RedirectPolicy(noRedirectPolicyFunc). Set("Host", host). diff --git a/test/e2e/annotations/fromtowwwredirect.go b/test/e2e/annotations/fromtowwwredirect.go index 4aaa5909b..d415549d1 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxConfiguration( @@ -59,7 +59,7 @@ var _ = framework.IngressNginxDescribe("Annotations - from-to-www-redirect", fun By("sending request to www.fromtowwwredirect.bar.com") resp, _, errs := gorequest.New(). - Get(fmt.Sprintf("%s/%s", f.IngressController.HTTPURL, "foo")). + Get(fmt.Sprintf("%s/%s", f.GetURL(framework.HTTP), "foo")). Retry(10, 1*time.Second, http.StatusNotFound). RedirectPolicy(noRedirectPolicyFunc). Set("Host", fmt.Sprintf("%s.%s", "www", host)). @@ -78,7 +78,7 @@ var _ = framework.IngressNginxDescribe("Annotations - from-to-www-redirect", fun "nginx.ingress.kubernetes.io/from-to-www-redirect": "true", } - ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host, fmt.Sprintf("www.%v", host)}, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host, fmt.Sprintf("www.%v", host)}, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) _, err := framework.CreateIngressTLSSecret(f.KubeClientSet, @@ -90,7 +90,7 @@ var _ = framework.IngressNginxDescribe("Annotations - from-to-www-redirect", fun f.WaitForNginxServer(fmt.Sprintf("www.%v", host), func(server string) bool { return Expect(server).Should(ContainSubstring(`server_name www.fromtowwwredirect.bar.com;`)) && - Expect(server).Should(ContainSubstring(fmt.Sprintf("/etc/ingress-controller/ssl/%v-fromtowwwredirect.bar.com.pem", f.IngressController.Namespace))) && + Expect(server).Should(ContainSubstring(fmt.Sprintf("/etc/ingress-controller/ssl/%v-fromtowwwredirect.bar.com.pem", f.Namespace))) && Expect(server).Should(ContainSubstring(`return 308 $scheme://fromtowwwredirect.bar.com$request_uri;`)) }) @@ -103,7 +103,7 @@ var _ = framework.IngressNginxDescribe("Annotations - from-to-www-redirect", fun InsecureSkipVerify: true, ServerName: h, }). - Get(f.IngressController.HTTPSURL). + Get(f.GetURL(framework.HTTPS)). Retry(10, 1*time.Second, http.StatusNotFound). RedirectPolicy(noRedirectPolicyFunc). Set("host", h). diff --git a/test/e2e/annotations/grpc.go b/test/e2e/annotations/grpc.go index b3c317cab..bb3c894af 100644 --- a/test/e2e/annotations/grpc.go +++ b/test/e2e/annotations/grpc.go @@ -40,7 +40,7 @@ var _ = framework.IngressNginxDescribe("Annotations - grpc", func() { "nginx.ingress.kubernetes.io/backend-protocol": "GRPC", } - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "fortune-teller", 50051, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "fortune-teller", 50051, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/http2pushpreload.go b/test/e2e/annotations/http2pushpreload.go index 66211e77f..5ba7212b1 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/influxdb.go b/test/e2e/annotations/influxdb.go index efd572c31..23917b6b8 100644 --- a/test/e2e/annotations/influxdb.go +++ b/test/e2e/annotations/influxdb.go @@ -67,7 +67,7 @@ var _ = framework.IngressNginxDescribe("Annotations - influxdb", func() { // Do a request to the echo server ingress that sends metrics // to the InfluxDB backend. res, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() @@ -103,7 +103,7 @@ func createInfluxDBService(f *framework.Framework) *corev1.Service { service := &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: "inflxudb-svc", - Namespace: f.IngressController.Namespace, + Namespace: f.Namespace, }, Spec: corev1.ServiceSpec{Ports: []corev1.ServicePort{ { @@ -123,7 +123,7 @@ func createInfluxDBService(f *framework.Framework) *corev1.Service { } func createInfluxDBIngress(f *framework.Framework, host, service string, port int, annotations map[string]string) { - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, service, port, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, service, port, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -133,7 +133,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.IngressController.Namespace).List(metav1.ListOptions{ + l, err := f.KubeClientSet.CoreV1().Pods(f.Namespace).List(metav1.ListOptions{ LabelSelector: "app=influxdb-svc", }) if err != nil { diff --git a/test/e2e/annotations/ipwhitelist.go b/test/e2e/annotations/ipwhitelist.go index 79125cff8..321ca236d 100644 --- a/test/e2e/annotations/ipwhitelist.go +++ b/test/e2e/annotations/ipwhitelist.go @@ -37,7 +37,7 @@ var _ = framework.IngressNginxDescribe("Annotations - IPWhiteList", func() { It("should set valid ip whitelist range", func() { host := "ipwhitelist.foo.com" - nameSpace := f.IngressController.Namespace + nameSpace := f.Namespace annotations := map[string]string{ "nginx.ingress.kubernetes.io/whitelist-source-range": "18.0.0.0/8, 56.0.0.0/8", diff --git a/test/e2e/annotations/log.go b/test/e2e/annotations/log.go index 9ae77ad51..068f953bd 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/luarestywaf.go b/test/e2e/annotations/luarestywaf.go index b4c2dcbdd..aaeda0c59 100644 --- a/test/e2e/annotations/luarestywaf.go +++ b/test/e2e/annotations/luarestywaf.go @@ -40,7 +40,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() { host := "foo" createIngress(f, host, "http-svc", 80, map[string]string{"nginx.ingress.kubernetes.io/lua-resty-waf": "active"}) - url := fmt.Sprintf("%s?msg=XSS", f.IngressController.HTTPURL) + url := fmt.Sprintf("%s?msg=XSS", f.GetURL(framework.HTTP)) resp, _, errs := gorequest.New(). Get(url). Set("Host", host). @@ -55,7 +55,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() { "nginx.ingress.kubernetes.io/lua-resty-waf": "active", "nginx.ingress.kubernetes.io/lua-resty-waf-ignore-rulesets": "41000_sqli, 42000_xss"}) - url := fmt.Sprintf("%s?msg=XSS", f.IngressController.HTTPURL) + url := fmt.Sprintf("%s?msg=XSS", f.GetURL(framework.HTTP)) resp, _, errs := gorequest.New(). Get(url). Set("Host", host). @@ -70,7 +70,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() { "nginx.ingress.kubernetes.io/lua-resty-waf": "active", "nginx.ingress.kubernetes.io/lua-resty-waf-score-threshold": "20"}) - url := fmt.Sprintf("%s?msg=XSS", f.IngressController.HTTPURL) + url := fmt.Sprintf("%s?msg=XSS", f.GetURL(framework.HTTP)) resp, _, errs := gorequest.New(). Get(url). Set("Host", host). @@ -86,7 +86,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() { "nginx.ingress.kubernetes.io/lua-resty-waf-allow-unknown-content-types": "true", "nginx.ingress.kubernetes.io/lua-resty-waf": "active"}) - url := fmt.Sprintf("%s?msg=my-message", f.IngressController.HTTPURL) + url := fmt.Sprintf("%s?msg=my-message", f.GetURL(framework.HTTP)) resp, _, errs := gorequest.New(). Get(url). Set("Host", host). @@ -103,7 +103,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() { "nginx.ingress.kubernetes.io/lua-resty-waf-process-multipart-body": "false", "nginx.ingress.kubernetes.io/lua-resty-waf": "active"}) - url := fmt.Sprintf("%s?msg=my-message", f.IngressController.HTTPURL) + url := fmt.Sprintf("%s?msg=my-message", f.GetURL(framework.HTTP)) resp, _, errs := gorequest.New(). Get(url). Set("Host", host). @@ -119,7 +119,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() { createIngress(f, host, "http-svc", 80, map[string]string{ "nginx.ingress.kubernetes.io/lua-resty-waf": "active"}) - url := fmt.Sprintf("%s?msg=my-message", f.IngressController.HTTPURL) + url := fmt.Sprintf("%s?msg=my-message", f.GetURL(framework.HTTP)) resp, _, errs := gorequest.New(). Get(url). Set("Host", host). @@ -148,7 +148,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() { ]=]`, }) - url := fmt.Sprintf("%s?msg=my-message", f.IngressController.HTTPURL) + url := fmt.Sprintf("%s?msg=my-message", f.GetURL(framework.HTTP)) resp, _, errs := gorequest.New(). Get(url). Set("Host", host). @@ -157,7 +157,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() { Expect(len(errs)).Should(Equal(0)) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - url = fmt.Sprintf("%s?msg=my-foo-message", f.IngressController.HTTPURL) + url = fmt.Sprintf("%s?msg=my-foo-message", f.GetURL(framework.HTTP)) resp, _, errs = gorequest.New(). Get(url). Set("Host", host). @@ -172,7 +172,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() { host := "foo" createIngress(f, host, "http-svc", 80, map[string]string{}) - url := fmt.Sprintf("%s?msg=XSS", f.IngressController.HTTPURL) + url := fmt.Sprintf("%s?msg=XSS", f.GetURL(framework.HTTP)) resp, _, errs := gorequest.New(). Get(url). Set("Host", host). @@ -185,7 +185,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() { host := "foo" createIngress(f, host, "http-svc", 80, map[string]string{"nginx.ingress.kubernetes.io/lua-resty-waf": "simulate"}) - url := fmt.Sprintf("%s?msg=XSS", f.IngressController.HTTPURL) + url := fmt.Sprintf("%s?msg=XSS", f.GetURL(framework.HTTP)) resp, _, errs := gorequest.New(). Get(url). Set("Host", host). @@ -203,7 +203,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() { }) func createIngress(f *framework.Framework, host, service string, port int, annotations map[string]string) { - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, service, port, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, service, port, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -214,7 +214,7 @@ func createIngress(f *framework.Framework, host, service string, port int, annot time.Sleep(1 * time.Second) resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() diff --git a/test/e2e/annotations/modsecurity.go b/test/e2e/annotations/modsecurity.go index 0024f4b4c..60343f644 100644 --- a/test/e2e/annotations/modsecurity.go +++ b/test/e2e/annotations/modsecurity.go @@ -35,7 +35,7 @@ var _ = framework.IngressNginxDescribe("Annotations - ModSecurityLocation", func It("should enable modsecurity", func() { host := "modsecurity.foo.com" - nameSpace := f.IngressController.Namespace + nameSpace := f.Namespace annotations := map[string]string{ "nginx.ingress.kubernetes.io/enable-modsecurity": "true", @@ -53,7 +53,7 @@ var _ = framework.IngressNginxDescribe("Annotations - ModSecurityLocation", func It("should enable modsecurity with transaction ID and OWASP rules", func() { host := "modsecurity.foo.com" - nameSpace := f.IngressController.Namespace + nameSpace := f.Namespace annotations := map[string]string{ "nginx.ingress.kubernetes.io/enable-modsecurity": "true", @@ -74,7 +74,7 @@ var _ = framework.IngressNginxDescribe("Annotations - ModSecurityLocation", func It("should disable modsecurity", func() { host := "modsecurity.foo.com" - nameSpace := f.IngressController.Namespace + nameSpace := f.Namespace annotations := map[string]string{ "nginx.ingress.kubernetes.io/enable-modsecurity": "false", @@ -91,7 +91,7 @@ var _ = framework.IngressNginxDescribe("Annotations - ModSecurityLocation", func It("should enable modsecurity with snippet", func() { host := "modsecurity.foo.com" - nameSpace := f.IngressController.Namespace + nameSpace := f.Namespace annotations := map[string]string{ "nginx.ingress.kubernetes.io/enable-modsecurity": "true", diff --git a/test/e2e/annotations/proxy.go b/test/e2e/annotations/proxy.go index f6169f4a3..73dfd408f 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -151,7 +151,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() { "nginx.ingress.kubernetes.io/proxy-buffer-size": "8k", } - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -168,7 +168,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() { "nginx.ingress.kubernetes.io/proxy-request-buffering": "off", } - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -183,7 +183,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() { "nginx.ingress.kubernetes.io/proxy-next-upstream-tries": "5", } - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -199,7 +199,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Proxy", func() { "nginx.ingress.kubernetes.io/proxy-cookie-path": "/one/ /", } - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/redirect.go b/test/e2e/annotations/redirect.go index 563c24778..7e6171ba8 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, redirectPath, host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -64,7 +64,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Redirect", func() { By("sending request to redirected URL path") resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL+redirectPath). + Get(f.GetURL(framework.HTTP)+redirectPath). Set("Host", host). RedirectPolicy(noRedirectPolicyFunc). End() @@ -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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, redirectPath, host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -100,7 +100,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Redirect", func() { By("sending request to redirected URL path") resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL+redirectPath). + Get(f.GetURL(framework.HTTP)+redirectPath). Set("Host", host). RedirectPolicy(noRedirectPolicyFunc). End() diff --git a/test/e2e/annotations/rewrite.go b/test/e2e/annotations/rewrite.go index a0ed9ed25..c5137a34c 100644 --- a/test/e2e/annotations/rewrite.go +++ b/test/e2e/annotations/rewrite.go @@ -47,7 +47,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { "nginx.ingress.kubernetes.io/enable-rewrite-log": "true", } - ing := framework.NewSingleIngress(host, "/something", host, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/something", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -56,7 +56,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { }) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL+"/something"). + Get(f.GetURL(framework.HTTP)+"/something"). Set("Host", host). End() @@ -73,7 +73,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.IngressController.Namespace, "http-svc", 80, &map[string]string{}) + ing := framework.NewSingleIngress("kube-lego", "/.well-known/acme/challenge", host, f.Namespace, "http-svc", 80, &map[string]string{}) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -83,7 +83,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { By("making a request to the non-rewritten location") resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL+"/.well-known/acme/challenge"). + 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) @@ -95,7 +95,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.IngressController.Namespace, "http-svc", 80, &annotations) + rewriteIng := framework.NewSingleIngress("rewrite-index", "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(rewriteIng) @@ -106,7 +106,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { By("making a second request to the non-rewritten location") resp, body, errs = gorequest.New(). - Get(f.IngressController.HTTPURL+"/.well-known/acme/challenge"). + Get(f.GetURL(framework.HTTP)+"/.well-known/acme/challenge"). Set("Host", host). End() Expect(len(errs)).Should(Equal(0)) @@ -118,7 +118,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { host := "rewrite.bar.com" By("creating a regular ingress definition") - ing := framework.NewSingleIngress("foo", "/foo", host, f.IngressController.Namespace, "http-svc", 80, &map[string]string{}) + ing := framework.NewSingleIngress("foo", "/foo", host, f.Namespace, "http-svc", 80, &map[string]string{}) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -131,7 +131,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.IngressController.Namespace, "http-svc", 80, &annotations) + ing = framework.NewSingleIngress("regex", "/foo.+", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -141,7 +141,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { By("ensuring '/foo' matches '~* ^/foo'") resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL+"/foo"). + Get(f.GetURL(framework.HTTP)+"/foo"). Set("Host", host). End() expectBodyRequestURI := fmt.Sprintf("request_uri=http://%v:8080/foo", host) @@ -151,7 +151,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { By("ensuring '/foo/bar' matches '~* ^/foo.+'") resp, body, errs = gorequest.New(). - Get(f.IngressController.HTTPURL+"/foo/bar"). + Get(f.GetURL(framework.HTTP)+"/foo/bar"). Set("Host", host). End() expectBodyRequestURI = fmt.Sprintf("request_uri=http://%v:8080/new/backend", host) @@ -164,7 +164,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.IngressController.Namespace, "http-svc", 80, &map[string]string{}) + ing := framework.NewSingleIngress("foo", "/foo/bar/bar", host, f.Namespace, "http-svc", 80, &map[string]string{}) f.EnsureIngress(ing) By(`creating an ingress definition with the use-regex annotation`) @@ -172,7 +172,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.IngressController.Namespace, "http-svc", 80, &annotations) + ing = framework.NewSingleIngress("regex", "/foo/bar/[a-z]{3}", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -182,7 +182,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { By("check that '/foo/bar/bar' does not match the longest exact path") resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL+"/foo/bar/bar"). + Get(f.GetURL(framework.HTTP)+"/foo/bar/bar"). Set("Host", host). End() expectBodyRequestURI := fmt.Sprintf("request_uri=http://%v:8080/new/backend", host) @@ -199,7 +199,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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress("regex", "/foo/bar/(.+)", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -209,7 +209,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Rewrite", func() { By("check that '/foo/bar/bar' redirects to cusotm rewrite") resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL+"/foo/bar/bar"). + Get(f.GetURL(framework.HTTP)+"/foo/bar/bar"). Set("Host", host). End() expectBodyRequestURI := fmt.Sprintf("request_uri=http://%v:8080/new/backend/bar", host) diff --git a/test/e2e/annotations/satisfy.go b/test/e2e/annotations/satisfy.go index ded4a77b9..faf80d252 100644 --- a/test/e2e/annotations/satisfy.go +++ b/test/e2e/annotations/satisfy.go @@ -58,11 +58,11 @@ var _ = framework.IngressNginxDescribe("Annotations - SATISFY", func() { annotationKey: "all", } - ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &initAnnotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &initAnnotations) f.EnsureIngress(ing) for key, result := range results { - err := framework.UpdateIngress(f.KubeClientSet, f.IngressController.Namespace, host, func(ingress *extensions.Ingress) error { + err := framework.UpdateIngress(f.KubeClientSet, f.Namespace, host, func(ingress *extensions.Ingress) error { ingress.ObjectMeta.Annotations[annotationKey] = annotations[key] return nil }) @@ -74,7 +74,7 @@ var _ = framework.IngressNginxDescribe("Annotations - SATISFY", func() { }) resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Retry(10, 1*time.Second, http.StatusNotFound). Set("Host", host). End() diff --git a/test/e2e/annotations/serversnippet.go b/test/e2e/annotations/serversnippet.go index 90bb36a25..6995d6c22 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/snippet.go b/test/e2e/annotations/snippet.go index 1686fb37b..13da543ae 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/sslciphers.go b/test/e2e/annotations/sslciphers.go index 859444022..5ea01f57b 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/something", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/annotations/upstreamhashby.go b/test/e2e/annotations/upstreamhashby.go index b893c5d33..59c2c765e 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.IngressController.Namespace, "http-svc", 80, annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, func(server string) bool { @@ -42,7 +42,7 @@ func startIngress(f *framework.Framework, annotations *map[string]string) map[st err := wait.PollImmediate(framework.Poll, framework.DefaultTimeout, func() (bool, error) { resp, _, _ := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() if resp.StatusCode == http.StatusOK { @@ -57,7 +57,7 @@ func startIngress(f *framework.Framework, annotations *map[string]string) map[st for i := 0; i < 100; i++ { _, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() diff --git a/test/e2e/annotations/upstreamvhost.go b/test/e2e/annotations/upstreamvhost.go index ae5789425..594eca9d1 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/dbg/main.go b/test/e2e/dbg/main.go index 2d252440e..55dfe3a77 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxConfiguration(func(cfg string) bool { @@ -88,7 +88,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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 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 c2104b415..02319f612 100644 --- a/test/e2e/defaultbackend/custom_default_backend.go +++ b/test/e2e/defaultbackend/custom_default_backend.go @@ -37,12 +37,12 @@ var _ = framework.IngressNginxDescribe("Dynamic Certificate", func() { BeforeEach(func() { f.NewEchoDeploymentWithReplicas(1) - framework.UpdateDeployment(f.KubeClientSet, f.IngressController.Namespace, "nginx-ingress-controller", 1, + framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 1, func(deployment *appsv1beta1.Deployment) error { args := deployment.Spec.Template.Spec.Containers[0].Args - args = append(args, fmt.Sprintf("--default-backend-service=%s/%s", f.IngressController.Namespace, "http-svc")) + args = append(args, fmt.Sprintf("--default-backend-service=%s/%s", f.Namespace, "http-svc")) deployment.Spec.Template.Spec.Containers[0].Args = args - _, err := f.KubeClientSet.AppsV1beta1().Deployments(f.IngressController.Namespace).Update(deployment) + _, err := f.KubeClientSet.AppsV1beta1().Deployments(f.Namespace).Update(deployment) return err }) @@ -54,7 +54,7 @@ var _ = framework.IngressNginxDescribe("Dynamic Certificate", func() { }) It("uses custom default backend", func() { - resp, _, errs := gorequest.New().Get(f.IngressController.HTTPURL).End() + resp, _, errs := gorequest.New().Get(f.GetURL(framework.HTTP)).End() Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) }) diff --git a/test/e2e/defaultbackend/default_backend.go b/test/e2e/defaultbackend/default_backend.go index 3e4b6b87b..a218738ac 100644 --- a/test/e2e/defaultbackend/default_backend.go +++ b/test/e2e/defaultbackend/default_backend.go @@ -76,9 +76,9 @@ var _ = framework.IngressNginxDescribe("Default backend", func() { switch test.Scheme { case framework.HTTP: - cm = request.CustomMethod(test.Method, f.IngressController.HTTPURL) + cm = request.CustomMethod(test.Method, f.GetURL(framework.HTTP)) case framework.HTTPS: - cm = request.CustomMethod(test.Method, f.IngressController.HTTPSURL) + cm = request.CustomMethod(test.Method, f.GetURL(framework.HTTPS)) // the default backend uses a self generated certificate cm.Transport = &http.Transport{ TLSClientConfig: &tls.Config{ diff --git a/test/e2e/defaultbackend/ssl.go b/test/e2e/defaultbackend/ssl.go index 80f2be185..685aa3a3e 100644 --- a/test/e2e/defaultbackend/ssl.go +++ b/test/e2e/defaultbackend/ssl.go @@ -38,7 +38,7 @@ var _ = framework.IngressNginxDescribe("Default backend - SSL", func() { It("should return a self generated SSL certificate", func() { By("checking SSL Certificate using the NGINX IP address") resp, _, errs := gorequest.New(). - Post(f.IngressController.HTTPSURL). + Post(f.GetURL(framework.HTTPS)). TLSClientConfig(&tls.Config{ // the default backend uses a self generated certificate InsecureSkipVerify: true, @@ -53,7 +53,7 @@ var _ = framework.IngressNginxDescribe("Default backend - SSL", func() { By("checking SSL Certificate using the NGINX catch all server") resp, _, errs = gorequest.New(). - Post(f.IngressController.HTTPSURL). + Post(f.GetURL(framework.HTTPS)). TLSClientConfig(&tls.Config{ // the default backend uses a self generated certificate InsecureSkipVerify: true, diff --git a/test/e2e/defaultbackend/with_hosts.go b/test/e2e/defaultbackend/with_hosts.go index c9aeee503..3d19c213b 100644 --- a/test/e2e/defaultbackend/with_hosts.go +++ b/test/e2e/defaultbackend/with_hosts.go @@ -47,7 +47,7 @@ var _ = framework.IngressNginxDescribe("Default backend with hosts", func() { ing := &extensions.Ingress{ ObjectMeta: metav1.ObjectMeta{ Name: "default-backend-annotations", - Namespace: f.IngressController.Namespace, + Namespace: f.Namespace, Annotations: annotations, }, Spec: extensions.IngressSpec{ @@ -71,7 +71,7 @@ var _ = framework.IngressNginxDescribe("Default backend with hosts", func() { }) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", "foo.com"). End() diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index a9cc45315..f7546229b 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -19,18 +19,15 @@ package e2e import ( "testing" - "k8s.io/client-go/tools/clientcmd" - "k8s.io/klog" - "k8s.io/ingress-nginx/test/e2e/framework" ) func init() { framework.RegisterParseFlags() - if "" == framework.TestContext.KubeConfig { - klog.Fatalf("environment variable %v must be set", clientcmd.RecommendedConfigPathEnvVar) - } + // if "" == framework.TestContext.KubeConfig { + // klog.Fatalf("environment variable %v must be set", clientcmd.RecommendedConfigPathEnvVar) + // } } func TestE2E(t *testing.T) { RunE2ETests(t) diff --git a/test/e2e/framework/deployment.go b/test/e2e/framework/deployment.go index 9380102dc..2884da3fe 100644 --- a/test/e2e/framework/deployment.go +++ b/test/e2e/framework/deployment.go @@ -71,7 +71,7 @@ func (f *Framework) NewDeployment(name, image string, port int32, replicas int32 deployment := &extensions.Deployment{ ObjectMeta: metav1.ObjectMeta{ Name: name, - Namespace: f.IngressController.Namespace, + Namespace: f.Namespace, }, Spec: extensions.DeploymentSpec{ Replicas: NewInt32(replicas), @@ -115,7 +115,7 @@ func (f *Framework) NewDeployment(name, image string, port int32, replicas int32 service := &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: name, - Namespace: f.IngressController.Namespace, + Namespace: f.Namespace, }, Spec: corev1.ServiceSpec{ Ports: []corev1.ServicePort{ @@ -135,6 +135,6 @@ 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") - err = WaitForEndpoints(f.KubeClientSet, DefaultTimeout, name, f.IngressController.Namespace, int(replicas)) + err = WaitForEndpoints(f.KubeClientSet, DefaultTimeout, name, f.Namespace, int(replicas)) Expect(err).NotTo(HaveOccurred(), "failed to wait for endpoints to become ready") } diff --git a/test/e2e/framework/exec.go b/test/e2e/framework/exec.go index 302a524aa..1da7f586b 100644 --- a/test/e2e/framework/exec.go +++ b/test/e2e/framework/exec.go @@ -30,7 +30,7 @@ import ( // ExecIngressPod executes a command inside the first container in ingress controller running pod func (f *Framework) ExecIngressPod(command string) (string, error) { - pod, err := getIngressNGINXPod(f.IngressController.Namespace, f.KubeClientSet) + pod, err := getIngressNGINXPod(f.Namespace, f.KubeClientSet) if err != nil { return "", err } diff --git a/test/e2e/framework/framework.go b/test/e2e/framework/framework.go index 8bafdc4c6..cbdb454ef 100644 --- a/test/e2e/framework/framework.go +++ b/test/e2e/framework/framework.go @@ -15,7 +15,6 @@ package framework import ( "fmt" - "os" "strings" "time" @@ -65,13 +64,6 @@ type Framework struct { // should abort, the AfterSuite hook should run all Cleanup actions. cleanupHandle CleanupActionHandle - IngressController *ingressController -} - -type ingressController struct { - HTTPURL string - HTTPSURL string - Namespace string } @@ -93,7 +85,11 @@ func (f *Framework) BeforeEach() { f.cleanupHandle = AddCleanupAction(f.AfterEach) By("Creating a kubernetes client") - kubeConfig, err := LoadConfig(TestContext.KubeConfig, TestContext.KubeContext) + kubeConfig, err := restclient.InClusterConfig() + if err != nil { + panic(err.Error()) + } + Expect(err).NotTo(HaveOccurred()) f.KubeConfig = kubeConfig @@ -104,25 +100,17 @@ func (f *Framework) BeforeEach() { ingressNamespace, err := CreateKubeNamespace(f.BaseName, f.KubeClientSet) Expect(err).NotTo(HaveOccurred()) - f.IngressController = &ingressController{ - Namespace: ingressNamespace, - } + f.Namespace = ingressNamespace By("Starting new ingress controller") - err = f.NewIngressController(f.IngressController.Namespace) + err = f.NewIngressController(f.Namespace) Expect(err).NotTo(HaveOccurred()) - err = WaitForPodsReady(f.KubeClientSet, DefaultTimeout, 1, f.IngressController.Namespace, metav1.ListOptions{ + err = WaitForPodsReady(f.KubeClientSet, DefaultTimeout, 1, f.Namespace, metav1.ListOptions{ LabelSelector: "app.kubernetes.io/name=ingress-nginx", }) Expect(err).NotTo(HaveOccurred()) - HTTPURL := f.GetNginxURL(HTTP) - f.IngressController.HTTPURL = HTTPURL - - HTTPSURL := f.GetNginxURL(HTTPS) - f.IngressController.HTTPSURL = HTTPSURL - // we wait for any change in the informers and SSL certificate generation time.Sleep(5 * time.Second) } @@ -132,7 +120,7 @@ func (f *Framework) AfterEach() { RemoveCleanupAction(f.cleanupHandle) By("Waiting for test namespace to no longer exist") - err := DeleteKubeNamespace(f.KubeClientSet, f.IngressController.Namespace) + err := DeleteKubeNamespace(f.KubeClientSet, f.Namespace) Expect(err).NotTo(HaveOccurred()) if CurrentGinkgoTestDescription().Failed { @@ -148,52 +136,34 @@ func IngressNginxDescribe(text string, body func()) bool { return Describe("[nginx-ingress] "+text, body) } -// GetNginxIP returns the IP address of the minikube cluster -// where the NGINX ingress controller is running +// GetNginxIP returns the number of TCP port where NGINX is running func (f *Framework) GetNginxIP() string { - nodeIP := os.Getenv("NODE_IP") - Expect(nodeIP).NotTo(BeEmpty(), "env variable NODE_IP is empty") - return nodeIP -} - -// GetNginxPort returns the number of TCP port where NGINX is running -func (f *Framework) GetNginxPort(name string) (int, error) { s, err := f.KubeClientSet. CoreV1(). - Services(f.IngressController.Namespace). + Services(f.Namespace). Get("ingress-nginx", metav1.GetOptions{}) - if err != nil { - return -1, err - } - - for _, p := range s.Spec.Ports { - if p.NodePort != 0 && p.Name == name { - return int(p.NodePort), nil - } - } - - return -1, err + Expect(err).NotTo(HaveOccurred(), "unexpected error obtaning NGINX IP address") + return s.Spec.ClusterIP } -// GetNginxURL returns the URL should be used to make a request to NGINX -func (f *Framework) GetNginxURL(scheme RequestScheme) string { +// GetURL returns the URL should be used to make a request to NGINX +func (f *Framework) GetURL(scheme RequestScheme) string { ip := f.GetNginxIP() - port, err := f.GetNginxPort(fmt.Sprintf("%v", scheme)) - Expect(err).NotTo(HaveOccurred(), "unexpected error obtaning NGINX Port") - - return fmt.Sprintf("%v://%v:%v", scheme, ip, port) + return fmt.Sprintf("%v://%v", scheme, ip) } // 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, time.Minute*5, f.matchNginxConditions(name, matcher)) + err := wait.Poll(Poll, DefaultTimeout, f.matchNginxConditions(name, matcher)) Expect(err).NotTo(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, time.Minute*5, f.matchNginxConditions("", matcher)) + err := wait.Poll(Poll, DefaultTimeout, f.matchNginxConditions("", matcher)) Expect(err).NotTo(HaveOccurred(), "unexpected error waiting for nginx server condition/s") + time.Sleep(5 * time.Second) } func nginxLogs(client kubernetes.Interface, namespace string) (string, error) { @@ -211,14 +181,14 @@ func nginxLogs(client kubernetes.Interface, namespace string) (string, error) { // NginxLogs returns the logs of the nginx ingress controller pod running func (f *Framework) NginxLogs() (string, error) { - return nginxLogs(f.KubeClientSet, f.IngressController.Namespace) + return nginxLogs(f.KubeClientSet, f.Namespace) } func (f *Framework) matchNginxConditions(name string, matcher func(cfg string) bool) wait.ConditionFunc { return func() (bool, error) { - pod, err := getIngressNGINXPod(f.IngressController.Namespace, f.KubeClientSet) + pod, err := getIngressNGINXPod(f.Namespace, f.KubeClientSet) if err != nil { - return false, err + return false, nil } var cmd string @@ -230,7 +200,7 @@ func (f *Framework) matchNginxConditions(name string, matcher func(cfg string) b o, err := f.ExecCommand(pod, cmd) if err != nil { - return false, err + return false, nil } var match bool @@ -264,7 +234,7 @@ func (f *Framework) getNginxConfigMap() (*v1.ConfigMap, error) { config, err := f.KubeClientSet. CoreV1(). - ConfigMaps(f.IngressController.Namespace). + ConfigMaps(f.Namespace). Get("nginx-configuration", metav1.GetOptions{}) if err != nil { return nil, err @@ -298,7 +268,7 @@ func (f *Framework) SetNginxConfigMapData(cmData map[string]string) { _, err = f.KubeClientSet. CoreV1(). - ConfigMaps(f.IngressController.Namespace). + ConfigMaps(f.Namespace). Update(config) Expect(err).NotTo(HaveOccurred()) @@ -318,14 +288,14 @@ func (f *Framework) UpdateNginxConfigMapData(key string, value string) { // DeleteNGINXPod deletes the currently running pod. It waits for the replacement pod to be up. // Grace period to wait for pod shutdown is in seconds. func (f *Framework) DeleteNGINXPod(grace int64) { - ns := f.IngressController.Namespace + ns := f.Namespace pod, err := getIngressNGINXPod(ns, f.KubeClientSet) Expect(err).NotTo(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") - err = wait.Poll(Poll, time.Minute*5, func() (bool, error) { + err = wait.Poll(Poll, DefaultTimeout, func() (bool, error) { pod, err := getIngressNGINXPod(ns, f.KubeClientSet) if err != nil || pod == nil { return false, nil diff --git a/test/e2e/framework/grpc_fortune_teller.go b/test/e2e/framework/grpc_fortune_teller.go index e6b28ad06..2293ddf5f 100644 --- a/test/e2e/framework/grpc_fortune_teller.go +++ b/test/e2e/framework/grpc_fortune_teller.go @@ -38,7 +38,7 @@ func (f *Framework) NewNewGRPCFortuneTellerDeploymentWithReplicas(replicas int32 deployment := &extensions.Deployment{ ObjectMeta: metav1.ObjectMeta{ Name: "fortune-teller", - Namespace: f.IngressController.Namespace, + Namespace: f.Namespace, }, Spec: extensions.DeploymentSpec{ Replicas: NewInt32(replicas), @@ -77,7 +77,7 @@ func (f *Framework) NewNewGRPCFortuneTellerDeploymentWithReplicas(replicas int32 Expect(err).NotTo(HaveOccurred()) Expect(d).NotTo(BeNil(), "expected a fortune-teller deployment") - err = WaitForPodsReady(f.KubeClientSet, DefaultTimeout, int(replicas), f.IngressController.Namespace, metav1.ListOptions{ + err = WaitForPodsReady(f.KubeClientSet, DefaultTimeout, int(replicas), f.Namespace, metav1.ListOptions{ LabelSelector: fields.SelectorFromSet(fields.Set(d.Spec.Template.ObjectMeta.Labels)).String(), }) Expect(err).NotTo(HaveOccurred(), "failed to wait for to become ready") @@ -85,7 +85,7 @@ func (f *Framework) NewNewGRPCFortuneTellerDeploymentWithReplicas(replicas int32 service := &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: "fortune-teller", - Namespace: f.IngressController.Namespace, + Namespace: f.Namespace, }, Spec: corev1.ServiceSpec{ Ports: []corev1.ServicePort{ diff --git a/test/e2e/framework/influxdb.go b/test/e2e/framework/influxdb.go index d34df549b..dfb441a66 100644 --- a/test/e2e/framework/influxdb.go +++ b/test/e2e/framework/influxdb.go @@ -61,7 +61,7 @@ func (f *Framework) NewInfluxDBDeployment() { configuration := &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Name: "influxdb-config", - Namespace: f.IngressController.Namespace, + Namespace: f.Namespace, }, Data: map[string]string{ "influxd.conf": influxConfig, @@ -76,7 +76,7 @@ func (f *Framework) NewInfluxDBDeployment() { deployment := &extensions.Deployment{ ObjectMeta: metav1.ObjectMeta{ Name: "influxdb-svc", - Namespace: f.IngressController.Namespace, + Namespace: f.Namespace, }, Spec: extensions.DeploymentSpec{ Replicas: NewInt32(1), @@ -140,7 +140,7 @@ func (f *Framework) NewInfluxDBDeployment() { Expect(d).NotTo(BeNil(), "unexpected error creating deployement for influxdb") - err = WaitForPodsReady(f.KubeClientSet, DefaultTimeout, 1, f.IngressController.Namespace, metav1.ListOptions{ + err = WaitForPodsReady(f.KubeClientSet, DefaultTimeout, 1, f.Namespace, metav1.ListOptions{ LabelSelector: fields.SelectorFromSet(fields.Set(d.Spec.Template.ObjectMeta.Labels)).String(), }) Expect(err).NotTo(HaveOccurred(), "failed to wait for influxdb to become ready") diff --git a/test/e2e/framework/k8s.go b/test/e2e/framework/k8s.go index f9e4425be..de0acd06a 100644 --- a/test/e2e/framework/k8s.go +++ b/test/e2e/framework/k8s.go @@ -124,7 +124,7 @@ func WaitForPodsReady(kubeClientSet kubernetes.Interface, timeout time.Duration, return wait.Poll(2*time.Second, timeout, func() (bool, error) { pl, err := kubeClientSet.CoreV1().Pods(namespace).List(opts) if err != nil { - return false, err + return false, nil } r := 0 @@ -150,11 +150,11 @@ func WaitForEndpoints(kubeClientSet kubernetes.Interface, timeout time.Duration, return wait.Poll(2*time.Second, timeout, func() (bool, error) { endpoint, err := kubeClientSet.CoreV1().Endpoints(ns).Get(name, metav1.GetOptions{}) if k8sErrors.IsNotFound(err) { - return false, err + return false, nil } Expect(err).NotTo(HaveOccurred()) if len(endpoint.Subsets) == 0 || len(endpoint.Subsets[0].Addresses) == 0 { - return false, err + return false, nil } r := 0 @@ -191,7 +191,7 @@ func getIngressNGINXPod(ns string, kubeClientSet kubernetes.Interface) (*core.Po LabelSelector: "app.kubernetes.io/name=ingress-nginx", }) if err != nil { - return nil, err + return nil, nil } if len(l.Items) == 0 { diff --git a/test/e2e/framework/ssl.go b/test/e2e/framework/ssl.go index cdfad461b..35fcb755e 100644 --- a/test/e2e/framework/ssl.go +++ b/test/e2e/framework/ssl.go @@ -34,7 +34,7 @@ import ( . "github.com/onsi/gomega" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/kubernetes" @@ -338,19 +338,24 @@ func tlsConfig(serverName string, pemCA []byte) (*tls.Config, error) { // given URL using the given TLS configuration and returns whether the TLS // handshake completed successfully. func matchTLSServerName(url string, tlsConfig *tls.Config) wait.ConditionFunc { - return func() (ready bool, err error) { + return func() (bool, error) { u, err := net_url.Parse(url) if err != nil { - return + return false, err } - conn, err := tls.Dial("tcp", u.Host, tlsConfig) + port := u.Port() + if port == "" { + port = "443" + } + + conn, err := tls.Dial("tcp", fmt.Sprintf("%v:%v", u.Host, port), tlsConfig) if err != nil { + Logf("Unexpected TLS error: %v", err) return false, nil } conn.Close() - ready = true - return + return true, nil } } diff --git a/test/e2e/framework/test_context.go b/test/e2e/framework/test_context.go index 17ba4ef7e..d91540cfc 100644 --- a/test/e2e/framework/test_context.go +++ b/test/e2e/framework/test_context.go @@ -18,17 +18,14 @@ package framework import ( "flag" - "os" "github.com/onsi/ginkgo/config" - - "k8s.io/client-go/tools/clientcmd" ) // TestContextType describes the client context to use in communications with the Kubernetes API. type TestContextType struct { - KubeHost string - KubeConfig string + KubeHost string + //KubeConfig string KubeContext string } @@ -51,7 +48,7 @@ func RegisterCommonFlags() { config.DefaultReporterConfig.SlowSpecThreshold = 20 flag.StringVar(&TestContext.KubeHost, "kubernetes-host", "http://127.0.0.1:8080", "The kubernetes host, or apiserver, to connect to") - flag.StringVar(&TestContext.KubeConfig, "kubernetes-config", os.Getenv(clientcmd.RecommendedConfigPathEnvVar), "Path to config containing embedded authinfo for kubernetes. Default value is from environment variable "+clientcmd.RecommendedConfigPathEnvVar) + //flag.StringVar(&TestContext.KubeConfig, "kubernetes-config", os.Getenv(clientcmd.RecommendedConfigPathEnvVar), "Path to config containing embedded authinfo for kubernetes. Default value is from environment variable "+clientcmd.RecommendedConfigPathEnvVar) flag.StringVar(&TestContext.KubeContext, "kubernetes-context", "", "config context to use for kubernetes. If unset, will use value from 'current-context'") } diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index 986729f55..2b7025d96 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -23,13 +23,12 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/uuid" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/kubernetes" - "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/tools/clientcmd/api" "k8s.io/ingress-nginx/internal/file" @@ -37,10 +36,10 @@ import ( const ( // Poll how often to poll for conditions - Poll = 2 * time.Second + Poll = 3 * time.Second // DefaultTimeout time to wait for operations to complete - DefaultTimeout = 5 * time.Minute + DefaultTimeout = 3 * time.Minute ) func nowStamp() string { @@ -87,15 +86,6 @@ func RestclientConfig(config, context string) (*api.Config, error) { return c, nil } -// LoadConfig deserializes the contents of a kubeconfig file into a REST configuration. -func LoadConfig(config, context string) (*rest.Config, error) { - c, err := RestclientConfig(config, context) - if err != nil { - return nil, err - } - return clientcmd.NewDefaultClientConfig(*c, &clientcmd.ConfigOverrides{}).ClientConfig() -} - // RunID unique identifier of the e2e run var RunID = uuid.NewUUID() @@ -109,8 +99,9 @@ func CreateKubeNamespace(baseName string, c kubernetes.Interface) (string, error } // Be robust about making the namespace creation call. var got *v1.Namespace - err := wait.PollImmediate(Poll, DefaultTimeout, func() (bool, error) { - var err error + var err error + + err = wait.PollImmediate(Poll, DefaultTimeout, func() (bool, error) { got, err = c.CoreV1().Namespaces().Create(ns) if err != nil { Logf("Unexpected error while creating namespace: %v", err) @@ -200,7 +191,7 @@ func secretInNamespace(c kubernetes.Interface, namespace, name string) wait.Cond return func() (bool, error) { s, err := c.CoreV1().Secrets(namespace).Get(name, metav1.GetOptions{}) if apierrors.IsNotFound(err) { - return false, err + return false, nil } if err != nil { return false, err @@ -268,7 +259,7 @@ func ingressInNamespace(c kubernetes.Interface, namespace, name string) wait.Con return func() (bool, error) { ing, err := c.ExtensionsV1beta1().Ingresses(namespace).Get(name, metav1.GetOptions{}) if apierrors.IsNotFound(err) { - return false, err + return false, nil } if err != nil { return false, err @@ -285,7 +276,7 @@ func podRunning(c kubernetes.Interface, podName, namespace string) wait.Conditio return func() (bool, error) { pod, err := c.CoreV1().Pods(namespace).Get(podName, metav1.GetOptions{}) if err != nil { - return false, err + return false, nil } switch pod.Status.Phase { case v1.PodRunning: diff --git a/test/e2e/gracefulshutdown/slow_requests.go b/test/e2e/gracefulshutdown/slow_requests.go index b98a77ee5..793881b96 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.IngressController.Namespace, "slowecho", 8080, nil)) + f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, "slowecho", 8080, nil)) f.WaitForNginxConfiguration( func(conf string) bool { return strings.Contains(conf, "worker_shutdown_timeout") @@ -49,7 +49,7 @@ var _ = framework.IngressNginxDescribe("Graceful Shutdown - Slow Requests", func defer func() { done <- true }() defer GinkgoRecover() resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL+"/sleep/30"). + Get(f.GetURL(framework.HTTP)+"/sleep/30"). Set("Host", host). End() Expect(errs).To(BeNil()) diff --git a/test/e2e/loadbalance/round_robin.go b/test/e2e/loadbalance/round_robin.go index aee6579c5..e64abbc13 100644 --- a/test/e2e/loadbalance/round_robin.go +++ b/test/e2e/loadbalance/round_robin.go @@ -43,7 +43,7 @@ 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.IngressController.Namespace, "http-svc", 80, nil)) + f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil)) f.WaitForNginxServer(host, func(server string) bool { return strings.Contains(server, "server_name load-balance.com") @@ -54,7 +54,7 @@ var _ = framework.IngressNginxDescribe("Load Balance - Round Robin", func() { for i := 0; i < 600; i++ { _, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() Expect(errs).Should(BeEmpty()) diff --git a/test/e2e/lua/dynamic_certificates.go b/test/e2e/lua/dynamic_certificates.go index 4e28ef356..88c901639 100644 --- a/test/e2e/lua/dynamic_certificates.go +++ b/test/e2e/lua/dynamic_certificates.go @@ -36,13 +36,13 @@ var _ = framework.IngressNginxDescribe("Dynamic Certificate", func() { host := "foo.com" BeforeEach(func() { - err := framework.UpdateDeployment(f.KubeClientSet, f.IngressController.Namespace, "nginx-ingress-controller", 1, + err := framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 1, func(deployment *appsv1beta1.Deployment) error { args := deployment.Spec.Template.Spec.Containers[0].Args args = append(args, "--enable-dynamic-certificates") args = append(args, "--enable-ssl-chain-completion=false") deployment.Spec.Template.Spec.Containers[0].Args = args - _, err := f.KubeClientSet.AppsV1beta1().Deployments(f.IngressController.Namespace).Update(deployment) + _, err := f.KubeClientSet.AppsV1beta1().Deployments(f.Namespace).Update(deployment) return err }) @@ -59,7 +59,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") - ing, err := f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.IngressController.Namespace).Get(host, metav1.GetOptions{}) + ing, err := f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.Namespace).Get(host, metav1.GetOptions{}) Expect(err).ToNot(HaveOccurred()) ing.Spec.TLS = []extensions.IngressTLS{ { @@ -72,20 +72,20 @@ var _ = framework.IngressNginxDescribe("Dynamic Certificate", func() { ing.Spec.TLS[0].SecretName, ing.Namespace) Expect(err).ToNot(HaveOccurred()) - _, err = f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.IngressController.Namespace).Update(ing) + _, err = f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.Namespace).Update(ing) Expect(err).ToNot(HaveOccurred()) time.Sleep(waitForLuaSync) - ensureHTTPSRequest(f.IngressController.HTTPSURL, host, host) + ensureHTTPSRequest(f.GetURL(framework.HTTPS), host, host) }) It("picks up the previously missing secret for a given ingress without reloading", func() { - ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.IngressController.Namespace, "http-svc", 80, nil) + ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "http-svc", 80, nil) f.EnsureIngress(ing) time.Sleep(waitForLuaSync) - ensureHTTPSRequest(fmt.Sprintf("%s?id=dummy_log_splitter_foo_bar", f.IngressController.HTTPSURL), host, "ingress.local") + ensureHTTPSRequest(fmt.Sprintf("%s?id=dummy_log_splitter_foo_bar", f.GetURL(framework.HTTPS)), host, "ingress.local") _, err := framework.CreateIngressTLSSecret(f.KubeClientSet, ing.Spec.TLS[0].Hosts, @@ -105,7 +105,7 @@ var _ = framework.IngressNginxDescribe("Dynamic Certificate", func() { time.Sleep(waitForLuaSync) By("serving the configured certificate on HTTPS endpoint") - ensureHTTPSRequest(f.IngressController.HTTPSURL, host, host) + ensureHTTPSRequest(f.GetURL(framework.HTTPS), host, host) log, err := f.NginxLogs() Expect(err).ToNot(HaveOccurred()) @@ -120,11 +120,11 @@ 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.IngressController.Namespace, "http-svc", 80, nil)) + ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "http-svc", 80, nil)) time.Sleep(waitForLuaSync) - ensureHTTPSRequest(f.IngressController.HTTPSURL, host, "ingress.local") + ensureHTTPSRequest(f.GetURL(framework.HTTPS), host, "ingress.local") _, err := framework.CreateIngressTLSSecret(f.KubeClientSet, ing.Spec.TLS[0].Hosts, @@ -145,14 +145,14 @@ var _ = framework.IngressNginxDescribe("Dynamic Certificate", func() { time.Sleep(waitForLuaSync) By("serving the configured certificate on HTTPS endpoint") - ensureHTTPSRequest(f.IngressController.HTTPSURL, host, host) + ensureHTTPSRequest(f.GetURL(framework.HTTPS), host, host) }) It("picks up the updated certificate without reloading", func() { - ing, err := f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.IngressController.Namespace).Get(host, metav1.GetOptions{}) + ing, err := f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.Namespace).Get(host, metav1.GetOptions{}) Expect(err).ToNot(HaveOccurred()) - ensureHTTPSRequest(fmt.Sprintf("%s?id=dummy_log_splitter_foo_bar", f.IngressController.HTTPSURL), host, host) + ensureHTTPSRequest(fmt.Sprintf("%s?id=dummy_log_splitter_foo_bar", f.GetURL(framework.HTTPS)), host, host) _, err = framework.CreateIngressTLSSecret(f.KubeClientSet, ing.Spec.TLS[0].Hosts, @@ -173,7 +173,7 @@ var _ = framework.IngressNginxDescribe("Dynamic Certificate", func() { time.Sleep(waitForLuaSync) By("serving the configured certificate on HTTPS endpoint") - ensureHTTPSRequest(f.IngressController.HTTPSURL, host, host) + ensureHTTPSRequest(f.GetURL(framework.HTTPS), host, host) log, err := f.NginxLogs() Expect(err).ToNot(HaveOccurred()) @@ -187,9 +187,9 @@ var _ = framework.IngressNginxDescribe("Dynamic Certificate", func() { }) It("falls back to using default certificate when secret gets deleted without reloading", func() { - ing, err := f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.IngressController.Namespace).Get(host, metav1.GetOptions{}) + ing, err := f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.Namespace).Get(host, metav1.GetOptions{}) - ensureHTTPSRequest(fmt.Sprintf("%s?id=dummy_log_splitter_foo_bar", f.IngressController.HTTPSURL), host, host) + ensureHTTPSRequest(fmt.Sprintf("%s?id=dummy_log_splitter_foo_bar", f.GetURL(framework.HTTPS)), host, host) f.KubeClientSet.CoreV1().Secrets(ing.Namespace).Delete(ing.Spec.TLS[0].SecretName, nil) Expect(err).ToNot(HaveOccurred()) @@ -207,7 +207,7 @@ var _ = framework.IngressNginxDescribe("Dynamic Certificate", func() { time.Sleep(waitForLuaSync) By("serving the default certificate on HTTPS endpoint") - ensureHTTPSRequest(f.IngressController.HTTPSURL, host, "ingress.local") + ensureHTTPSRequest(f.GetURL(framework.HTTPS), host, "ingress.local") log, err := f.NginxLogs() Expect(err).ToNot(HaveOccurred()) @@ -222,22 +222,22 @@ var _ = framework.IngressNginxDescribe("Dynamic Certificate", func() { It("picks up a non-certificate only change", func() { newHost := "foo2.com" - ing, err := f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.IngressController.Namespace).Get(host, metav1.GetOptions{}) + ing, err := f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.Namespace).Get(host, metav1.GetOptions{}) Expect(err).NotTo(HaveOccurred()) ing.Spec.Rules[0].Host = newHost - _, err = f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.IngressController.Namespace).Update(ing) + _, err = f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.Namespace).Update(ing) Expect(err).ToNot(HaveOccurred()) time.Sleep(waitForLuaSync) By("serving the configured certificate on HTTPS endpoint") - ensureHTTPSRequest(f.IngressController.HTTPSURL, newHost, "ingress.local") + ensureHTTPSRequest(f.GetURL(framework.HTTPS), newHost, "ingress.local") }) It("removes HTTPS configuration when we delete TLS spec", func() { - ing, err := f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.IngressController.Namespace).Get(host, metav1.GetOptions{}) + ing, err := f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.Namespace).Get(host, metav1.GetOptions{}) Expect(err).NotTo(HaveOccurred()) ing.Spec.TLS = []extensions.IngressTLS{} - _, err = f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.IngressController.Namespace).Update(ing) + _, err = f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.Namespace).Update(ing) Expect(err).ToNot(HaveOccurred()) time.Sleep(waitForLuaSync) diff --git a/test/e2e/lua/dynamic_configuration.go b/test/e2e/lua/dynamic_configuration.go index 83dff3e66..a5eb34d53 100644 --- a/test/e2e/lua/dynamic_configuration.go +++ b/test/e2e/lua/dynamic_configuration.go @@ -79,7 +79,7 @@ var _ = framework.IngressNginxDescribe("Dynamic Configuration", func() { }) replicas := 2 - err := framework.UpdateDeployment(f.KubeClientSet, f.IngressController.Namespace, "http-svc", replicas, nil) + err := framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "http-svc", replicas, nil) Expect(err).NotTo(HaveOccurred()) time.Sleep(waitForLuaSync) @@ -101,7 +101,7 @@ var _ = framework.IngressNginxDescribe("Dynamic Configuration", func() { }) replicas := 2 - err := framework.UpdateDeployment(f.KubeClientSet, f.IngressController.Namespace, "http-svc", replicas, nil) + err := framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "http-svc", replicas, nil) Expect(err).NotTo(HaveOccurred()) time.Sleep(waitForLuaSync * 2) @@ -114,7 +114,7 @@ var _ = framework.IngressNginxDescribe("Dynamic Configuration", func() { }) Expect(nginxConfig).Should(Equal(newNginxConfig)) - err = framework.UpdateDeployment(f.KubeClientSet, f.IngressController.Namespace, "http-svc", 0, nil) + err = framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "http-svc", 0, nil) Expect(err).NotTo(HaveOccurred()) time.Sleep(waitForLuaSync * 2) @@ -129,14 +129,14 @@ var _ = framework.IngressNginxDescribe("Dynamic Configuration", func() { originalResponseCode := runRequest(f, "scaling.foo.com") replicas := 2 - err := framework.UpdateDeployment(f.KubeClientSet, f.IngressController.Namespace, deploymentName, replicas, nil) + err := framework.UpdateDeployment(f.KubeClientSet, f.Namespace, deploymentName, replicas, nil) Expect(err).NotTo(HaveOccurred()) time.Sleep(waitForLuaSync * 2) expectedSuccessResponseCode := runRequest(f, "scaling.foo.com") replicas = 0 - err = framework.UpdateDeployment(f.KubeClientSet, f.IngressController.Namespace, deploymentName, replicas, nil) + err = framework.UpdateDeployment(f.KubeClientSet, f.Namespace, deploymentName, replicas, nil) Expect(err).NotTo(HaveOccurred()) time.Sleep(waitForLuaSync * 2) @@ -154,11 +154,11 @@ var _ = framework.IngressNginxDescribe("Dynamic Configuration", func() { return true }) - ingress, err := f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.IngressController.Namespace).Get("foo.com", metav1.GetOptions{}) + ingress, err := f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.Namespace).Get("foo.com", metav1.GetOptions{}) Expect(err).ToNot(HaveOccurred()) ingress.ObjectMeta.Annotations["nginx.ingress.kubernetes.io/load-balance"] = "round_robin" - _, err = f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.IngressController.Namespace).Update(ingress) + _, err = f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.Namespace).Update(ingress) Expect(err).ToNot(HaveOccurred()) time.Sleep(waitForLuaSync) @@ -181,7 +181,7 @@ var _ = framework.IngressNginxDescribe("Dynamic Configuration", func() { return true }) - ingress, err := f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.IngressController.Namespace).Get("foo.com", metav1.GetOptions{}) + ingress, err := f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.Namespace).Get("foo.com", metav1.GetOptions{}) Expect(err).ToNot(HaveOccurred()) ingress.Spec.TLS = []extensions.IngressTLS{ { @@ -194,7 +194,7 @@ var _ = framework.IngressNginxDescribe("Dynamic Configuration", func() { ingress.Spec.TLS[0].SecretName, ingress.Namespace) Expect(err).ToNot(HaveOccurred()) - _, err = f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.IngressController.Namespace).Update(ingress) + _, err = f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.Namespace).Update(ingress) Expect(err).ToNot(HaveOccurred()) var newNginxConfig string @@ -213,7 +213,7 @@ var _ = framework.IngressNginxDescribe("Dynamic Configuration", func() { Expect(err).ToNot(HaveOccurred()) Expect(output).Should(Equal(`{"controllerPodsCount":1}`)) - err = framework.UpdateDeployment(f.KubeClientSet, f.IngressController.Namespace, "nginx-ingress-controller", 3, nil) + err = framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 3, nil) Expect(err).ToNot(HaveOccurred()) time.Sleep(waitForLuaSync) @@ -232,7 +232,7 @@ func ensureIngress(f *framework.Framework, host string, deploymentName string) * } func createIngress(f *framework.Framework, host string, deploymentName string) *extensions.Ingress { - ing := f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, deploymentName, 80, + ing := f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, deploymentName, 80, &map[string]string{"nginx.ingress.kubernetes.io/load-balance": "ewma"})) f.WaitForNginxServer(host, @@ -246,7 +246,7 @@ func createIngress(f *framework.Framework, host string, deploymentName string) * func ensureRequest(f *framework.Framework, host string) { resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() Expect(errs).Should(BeEmpty()) @@ -255,7 +255,7 @@ func ensureRequest(f *framework.Framework, host string) { func ensureRequestWithStatus(f *framework.Framework, host string, statusCode int) { resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() Expect(errs).Should(BeEmpty()) @@ -264,7 +264,7 @@ func ensureRequestWithStatus(f *framework.Framework, host string, statusCode int func runRequest(f *framework.Framework, host string) int { resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() Expect(errs).Should(BeEmpty()) diff --git a/test/e2e/servicebackend/service_backend.go b/test/e2e/servicebackend/service_backend.go index 3df7e8996..a508eeb14 100644 --- a/test/e2e/servicebackend/service_backend.go +++ b/test/e2e/servicebackend/service_backend.go @@ -44,7 +44,7 @@ var _ = framework.IngressNginxDescribe("Service backend - 503", func() { It("should return 503 when backend service does not exist", func() { host := "nonexistent.svc.com" - bi := buildIngressWithNonexistentService(host, f.IngressController.Namespace, "/") + bi := buildIngressWithNonexistentService(host, f.Namespace, "/") f.EnsureIngress(bi) f.WaitForNginxServer(host, @@ -53,7 +53,7 @@ var _ = framework.IngressNginxDescribe("Service backend - 503", func() { }) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() Expect(errs).Should(BeEmpty()) @@ -63,7 +63,7 @@ var _ = framework.IngressNginxDescribe("Service backend - 503", func() { It("should return 503 when all backend service endpoints are unavailable", func() { host := "unavailable.svc.com" - bi, bs := buildIngressWithUnavailableServiceEndpoints(host, f.IngressController.Namespace, "/") + bi, bs := buildIngressWithUnavailableServiceEndpoints(host, f.Namespace, "/") svc := f.EnsureService(bs) Expect(svc).NotTo(BeNil()) @@ -76,7 +76,7 @@ var _ = framework.IngressNginxDescribe("Service backend - 503", func() { }) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() Expect(errs).Should(BeEmpty()) diff --git a/test/e2e/settings/configmap_change.go b/test/e2e/settings/configmap_change.go index 4e19ca90d..e19fdf319 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.IngressController.Namespace, "http-svc", 80, nil) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil) f.EnsureIngress(ing) wlKey := "whitelist-source-range" diff --git a/test/e2e/settings/disable_catch_all.go b/test/e2e/settings/disable_catch_all.go index 673223d32..32c3c4fbf 100644 --- a/test/e2e/settings/disable_catch_all.go +++ b/test/e2e/settings/disable_catch_all.go @@ -37,12 +37,12 @@ var _ = framework.IngressNginxDescribe("Disabled catch-all", func() { BeforeEach(func() { f.NewEchoDeploymentWithReplicas(1) - framework.UpdateDeployment(f.KubeClientSet, f.IngressController.Namespace, "nginx-ingress-controller", 1, + framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 1, func(deployment *appsv1beta1.Deployment) error { args := deployment.Spec.Template.Spec.Containers[0].Args args = append(args, "--disable-catch-all=true") deployment.Spec.Template.Spec.Containers[0].Args = args - _, err := f.KubeClientSet.AppsV1beta1().Deployments(f.IngressController.Namespace).Update(deployment) + _, err := f.KubeClientSet.AppsV1beta1().Deployments(f.Namespace).Update(deployment) return err }) @@ -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.IngressController.Namespace, "http-svc", 80, nil) + ing := framework.NewSingleCatchAllIngress("catch-all", f.Namespace, "http-svc", 80, nil) f.EnsureIngress(ing) - ing = framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, nil) + ing = framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 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.IngressController.Namespace, "http-svc", 80, nil) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -82,13 +82,13 @@ var _ = framework.IngressNginxDescribe("Disabled catch-all", func() { }) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() Expect(errs).To(BeNil()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - err := framework.UpdateIngress(f.KubeClientSet, f.IngressController.Namespace, host, func(ingress *extensions.Ingress) error { + 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", @@ -103,7 +103,7 @@ var _ = framework.IngressNginxDescribe("Disabled catch-all", func() { }) resp, _, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() Expect(errs).To(BeNil()) @@ -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.IngressController.Namespace, "http-svc", 80, "http-svc", 80, nil) + ing := framework.NewSingleIngressWithBackendAndRules("not-catch-all", "/rulepath", host, f.Namespace, "http-svc", 80, "http-svc", 80, nil) f.EnsureIngress(ing) f.WaitForNginxServer(host, func(cfg string) bool { @@ -121,7 +121,7 @@ var _ = framework.IngressNginxDescribe("Disabled catch-all", func() { }) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() diff --git a/test/e2e/settings/forwarded_headers.go b/test/e2e/settings/forwarded_headers.go index b08ee075e..4bbdf952f 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.IngressController.Namespace, "http-svc", 80, nil) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil) f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -55,7 +55,7 @@ var _ = framework.IngressNginxDescribe("X-Forwarded headers", func() { }) resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("X-Forwarded-Port", "1234"). Set("X-Forwarded-Proto", "myproto"). @@ -76,7 +76,7 @@ var _ = framework.IngressNginxDescribe("X-Forwarded headers", func() { f.UpdateNginxConfigMapData(setting, "false") - f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, nil)) + f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil)) f.WaitForNginxServer(host, func(server string) bool { @@ -84,7 +84,7 @@ var _ = framework.IngressNginxDescribe("X-Forwarded headers", func() { }) resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("X-Forwarded-Port", "1234"). Set("X-Forwarded-Proto", "myproto"). diff --git a/test/e2e/settings/geoip2.go b/test/e2e/settings/geoip2.go index 58f657aff..6c464c78d 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.IngressController.Namespace, "http-svc", 80, &annotations)) + f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations)) f.WaitForNginxConfiguration( func(cfg string) bool { @@ -71,7 +71,7 @@ var _ = framework.IngressNginxDescribe("Geoip2", func() { // Should be blocked usIP := "8.8.8.8" resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("X-Forwarded-For", usIP). End() @@ -81,7 +81,7 @@ var _ = framework.IngressNginxDescribe("Geoip2", func() { // Shouldn't be blocked australianIP := "1.1.1.1" resp, _, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("X-Forwarded-For", australianIP). End() diff --git a/test/e2e/settings/global_access_block.go b/test/e2e/settings/global_access_block.go index 924283b18..3e1abb94f 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.IngressController.Namespace, "http-svc", 80, nil)) + f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil)) }) AfterEach(func() { @@ -53,7 +53,7 @@ var _ = framework.IngressNginxDescribe("Global access block", func() { // This test works for minikube, but may have problems with real kubernetes clusters, // especially if connection is done via Internet. In this case, the test should be disabled/removed. resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() Expect(errs).To(BeNil()) @@ -71,7 +71,7 @@ var _ = framework.IngressNginxDescribe("Global access block", func() { // Should be blocked resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"). End() @@ -79,7 +79,7 @@ var _ = framework.IngressNginxDescribe("Global access block", func() { Expect(resp.StatusCode).Should(Equal(http.StatusForbidden)) resp, _, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("User-Agent", "AlphaBot"). End() @@ -88,7 +88,7 @@ var _ = framework.IngressNginxDescribe("Global access block", func() { // Shouldn't be blocked resp, _, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 11_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1"). End() @@ -107,7 +107,7 @@ var _ = framework.IngressNginxDescribe("Global access block", func() { // Should be blocked resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("Referer", "example.com"). End() @@ -115,7 +115,7 @@ var _ = framework.IngressNginxDescribe("Global access block", func() { Expect(resp.StatusCode).Should(Equal(http.StatusForbidden)) resp, _, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("Referer", "qwerty"). End() @@ -124,7 +124,7 @@ var _ = framework.IngressNginxDescribe("Global access block", func() { // Shouldn't be blocked resp, _, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). Set("Referer", "qwerty123"). End() diff --git a/test/e2e/settings/ingress_class.go b/test/e2e/settings/ingress_class.go index 69032d308..772429cd2 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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(invalidHost, "/", invalidHost, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) validHost := "bar" - ing = framework.NewSingleIngress(validHost, "/", validHost, f.IngressController.Namespace, "http-svc", 80, nil) + ing = framework.NewSingleIngress(validHost, "/", validHost, f.Namespace, "http-svc", 80, nil) f.EnsureIngress(ing) f.WaitForNginxConfiguration(func(cfg string) bool { @@ -58,14 +58,14 @@ var _ = framework.IngressNginxDescribe("Ingress class", func() { }) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", invalidHost). End() Expect(errs).To(BeNil()) Expect(resp.StatusCode).Should(Equal(http.StatusNotFound)) resp, _, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", validHost). End() Expect(errs).To(BeNil()) @@ -75,12 +75,12 @@ var _ = framework.IngressNginxDescribe("Ingress class", func() { Context("With a specific ingress-class", func() { BeforeEach(func() { - framework.UpdateDeployment(f.KubeClientSet, f.IngressController.Namespace, "nginx-ingress-controller", 1, + framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 1, func(deployment *appsv1beta1.Deployment) error { args := deployment.Spec.Template.Spec.Containers[0].Args args = append(args, "--ingress-class=testclass") deployment.Spec.Template.Spec.Containers[0].Args = args - _, err := f.KubeClientSet.AppsV1beta1().Deployments(f.IngressController.Namespace).Update(deployment) + _, err := f.KubeClientSet.AppsV1beta1().Deployments(f.Namespace).Update(deployment) return err }) @@ -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.IngressController.Namespace, "http-svc", 80, nil) + ing := framework.NewSingleIngress(invalidHost, "/", invalidHost, f.Namespace, "http-svc", 80, nil) f.EnsureIngress(ing) validHost := "foo" annotations := map[string]string{ "kubernetes.io/ingress.class": "testclass", } - ing = framework.NewSingleIngress(validHost, "/", validHost, f.IngressController.Namespace, "http-svc", 80, &annotations) + ing = framework.NewSingleIngress(validHost, "/", validHost, f.Namespace, "http-svc", 80, &annotations) f.EnsureIngress(ing) f.WaitForNginxServer(validHost, func(cfg string) bool { @@ -108,14 +108,14 @@ var _ = framework.IngressNginxDescribe("Ingress class", func() { }) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", validHost). End() Expect(errs).To(BeNil()) Expect(resp.StatusCode).Should(Equal(http.StatusOK)) resp, _, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", invalidHost). End() Expect(errs).To(BeNil()) @@ -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.IngressController.Namespace, "http-svc", 80, &annotations) + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, &annotations) ing = f.EnsureIngress(ing) f.WaitForNginxServer(host, func(cfg string) bool { @@ -135,7 +135,7 @@ var _ = framework.IngressNginxDescribe("Ingress class", func() { }) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() Expect(errs).To(BeNil()) @@ -149,7 +149,7 @@ var _ = framework.IngressNginxDescribe("Ingress class", func() { }) resp, _, errs = gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() Expect(errs).To(BeNil()) diff --git a/test/e2e/settings/no_auth_locations.go b/test/e2e/settings/no_auth_locations.go index 546df3043..49aa3af07 100644 --- a/test/e2e/settings/no_auth_locations.go +++ b/test/e2e/settings/no_auth_locations.go @@ -45,11 +45,11 @@ var _ = framework.IngressNginxDescribe("No Auth locations", func() { BeforeEach(func() { f.NewEchoDeployment() - s := f.EnsureSecret(buildSecret(username, password, secretName, f.IngressController.Namespace)) + s := f.EnsureSecret(buildSecret(username, password, secretName, f.Namespace)) f.UpdateNginxConfigMapData(setting, noAuthPath) - bi := buildBasicAuthIngressWithSecondPath(host, f.IngressController.Namespace, s.Name, noAuthPath) + bi := buildBasicAuthIngressWithSecondPath(host, f.Namespace, s.Name, noAuthPath) f.EnsureIngress(bi) }) @@ -63,7 +63,7 @@ var _ = framework.IngressNginxDescribe("No Auth locations", func() { }) resp, body, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). End() @@ -79,7 +79,7 @@ var _ = framework.IngressNginxDescribe("No Auth locations", func() { }) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", host). SetBasicAuth(username, password). End() @@ -95,7 +95,7 @@ var _ = framework.IngressNginxDescribe("No Auth locations", func() { }) resp, _, errs := gorequest.New(). - Get(fmt.Sprintf("%s/noauth", f.IngressController.HTTPURL)). + Get(fmt.Sprintf("%s/noauth", f.GetURL(framework.HTTP))). Set("Host", host). End() diff --git a/test/e2e/settings/pod_security_policy.go b/test/e2e/settings/pod_security_policy.go index 214b1ee88..eec563e61 100644 --- a/test/e2e/settings/pod_security_policy.go +++ b/test/e2e/settings/pod_security_policy.go @@ -63,12 +63,12 @@ var _ = framework.IngressNginxDescribe("[Serial] Pod Security Policies", func() Expect(err).NotTo(HaveOccurred(), "updating ingress controller cluster role to use a pod security policy") // update the deployment just to trigger a rolling update and the use of the security policy - err = framework.UpdateDeployment(f.KubeClientSet, f.IngressController.Namespace, "nginx-ingress-controller", 1, + err = framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 1, func(deployment *appsv1beta1.Deployment) error { args := deployment.Spec.Template.Spec.Containers[0].Args args = append(args, "--v=2") deployment.Spec.Template.Spec.Containers[0].Args = args - _, err := f.KubeClientSet.AppsV1beta1().Deployments(f.IngressController.Namespace).Update(deployment) + _, err := f.KubeClientSet.AppsV1beta1().Deployments(f.Namespace).Update(deployment) return err }) @@ -108,7 +108,7 @@ var _ = framework.IngressNginxDescribe("[Serial] Pod Security Policies", func() }) resp, _, _ := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). Set("Host", "foo.bar.com"). End() Expect(resp.StatusCode).Should(Equal(http.StatusNotFound)) diff --git a/test/e2e/settings/proxy_host.go b/test/e2e/settings/proxy_host.go index 2ae17b49e..d9789e7fd 100644 --- a/test/e2e/settings/proxy_host.go +++ b/test/e2e/settings/proxy_host.go @@ -20,6 +20,7 @@ import ( "fmt" "net/http" "strings" + "time" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -37,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.IngressController.Namespace) + upstreamName := fmt.Sprintf("%v-http-svc-80", f.Namespace) annotations := map[string]string{ "nginx.ingress.kubernetes.io/configuration-snippet": `more_set_headers "Custom-Header: $proxy_host"`, } - f.EnsureIngress(framework.NewSingleIngress(test, "/", test, f.IngressController.Namespace, "http-svc", 80, &annotations)) + f.EnsureIngress(framework.NewSingleIngress(test, "/", test, f.Namespace, "http-svc", 80, &annotations)) f.WaitForNginxConfiguration( func(server string) bool { @@ -50,7 +51,8 @@ var _ = framework.IngressNginxDescribe("Proxy host variable", func() { }) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). + Retry(10, 1*time.Second, http.StatusNotFound). Set("Host", test). End() @@ -60,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.IngressController.Namespace) + upstreamName := fmt.Sprintf("%v-http-svc-80", f.Namespace) 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.IngressController.Namespace, "http-svc", 80, &annotations)) + f.EnsureIngress(framework.NewSingleIngress(test, "/", test, f.Namespace, "http-svc", 80, &annotations)) f.WaitForNginxConfiguration( func(server string) bool { @@ -75,7 +77,8 @@ var _ = framework.IngressNginxDescribe("Proxy host variable", func() { }) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPURL). + Get(f.GetURL(framework.HTTP)). + Retry(10, 1*time.Second, http.StatusNotFound). Set("Host", test). End() diff --git a/test/e2e/settings/proxy_protocol.go b/test/e2e/settings/proxy_protocol.go index 8a2956515..95fdde595 100644 --- a/test/e2e/settings/proxy_protocol.go +++ b/test/e2e/settings/proxy_protocol.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "net" - "strconv" "strings" . "github.com/onsi/ginkgo" @@ -47,7 +46,7 @@ var _ = framework.IngressNginxDescribe("Proxy Protocol", func() { f.UpdateNginxConfigMapData(setting, "true") - f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, nil)) + f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil)) f.WaitForNginxServer(host, func(server string) bool { @@ -56,11 +55,9 @@ var _ = framework.IngressNginxDescribe("Proxy Protocol", func() { }) ip := f.GetNginxIP() - port, err := f.GetNginxPort("http") - Expect(err).NotTo(HaveOccurred(), "unexpected error obtaning NGINX Port") - conn, err := net.Dial("tcp", net.JoinHostPort(ip, strconv.Itoa(port))) - Expect(err).NotTo(HaveOccurred(), "unexpected error creating connection to %s:%d", ip, port) + conn, err := net.Dial("tcp", net.JoinHostPort(ip, "80")) + Expect(err).NotTo(HaveOccurred(), "unexpected error creating connection to %s:80", ip) defer conn.Close() header := "PROXY TCP4 192.168.0.1 192.168.0.11 56324 1234\r\n" diff --git a/test/e2e/settings/server_tokens.go b/test/e2e/settings/server_tokens.go index 2189f2f79..d1abe760c 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.IngressController.Namespace, "http-svc", 80, nil)) + f.EnsureIngress(framework.NewSingleIngress(serverTokens, "/", serverTokens, f.Namespace, "http-svc", 80, nil)) f.WaitForNginxConfiguration( func(cfg string) bool { @@ -56,7 +56,7 @@ var _ = framework.IngressNginxDescribe("Server Tokens", func() { f.EnsureIngress(&v1beta1.Ingress{ ObjectMeta: metav1.ObjectMeta{ Name: serverTokens, - Namespace: f.IngressController.Namespace, + Namespace: f.Namespace, Annotations: map[string]string{}, }, Spec: v1beta1.IngressSpec{ diff --git a/test/e2e/settings/tls.go b/test/e2e/settings/tls.go index 986e02a70..67a7b4507 100644 --- a/test/e2e/settings/tls.go +++ b/test/e2e/settings/tls.go @@ -54,14 +54,14 @@ 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.IngressController.Namespace, "http-svc", 80, nil)) + ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "http-svc", 80, nil)) tlsConfig, err := framework.CreateIngressTLSSecret(f.KubeClientSet, ing.Spec.TLS[0].Hosts, ing.Spec.TLS[0].SecretName, ing.Namespace) Expect(err).NotTo(HaveOccurred()) - framework.WaitForTLS(f.IngressController.HTTPSURL, tlsConfig) + framework.WaitForTLS(f.GetURL(framework.HTTPS), tlsConfig) By("setting cipher suite") f.UpdateNginxConfigMapData(sslCiphers, testCiphers) @@ -72,7 +72,7 @@ var _ = framework.IngressNginxDescribe("Settings - TLS)", func() { }) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPSURL). + Get(f.GetURL(framework.HTTPS)). TLSClientConfig(tlsConfig). Set("Host", host). End() @@ -91,7 +91,7 @@ var _ = framework.IngressNginxDescribe("Settings - TLS)", func() { }) resp, _, errs = gorequest.New(). - Get(f.IngressController.HTTPSURL). + Get(f.GetURL(framework.HTTPS)). TLSClientConfig(tlsConfig). Set("Host", host). End() @@ -107,14 +107,14 @@ var _ = framework.IngressNginxDescribe("Settings - TLS)", func() { hstsIncludeSubdomains := "hsts-include-subdomains" hstsPreload := "hsts-preload" - ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.IngressController.Namespace, "http-svc", 80, nil)) + ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "http-svc", 80, nil)) tlsConfig, err := framework.CreateIngressTLSSecret(f.KubeClientSet, ing.Spec.TLS[0].Hosts, ing.Spec.TLS[0].SecretName, ing.Namespace) Expect(err).NotTo(HaveOccurred()) - framework.WaitForTLS(f.IngressController.HTTPSURL, tlsConfig) + framework.WaitForTLS(f.GetURL(framework.HTTPS), tlsConfig) By("setting max-age parameter") f.UpdateNginxConfigMapData(hstsMaxAge, "86400") @@ -125,7 +125,7 @@ var _ = framework.IngressNginxDescribe("Settings - TLS)", func() { }) resp, _, errs := gorequest.New(). - Get(f.IngressController.HTTPSURL). + Get(f.GetURL(framework.HTTPS)). TLSClientConfig(tlsConfig). Set("Host", host). End() @@ -143,7 +143,7 @@ var _ = framework.IngressNginxDescribe("Settings - TLS)", func() { }) resp, _, errs = gorequest.New(). - Get(f.IngressController.HTTPSURL). + Get(f.GetURL(framework.HTTPS)). TLSClientConfig(tlsConfig). Set("Host", host). End() @@ -161,7 +161,7 @@ var _ = framework.IngressNginxDescribe("Settings - TLS)", func() { }) resp, _, errs = gorequest.New(). - Get(f.IngressController.HTTPSURL). + Get(f.GetURL(framework.HTTPS)). TLSClientConfig(tlsConfig). Set("Host", host). End() @@ -172,14 +172,14 @@ 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.IngressController.Namespace, "http-svc", 80, nil)) + ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "http-svc", 80, nil)) tlsConfig, err := framework.CreateIngressTLSSecret(f.KubeClientSet, ing.Spec.TLS[0].Hosts, ing.Spec.TLS[0].SecretName, ing.Namespace) Expect(err).NotTo(HaveOccurred()) - framework.WaitForTLS(f.IngressController.HTTPSURL, tlsConfig) + framework.WaitForTLS(f.GetURL(framework.HTTPS), tlsConfig) f.WaitForNginxServer(host, func(server string) bool { @@ -188,7 +188,7 @@ var _ = framework.IngressNginxDescribe("Settings - TLS)", func() { }) resp, _, errs := gorequest.New(). - Get(fmt.Sprintf(f.IngressController.HTTPURL)). + Get(fmt.Sprintf(f.GetURL(framework.HTTP))). Retry(10, 1*time.Second, http.StatusNotFound). RedirectPolicy(noRedirectPolicyFunc). Set("Host", host). @@ -202,14 +202,14 @@ 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.IngressController.Namespace, "http-svc", 80, nil)) + ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "http-svc", 80, nil)) tlsConfig, err := framework.CreateIngressTLSSecret(f.KubeClientSet, ing.Spec.TLS[0].Hosts, ing.Spec.TLS[0].SecretName, ing.Namespace) Expect(err).NotTo(HaveOccurred()) - framework.WaitForTLS(f.IngressController.HTTPSURL, tlsConfig) + framework.WaitForTLS(f.GetURL(framework.HTTPS), tlsConfig) f.WaitForNginxServer(host, func(server string) bool { @@ -218,7 +218,7 @@ var _ = framework.IngressNginxDescribe("Settings - TLS)", func() { }) resp, _, errs := gorequest.New(). - Get(fmt.Sprintf(f.IngressController.HTTPURL)). + Get(fmt.Sprintf(f.GetURL(framework.HTTP))). Retry(10, 1*time.Second, http.StatusNotFound). RedirectPolicy(noRedirectPolicyFunc). Set("Host", host). diff --git a/test/e2e/ssl/secret_update.go b/test/e2e/ssl/secret_update.go index 36026955f..ed77c6b6c 100644 --- a/test/e2e/ssl/secret_update.go +++ b/test/e2e/ssl/secret_update.go @@ -45,14 +45,14 @@ var _ = framework.IngressNginxDescribe("SSL", func() { dummySecret := f.EnsureSecret(&v1.Secret{ ObjectMeta: metav1.ObjectMeta{ Name: "dummy", - Namespace: f.IngressController.Namespace, + Namespace: f.Namespace, }, Data: map[string][]byte{ "key": []byte("value"), }, }) - ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.IngressController.Namespace, "http-svc", 80, nil)) + ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "http-svc", 80, nil)) _, err := framework.CreateIngressTLSSecret(f.KubeClientSet, ing.Spec.TLS[0].Hosts, ing.Spec.TLS[0].SecretName, @@ -69,12 +69,12 @@ var _ = framework.IngressNginxDescribe("SSL", func() { Expect(err).ToNot(HaveOccurred()) Expect(log).ToNot(BeEmpty()) - Expect(log).ToNot(ContainSubstring(fmt.Sprintf("starting syncing of secret %v/dummy", f.IngressController.Namespace))) + Expect(log).ToNot(ContainSubstring(fmt.Sprintf("starting syncing of secret %v/dummy", f.Namespace))) time.Sleep(5 * time.Second) dummySecret.Data["some-key"] = []byte("some value") - f.KubeClientSet.CoreV1().Secrets(f.IngressController.Namespace).Update(dummySecret) + f.KubeClientSet.CoreV1().Secrets(f.Namespace).Update(dummySecret) time.Sleep(5 * time.Second) - Expect(log).ToNot(ContainSubstring(fmt.Sprintf("starting syncing of secret %v/dummy", f.IngressController.Namespace))) - Expect(log).ToNot(ContainSubstring(fmt.Sprintf("error obtaining PEM from secret %v/dummy", f.IngressController.Namespace))) + Expect(log).ToNot(ContainSubstring(fmt.Sprintf("starting syncing of secret %v/dummy", f.Namespace))) + Expect(log).ToNot(ContainSubstring(fmt.Sprintf("error obtaining PEM from secret %v/dummy", f.Namespace))) }) }) diff --git a/test/e2e/status/update.go b/test/e2e/status/update.go index 062c3cb7e..c28122a0f 100644 --- a/test/e2e/status/update.go +++ b/test/e2e/status/update.go @@ -49,7 +49,7 @@ var _ = framework.IngressNginxDescribe("Status Update [Status]", func() { port, cmd, err := f.KubectlProxy(0) Expect(err).NotTo(HaveOccurred(), "unexpected error starting kubectl proxy") - err = framework.UpdateDeployment(f.KubeClientSet, f.IngressController.Namespace, "nginx-ingress-controller", 1, + err = framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 1, func(deployment *appsv1beta1.Deployment) error { args := deployment.Spec.Template.Spec.Containers[0].Args args = append(args, fmt.Sprintf("--apiserver-host=http://%s:%d", address.String(), port)) @@ -67,14 +67,14 @@ var _ = framework.IngressNginxDescribe("Status Update [Status]", func() { } deployment.Spec.Template.Spec.Containers[0].Args = args - _, err := f.KubeClientSet.AppsV1beta1().Deployments(f.IngressController.Namespace).Update(deployment) + _, err := f.KubeClientSet.AppsV1beta1().Deployments(f.Namespace).Update(deployment) return err }) Expect(err).NotTo(HaveOccurred(), "unexpected error updating ingress controller deployment flags") f.NewEchoDeploymentWithReplicas(1) - ing := f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, nil)) + ing := f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, "http-svc", 80, nil)) f.WaitForNginxConfiguration( func(cfg string) bool { @@ -87,16 +87,16 @@ var _ = framework.IngressNginxDescribe("Status Update [Status]", func() { err = cmd.Process.Kill() Expect(err).NotTo(HaveOccurred(), "unexpected error terminating kubectl proxy") - ing, err = f.KubeClientSet.Extensions().Ingresses(f.IngressController.Namespace).Get(host, metav1.GetOptions{}) - Expect(err).NotTo(HaveOccurred(), "unexpected error getting %s/%v Ingress", f.IngressController.Namespace, host) + ing, err = f.KubeClientSet.Extensions().Ingresses(f.Namespace).Get(host, metav1.GetOptions{}) + Expect(err).NotTo(HaveOccurred(), "unexpected error getting %s/%v Ingress", f.Namespace, host) ing.Status.LoadBalancer.Ingress = []apiv1.LoadBalancerIngress{} - _, err = f.KubeClientSet.Extensions().Ingresses(f.IngressController.Namespace).UpdateStatus(ing) + _, err = f.KubeClientSet.Extensions().Ingresses(f.Namespace).UpdateStatus(ing) Expect(err).NotTo(HaveOccurred(), "unexpected error cleaning Ingress status") time.Sleep(10 * time.Second) err = f.KubeClientSet.CoreV1(). - ConfigMaps(f.IngressController.Namespace). + ConfigMaps(f.Namespace). Delete("ingress-controller-leader-nginx", &metav1.DeleteOptions{}) Expect(err).NotTo(HaveOccurred(), "unexpected error deleting leader election configmap") @@ -110,9 +110,9 @@ var _ = framework.IngressNginxDescribe("Status Update [Status]", func() { }() err = wait.Poll(10*time.Second, framework.DefaultTimeout, func() (done bool, err error) { - ing, err = f.KubeClientSet.Extensions().Ingresses(f.IngressController.Namespace).Get(host, metav1.GetOptions{}) + ing, err = f.KubeClientSet.Extensions().Ingresses(f.Namespace).Get(host, metav1.GetOptions{}) if err != nil { - return false, err + return false, nil } if len(ing.Status.LoadBalancer.Ingress) != 1 { diff --git a/test/e2e/tcpudp/tcp.go b/test/e2e/tcpudp/tcp.go index df93ca776..8a9fa36b8 100644 --- a/test/e2e/tcpudp/tcp.go +++ b/test/e2e/tcpudp/tcp.go @@ -19,11 +19,12 @@ package settings import ( "context" "fmt" - "github.com/parnurzeal/gorequest" "net" "strings" "time" + "github.com/parnurzeal/gorequest" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" @@ -52,7 +53,7 @@ var _ = framework.IngressNginxDescribe("TCP Feature", func() { config, err := f.KubeClientSet. CoreV1(). - ConfigMaps(f.IngressController.Namespace). + ConfigMaps(f.Namespace). Get("tcp-services", metav1.GetOptions{}) Expect(err).To(BeNil(), "unexpected error obtaining tcp-services configmap") Expect(config).NotTo(BeNil(), "expected a configmap but none returned") @@ -61,17 +62,17 @@ var _ = framework.IngressNginxDescribe("TCP Feature", func() { config.Data = map[string]string{} } - config.Data["8080"] = fmt.Sprintf("%v/http-svc:80", f.IngressController.Namespace) + config.Data["8080"] = fmt.Sprintf("%v/http-svc:80", f.Namespace) _, err = f.KubeClientSet. CoreV1(). - ConfigMaps(f.IngressController.Namespace). + ConfigMaps(f.Namespace). Update(config) Expect(err).NotTo(HaveOccurred(), "unexpected error updating configmap") svc, err := f.KubeClientSet. CoreV1(). - Services(f.IngressController.Namespace). + Services(f.Namespace). Get("ingress-nginx", metav1.GetOptions{}) Expect(err).To(BeNil(), "unexpected error obtaining ingress-nginx service") Expect(svc).NotTo(BeNil(), "expected a service but none returned") @@ -83,21 +84,18 @@ var _ = framework.IngressNginxDescribe("TCP Feature", func() { }) _, err = f.KubeClientSet. CoreV1(). - Services(f.IngressController.Namespace). + Services(f.Namespace). Update(svc) Expect(err).NotTo(HaveOccurred(), "unexpected error updating service") f.WaitForNginxConfiguration( func(cfg string) bool { - return strings.Contains(cfg, fmt.Sprintf(`ngx.var.proxy_upstream_name="tcp-%v-http-svc-80"`, f.IngressController.Namespace)) + return strings.Contains(cfg, fmt.Sprintf(`ngx.var.proxy_upstream_name="tcp-%v-http-svc-80"`, f.Namespace)) }) ip := f.GetNginxIP() - port, err := f.GetNginxPort("http-svc") - Expect(err).NotTo(HaveOccurred(), "unexpected error obtaining service port") - resp, _, errs := gorequest.New(). - Get(fmt.Sprintf("http://%v:%v", ip, port)). + Get(fmt.Sprintf("http://%v:8080", ip)). End() Expect(errs).Should(BeEmpty()) Expect(resp.StatusCode).Should(Equal(200)) @@ -113,7 +111,7 @@ var _ = framework.IngressNginxDescribe("TCP Feature", func() { externalService := &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: "dns-external-name-svc", - Namespace: f.IngressController.Namespace, + Namespace: f.Namespace, }, Spec: corev1.ServiceSpec{ @@ -133,7 +131,7 @@ var _ = framework.IngressNginxDescribe("TCP Feature", func() { // Expose the `external name` port on the `ingress-nginx` service svc, err := f.KubeClientSet. CoreV1(). - Services(f.IngressController.Namespace). + Services(f.Namespace). Get("ingress-nginx", metav1.GetOptions{}) Expect(err).To(BeNil(), "unexpected error obtaining ingress-nginx service") Expect(svc).NotTo(BeNil(), "expected a service but none returned") @@ -145,14 +143,14 @@ var _ = framework.IngressNginxDescribe("TCP Feature", func() { }) _, err = f.KubeClientSet. CoreV1(). - Services(f.IngressController.Namespace). + Services(f.Namespace). Update(svc) Expect(err).NotTo(HaveOccurred(), "unexpected error updating service") // Update the TCP configmap to link port 5353 to the DNS external name service config, err := f.KubeClientSet. CoreV1(). - ConfigMaps(f.IngressController.Namespace). + ConfigMaps(f.Namespace). Get("tcp-services", metav1.GetOptions{}) Expect(err).To(BeNil(), "unexpected error obtaining tcp-services configmap") Expect(config).NotTo(BeNil(), "expected a configmap but none returned") @@ -161,11 +159,11 @@ var _ = framework.IngressNginxDescribe("TCP Feature", func() { config.Data = map[string]string{} } - config.Data["5353"] = fmt.Sprintf("%v/dns-external-name-svc:5353", f.IngressController.Namespace) + config.Data["5353"] = fmt.Sprintf("%v/dns-external-name-svc:5353", f.Namespace) _, err = f.KubeClientSet. CoreV1(). - ConfigMaps(f.IngressController.Namespace). + ConfigMaps(f.Namespace). Update(config) Expect(err).NotTo(HaveOccurred(), "unexpected error updating configmap") @@ -174,19 +172,16 @@ var _ = framework.IngressNginxDescribe("TCP Feature", func() { // Validate that the generated nginx config contains the expected `proxy_upstream_name` value f.WaitForNginxConfiguration( func(cfg string) bool { - return strings.Contains(cfg, fmt.Sprintf(`ngx.var.proxy_upstream_name="tcp-%v-dns-external-name-svc-5353"`, f.IngressController.Namespace)) + return strings.Contains(cfg, fmt.Sprintf(`ngx.var.proxy_upstream_name="tcp-%v-dns-external-name-svc-5353"`, f.Namespace)) }) // Execute the test. Use the `external name` service to resolve a domain name. ip := f.GetNginxIP() - port, err := f.GetNginxPort("dns-svc") - Expect(err).NotTo(HaveOccurred(), "unexpected error obtaining service port") - resolver := net.Resolver{ PreferGo: true, Dial: func(ctx context.Context, network, address string) (net.Conn, error) { d := net.Dialer{} - return d.DialContext(ctx, "tcp", fmt.Sprintf("%v:%v", ip, port)) + return d.DialContext(ctx, "tcp", fmt.Sprintf("%v:5353", ip)) }, } ips, err := resolver.LookupHost(context.Background(), "google-public-dns-b.google.com") diff --git a/test/e2e/up.sh b/test/e2e/up.sh index 31a24b33a..3914cb2c0 100755 --- a/test/e2e/up.sh +++ b/test/e2e/up.sh @@ -22,13 +22,12 @@ if test -e kubectl; then echo "skipping download of kubectl" else echo "downloading kubectl..." - curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.12.0/bin/linux/amd64/kubectl && \ - chmod +x kubectl && sudo mv kubectl /usr/local/bin/ + curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.13.3/bin/linux/amd64/kubectl \ + && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ fi -mkdir -p ${HOME}/.kube -touch ${HOME}/.kube/config -export KUBECONFIG=${HOME}/.kube/config +export KUBECONFIG="$(mktemp)" +echo -n ${KUBECONFIG} > /tmp/kubeconfig echo "starting Kubernetes cluster..." K8S_VERSION=v1.11 @@ -54,3 +53,6 @@ make -C ${DIR}/../../ build container echo "copying docker image to cluster..." DEV_IMAGE=${REGISTRY}/nginx-ingress-controller:${TAG} ${DIR}/dind-cluster-v1.11.sh copy-image ${DEV_IMAGE} + +echo "copying e2e docker image to cluster..." +${DIR}/dind-cluster-v1.11.sh copy-image nginx-ingress-controller:e2e diff --git a/test/e2e/wait-for-nginx.sh b/test/e2e/wait-for-nginx.sh index 360a7986d..f7b3ad9db 100755 --- a/test/e2e/wait-for-nginx.sh +++ b/test/e2e/wait-for-nginx.sh @@ -15,6 +15,7 @@ # limitations under the License. set -e +set -x DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" @@ -32,8 +33,10 @@ function on_exit { } trap on_exit EXIT -sed "s@\${NAMESPACE}@${NAMESPACE}@" $DIR/../manifests/ingress-controller/mandatory.yaml | kubectl apply --namespace=$NAMESPACE -f - -cat $DIR/../manifests/ingress-controller/service-nodeport.yaml | kubectl apply --namespace=$NAMESPACE -f - +kubectl apply --namespace=$NAMESPACE -f $DIR/manifests/service.yaml + +sed "s@\${NAMESPACE}@${NAMESPACE}@" $DIR/manifests/mandatory.yaml | kubectl apply --namespace=$NAMESPACE -f - +cat $DIR/manifests/service.yaml | kubectl apply --namespace=$NAMESPACE -f - # wait for the deployment and fail if there is an error before starting the execution of any test kubectl rollout status \