From a637b399b84b0748adf15b35a785fc04d4c8886e Mon Sep 17 00:00:00 2001 From: Gilles Filippini Date: Sun, 20 Jun 2021 16:57:55 +0200 Subject: [PATCH] test: add test_server-down/test_load-balancing Check that when multiple containers have the same WIRTUAL_HOST and one of them is unreachable, the resulting `upstream` block has no `server 127.0.0.1 down;` entry. --- test/test_server-down/test_load-balancing.py | 8 +++++ test/test_server-down/test_load-balancing.yml | 30 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 test/test_server-down/test_load-balancing.py create mode 100644 test/test_server-down/test_load-balancing.yml diff --git a/test/test_server-down/test_load-balancing.py b/test/test_server-down/test_load-balancing.py new file mode 100644 index 0000000..b65d0a1 --- /dev/null +++ b/test/test_server-down/test_load-balancing.py @@ -0,0 +1,8 @@ +import pytest + +def test_web_has_no_server_down(docker_compose, nginxproxy): + conf = nginxproxy.get_conf().decode('ASCII') + r = nginxproxy.get("http://web.nginx-proxy.tld/port") + assert r.status_code == 200 + assert (r.text == "answer from port 81\n") or (r.text == "answer from port 82\n") + assert conf.count("server 127.0.0.1 down;") == 0 diff --git a/test/test_server-down/test_load-balancing.yml b/test/test_server-down/test_load-balancing.yml new file mode 100644 index 0000000..b7162d1 --- /dev/null +++ b/test/test_server-down/test_load-balancing.yml @@ -0,0 +1,30 @@ +web1: + image: web + expose: + - "81" + environment: + WEB_PORTS: 81 + VIRTUAL_HOST: web.nginx-proxy.tld + +web2: + image: web + expose: + - "82" + environment: + WEB_PORTS: 83 + VIRTUAL_HOST: web.nginx-proxy.tld + +web3: + image: web + expose: + - "83" + environment: + WEB_PORTS: 83 + VIRTUAL_HOST: web.nginx-proxy.tld + net: "none" + +sut: + image: nginxproxy/nginx-proxy:test + volumes: + - /var/run/docker.sock:/tmp/docker.sock:ro + - ../lib/ssl/dhparam.pem:/etc/nginx/dhparam/dhparam.pem:ro