Skip to content

Commit

Permalink
fixed itest
Browse files Browse the repository at this point in the history
  • Loading branch information
PietroPasotti committed Oct 18, 2023
1 parent bf942f8 commit 862f2af
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
15 changes: 14 additions & 1 deletion src/traefik.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def configure(self):
# Ensure the required basic configurations and folders exist
tcp_entrypoints = self._tcp_entrypoints
self._update_static_configuration(tcp_entrypoints)
self._setup_dynamic_config_folder()

if self._tls_enabled:
self._update_tls_configuration()
Expand Down Expand Up @@ -532,7 +533,14 @@ def delete_dynamic_config(self, file_name: str):
logger.debug("deleted dynamic configuration file: %s", file_name)

def add_dynamic_config(self, file_name: str, config: str):
"""Push a yaml to the dynamic config dir."""
"""Push a yaml to the dynamic config dir.
The dynamic config dir is assumed to exist already.
"""
# make_dirs is technically not necessary at runtime, since traefik.configure() should
# guarantee that the dynamic config dir exists. However, it simplifies testing as it means
# we don't have to worry about setting up manually the traefik container every time we
# simulate an event.
self._container.push(Path(DYNAMIC_CONFIG_DIR) / file_name, config, make_dirs=True)

logger.debug("Updated dynamic configuration file: %s", file_name)
Expand Down Expand Up @@ -585,3 +593,8 @@ def generate_per_unit_tcp_config(prefix: str, host: str, port: int) -> dict:
}
}
return config

def _setup_dynamic_config_folder(self):
# ensure the dynamic config dir exists else traefik will error on startup and fail to
# set up the watcher
self._container.make_dir(DYNAMIC_CONFIG_DIR, make_parents=True)
2 changes: 1 addition & 1 deletion tests/integration/test_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async def test_build_and_deploy(ops_test: OpsTest, traefik_charm):
async def test_ingressed_endpoints_reachable_after_metallb_enabled(ops_test: OpsTest):
ip = await get_address(ops_test, trfk.name)
for ep in get_endpoints(ops_test, scheme="http", netloc=ip):
logger.debug("Attempting to reach %s", ep) # Traceback doesn't spell out the endpoint
logger.info("Attempting to reach %s", ep) # Traceback doesn't spell out the endpoint
urlopen(ep)


Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ deps =
tenacity
-r{toxinidir}/requirements.txt
commands =
pytest -v --tb native --log-cli-level=INFO -s {[vars]tst_path}/integration {posargs}
; pytest -v --tb native --log-cli-level=INFO -s {posargs}
; pytest -v --tb native --log-cli-level=INFO -s {[vars]tst_path}/integration {posargs}
pytest -v --tb native --log-cli-level=INFO -s {posargs}

[testenv:static-{charm,lib}]
description = Static code checking
Expand Down

0 comments on commit 862f2af

Please sign in to comment.