fix: wire auto_install_agent_deps into server.py startup (#216)
* fix: wire auto_install_agent_deps into server.py startup; add api/startup.py to ARCHITECTURE.md * fix(tests): kill stale process on test port before server start in conftest Stale servers left by QA harness runs (ports 8792/8793 etc.) or prior test sessions could interfere with conftest starting its own server on TEST_PORT (8788). If the port was already occupied, _wait_for_server hit the wrong server and tests got unexpected 404s/500s, failing non-deterministically — the 'conftest isolation issue' seen this session. Fix: run fuser -k on TEST_PORT before launching the new server process, with a 0.5s sleep for port release. The full suite now runs 571/571 reliably regardless of what other servers were previously active. --------- Co-authored-by: Nathan Esquenazi <nesquena@gmail.com>
This commit is contained in:
@@ -210,6 +210,18 @@ def test_server():
|
||||
Start an isolated test server on TEST_PORT with a clean state directory.
|
||||
Paths are discovered dynamically -- no hardcoded absolute path assumptions.
|
||||
"""
|
||||
# Kill any leftover process on the test port before starting.
|
||||
# Stale servers from QA harness runs or prior test sessions cause
|
||||
# conftest to think the server is already up, producing false failures.
|
||||
try:
|
||||
import subprocess as _sp
|
||||
_sp.run(['fuser', '-k', f'{TEST_PORT}/tcp'],
|
||||
capture_output=True, timeout=5)
|
||||
except Exception:
|
||||
pass
|
||||
import time as _time
|
||||
_time.sleep(0.5) # brief pause to let the port release
|
||||
|
||||
# Clean slate
|
||||
if TEST_STATE_DIR.exists():
|
||||
shutil.rmtree(TEST_STATE_DIR)
|
||||
|
||||
Reference in New Issue
Block a user