Use dynamic ports in the last three hardcoded test bindings #698

Merged
weichen merged 2 commits from fix/svc-test-port-governance-final into main 2026-10-22 09:33:12 +00:00
Owner

Why: three more test methods in tests/test_svc.py still bound hardcoded ports, the same class of issue closed for test_addr_change_keeps_database_and_auth and register_agent in the previous pull request. Any of them could fail intermittently when the runner already held the port, and none of the failures would point at the real cause.

Evidence:

  • The ports that actually matter are the ones seed_agent binds: its stub binary starts a real HTTPServer, whereas register_pg only writes text into svc.env. Both are fixed anyway so the file has no stray literals.
  • Verified by occupation rather than assumption: with 18791, 18792, 18796, 18797, 18798 and 18799 each held by an unrelated python3 -m http.server, all three tests still pass. Before the change the first of them failed with [svc]端口被占用(非本服务).
  • register_pg ports and the DSN strings are coupled — the DSN must match what was registered or the recovery path resolves a different database — so each pair now shares one pg_port from free_test_port(), and each seed_agent shares one port with its --addr.
  • In the refusal test the conflicting DSN port is allocated separately from the pg1 registration, so the "dbref and dsn point at different databases" construction still holds.
  • No new import and no new helper: free_test_port was already imported from the shared tests/_port_alloc.py in an earlier change. No assertion was removed, skipped, or relaxed, and no test logic was altered beyond the port source.
  • tests.test_svc is green (23 tests) as is the broader svc suite (97 tests, 1 skipped). The full make test and the CI test job cover the rest.

With this, the file no longer carries any hardcoded binding port, closing the last of the cases found by scanning the test tree.

Refs: follows the same governance that introduced tests/_port_alloc.py; closes the remaining three methods left out of the previous pull request.

Why: three more test methods in `tests/test_svc.py` still bound hardcoded ports, the same class of issue closed for `test_addr_change_keeps_database_and_auth` and `register_agent` in the previous pull request. Any of them could fail intermittently when the runner already held the port, and none of the failures would point at the real cause. Evidence: - The ports that actually matter are the ones `seed_agent` binds: its stub binary starts a real `HTTPServer`, whereas `register_pg` only writes text into `svc.env`. Both are fixed anyway so the file has no stray literals. - Verified by occupation rather than assumption: with 18791, 18792, 18796, 18797, 18798 and 18799 each held by an unrelated `python3 -m http.server`, all three tests still pass. Before the change the first of them failed with `[svc]端口被占用(非本服务)`. - `register_pg` ports and the DSN strings are coupled — the DSN must match what was registered or the recovery path resolves a different database — so each pair now shares one `pg_port` from `free_test_port()`, and each `seed_agent` shares one `port` with its `--addr`. - In the refusal test the conflicting DSN port is allocated separately from the `pg1` registration, so the "dbref and dsn point at different databases" construction still holds. - No new import and no new helper: `free_test_port` was already imported from the shared `tests/_port_alloc.py` in an earlier change. No assertion was removed, skipped, or relaxed, and no test logic was altered beyond the port source. - `tests.test_svc` is green (23 tests) as is the broader svc suite (97 tests, 1 skipped). The full `make test` and the CI `test` job cover the rest. With this, the file no longer carries any hardcoded binding port, closing the last of the cases found by scanning the test tree. Refs: follows the same governance that introduced `tests/_port_alloc.py`; closes the remaining three methods left out of the previous pull request.
weichen added 2 commits 2026-10-22 09:19:50 +00:00
Why: establish the authorized task workspace and its initial baseline.

Evidence: preserved precheck receipt in .task/fix-svc-test-port-governance-final.md; R0=955a32de2bb49171348bad5f566cce935df19212.

Impact: task metadata only; the feature workspace starts at 955a32de2b.

Refs: .task/fix-svc-test-port-governance-final.md
agent-exec transport 848ba0b1bdee6617e7757143cdffa2e9/e0b4b463efec
ci / svc-realcombo (pull_request) Successful in 2m53s
ci / test (pull_request) Successful in 8m57s
ci / test-pg (pull_request) Successful in 12m24s
60bd1bedb4
weichen merged commit 98ee59c477 into main 2026-10-22 09:33:12 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weichen/Agent-System-Dev#698