chore(harness): dedicated DH_PORT so tests never collide with a dev server - #40
Merged
Conversation
…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>
This was referenced Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Running the pytest harness while a dev/"production"
dh_serveris 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 normalgleam run/godotbehaviour is unchanged. The pytest harness setsDH_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.dh_server.gleam,server.gleam): readsDH_PORTvia the existingenvoy.get(...)idiom; robust parse (missing/invalid/≤0 → 8484); port threaded intoserver.start(removed the moduleconst port).network_client.gd):SERVER_URLconst → computed in_ready()fromOS.get_environment("DH_PORT"), fallback 8484; both call sites updated.server_fixture.py,automation.py,dh_client.py,benchmark.py,conftest.py,shot_m35_space.py): dedicatedTEST_PORT(8585), server + launched client both getDH_PORTin their env;benchmark.pydeliberately keeps its 8484 default (targets a manually-run server).Verification
DH_PORT=8600(netstat LISTENING); with noDH_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 onmain, so it's pre-existing, not a regression.Review notes (addressed)
Reviewed independently; the one Important finding —
DHClient.DEFAULT_URLwas a module constant frozen as a default arg, making client port selection depend onconftestimportingserver_fixturefirst — is fixed by late-binding the URL atDHClient()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