From 15974a359fdd8a6a21cb01cc56453436deb7c204 Mon Sep 17 00:00:00 2001 From: GeorgianaElena Date: Sun, 21 Jun 2020 13:55:52 +0300 Subject: [PATCH] Group tests for fewer reloads --- integration-tests/test_proxy.py | 60 +++++++++++++++------------------ 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/integration-tests/test_proxy.py b/integration-tests/test_proxy.py index f755470..390dd6a 100644 --- a/integration-tests/test_proxy.py +++ b/integration-tests/test_proxy.py @@ -99,15 +99,35 @@ def test_manual_https(preserve_config): reload_component("proxy") -def test_extra_traefik_static_config(): +def test_extra_traefik_config(): extra_static_config_dir = os.path.join(CONFIG_DIR, "traefik_config.d") os.makedirs(extra_static_config_dir, exist_ok=True) + dynamic_config_dir = os.path.join(STATE_DIR, "rules") + os.makedirs(dynamic_config_dir, exist_ok=True) + + extra_static_config = { "entryPoints": {"no_auth_api": {"address": "127.0.0.1:9999"}}, "api": {"dashboard": True, "entrypoint": "no_auth_api"}, } + extra_dynamic_config = { + "frontends": { + "test": { + "backend": "test", + "routes": { + "rule1": {"rule": "PathPrefixStrip: /the/hub/runs/here/too"} + }, + } + }, + "backends": { + # redirect to hub + "test": {"servers": {"server1": {"url": "http://127.0.0.1:15001"}}} + }, + } + + success = False for i in range(5): time.sleep(i) @@ -129,38 +149,6 @@ def test_extra_traefik_static_config(): ) as extra_config_file: toml.dump(extra_static_config, extra_config_file) - # load the extra config - reload_component("proxy") - - # the new dashboard entrypoint shouldn't require authentication anymore - resp = send_request(url="http://127.0.0.1:9999/dashboard/", max_sleep=5) - assert resp.code == 200 - - # cleanup - os.remove(os.path.join(extra_static_config_dir, "extra.toml")) - open(os.path.join(STATE_DIR, "traefik.toml"), "w").close() - reload_component("proxy") - - -def test_extra_traefik_dynamic_config(): - dynamic_config_dir = os.path.join(STATE_DIR, "rules") - os.makedirs(dynamic_config_dir, exist_ok=True) - - extra_dynamic_config = { - "frontends": { - "test": { - "backend": "test", - "routes": { - "rule1": {"rule": "PathPrefixStrip: /the/hub/runs/here/too"} - }, - } - }, - "backends": { - # redirect to hub - "test": {"servers": {"server1": {"url": "http://127.0.0.1:15001"}}} - }, - } - # write the extra dynamic config with open( os.path.join(dynamic_config_dir, "extra_rules.toml"), "w+" @@ -170,10 +158,16 @@ def test_extra_traefik_dynamic_config(): # load the extra config reload_component("proxy") + # the new dashboard entrypoint shouldn't require authentication anymore + resp = send_request(url="http://127.0.0.1:9999/dashboard/", max_sleep=5) + assert resp.code == 200 + # test extra dynamic config resp = send_request(url="http://127.0.0.1/the/hub/runs/here/too", max_sleep=5) assert resp.code == 200 assert resp.effective_url == "http://127.0.0.1/hub/login" # cleanup + os.remove(os.path.join(extra_static_config_dir, "extra.toml")) os.remove(os.path.join(dynamic_config_dir, "extra_rules.toml")) + open(os.path.join(STATE_DIR, "traefik.toml"), "w").close()