mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-10-14 05:18:54 +00:00
test(integration): config hot-reload proof via directory provider
Single-file file-provider watch (providers.file.filename) never fires under Docker Desktop's VirtioFS bind mount — empirically confirmed against this stack. Traefik's directory-based file provider (providers.file.directory) is the fix, and is also the correct pattern for a Kubernetes ConfigMap mount (a symlink swap, which a single-file watch never observes either). integration/traefik/traefik.yml: providers.file.filename -> providers.file.directory (watch: true unchanged). docker-compose.yml: both traefik1 and traefik2 now bind-mount integration/traefik/dynamic/ (a directory) instead of the single rendered dynamic.yml. Makefile's integration-up now mkdir -p's and renders into integration/traefik/dynamic/dynamic.yml; .gitignore updated to match. New TestConfigHotReload (build tag integration): baseline chat succeeds, then a sustained ~20rps request loop runs against an existing model while the rendered config is rewritten (temp file + os.Rename, atomic, mirroring a k8s symlink swap) to add a new model alias. /v1/models is polled up to 30s for the alias to appear. The request loop's zero- failures property is asserted unconditionally, whether or not the watch fired within the bound; only when it fired does the test also chat through the new alias and expect 200. Empirically, on this host the directory watch fires reliably but with variable latency (observed under 1s up to several seconds; one run exceeded the 30s bound and hit the Skip path with zero request failures throughout). Found and fixed during verification: the test's cleanup step now writes the restore atomically and WAITS for it to propagate before returning. Without that wait, a delayed rebuild triggered by the restore could land during a later test's own non-atomic config write (TestUsersFileHotReload's users.json), reading a torn file mid-write and failing plugin construction outright — a global 404 outage until the next unrelated config change happened to trigger a successful rebuild. Reproduced and confirmed fixed: two full `make integration` runs (cold teardown-to-up, then immediately again) both pass end to end.
This commit is contained in:
@@ -28,12 +28,15 @@ INTEGRATION_ALICE_KEY := sk-int-alice
|
||||
# INTEGRATION_REAL=1) never hardcodes one operator's personal hostname as
|
||||
# the only option: `INTEGRATION_REAL_BASEURL=https://other.example make
|
||||
# integration` points it elsewhere. Rendered into
|
||||
# integration/traefik/dynamic.yml (git-ignored) from the checked-in
|
||||
# dynamic.yml.tmpl by integration-up, below.
|
||||
# integration/traefik/dynamic/dynamic.yml (git-ignored directory) from the
|
||||
# checked-in dynamic.yml.tmpl by integration-up, below. Traefik's file
|
||||
# provider watches that whole directory (traefik.yml's providers.file.directory),
|
||||
# not the single rendered file — see traefik.yml's own comment for why.
|
||||
INTEGRATION_REAL_BASEURL ?= https://llmgw.example.com
|
||||
|
||||
integration-up:
|
||||
sed 's#__INTEGRATION_REAL_BASEURL__#$(INTEGRATION_REAL_BASEURL)#' integration/traefik/dynamic.yml.tmpl > integration/traefik/dynamic.yml
|
||||
mkdir -p integration/traefik/dynamic
|
||||
sed 's#__INTEGRATION_REAL_BASEURL__#$(INTEGRATION_REAL_BASEURL)#' integration/traefik/dynamic.yml.tmpl > integration/traefik/dynamic/dynamic.yml
|
||||
docker compose -f $(INTEGRATION_COMPOSE) up -d --build
|
||||
|
||||
integration-wait:
|
||||
|
||||
Reference in New Issue
Block a user