Skip to content

chore(harness): dedicated DH_PORT so tests never collide with a dev server - #40

Merged
Dibujaron merged 2 commits into
mainfrom
chore/harness-dedicated-port
Jul 21, 2026
Merged

chore(harness): dedicated DH_PORT so tests never collide with a dev server#40
Dibujaron merged 2 commits into
mainfrom
chore/harness-dedicated-port

Conversation

@Dibujaron

Copy link
Copy Markdown
Owner

Why

Running the pytest harness while a dev/"production" dh_server is up on the default 8484 made the harness refuse to start (its freshness guard treats a live 8484 as a stale/shared server). This decouples them.

What

A single env var DH_PORT, honoured by both the server and the Godot client, defaulting to 8484 — so normal gleam run / godot behaviour is unchanged. The pytest harness sets DH_PORT=8585 (a dedicated test port) for both the server it spawns and the client it launches, and builds its own URLs/guards from it.

  • Server (dh_server.gleam, server.gleam): reads DH_PORT via the existing envoy.get(...) idiom; robust parse (missing/invalid/≤0 → 8484); port threaded into server.start (removed the module const port).
  • Client (network_client.gd): SERVER_URL const → computed in _ready() from OS.get_environment("DH_PORT"), fallback 8484; both call sites updated.
  • Harness (server_fixture.py, automation.py, dh_client.py, benchmark.py, conftest.py, shot_m35_space.py): dedicated TEST_PORT (8585), server + launched client both get DH_PORT in their env; benchmark.py deliberately keeps its 8484 default (targets a manually-run server).

Verification

  • Server binds DH_PORT=8600 (netstat LISTENING); with no DH_PORT, binds 8484. Default preserved on both server and client.
  • gleam test: 240 passed (matches main).
  • pytest harness/test_m1_flight.py: server ran on 8585, client connected, 5 passed / 1 failed — the 1 failure (test_two_clients_see_each_other_fly, a rail-position timing assertion) reproduces identically on main, so it's pre-existing, not a regression.

Review notes (addressed)

Reviewed independently; the one Important finding — DHClient.DEFAULT_URL was a module constant frozen as a default arg, making client port selection depend on conftest importing server_fixture first — is fixed by late-binding the URL at DHClient() construction (commit 2a2b30c). Minor remaining: TEST_PORT = int(os.environ["DH_PORT"]) raises on a non-numeric override (fail-fast for a test harness, vs the server's graceful fallback) — left intentionally.

Separate from the decorated-interiors (#36) work.

🤖 Generated with Claude Code

Dibujaron and others added 2 commits July 19, 2026 20:47
…with a dev server

Server (dh_server.gleam/server.gleam) and client (network_client.gd) now
read DH_PORT at startup, defaulting to 8484 so plain gleam run/godot
behaviour is unchanged. The pytest harness (server_fixture.py,
automation.py, dh_client.py, conftest.py, shot_m35_space.py) sets
DH_PORT=8585 for the server it spawns and any client it launches, and
builds its own URLs from that port, so a running dev server on 8484 no
longer blocks it. benchmark.py's --url default is left at 8484 since it
targets a manually-run server.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Review follow-up: DEFAULT_URL was a module constant frozen as a default arg,
so client-side port selection depended on conftest importing server_fixture
(which stamps DH_PORT) before dh_client. Read DH_PORT at construction instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Dibujaron
Dibujaron merged commit 29ea03e into main Jul 21, 2026
1 check passed
@Dibujaron
Dibujaron deleted the chore/harness-dedicated-port branch July 21, 2026 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant