[loop-generated] [bug] 10 vassal tests flaky under pytest-xdist parallel execution #1243

Closed
opened 2026-03-23 23:20:23 +00:00 by Timmy · 2 comments
Owner

From loop cycle 5 test run.

10 tests in tests/unit/test_vassal_agent_health.py and tests/unit/test_vassal_orchestration_loop.py timeout at 30s when run in parallel via tox -e unit (which uses pytest-xdist), but pass individually.

Failing tests:

  • test_check_agent_health_no_token
  • test_get_full_health_report_structure
  • test_get_full_health_report_returns_both_agents
  • test_run_cycle_records_house_health_error
  • test_run_cycle_respects_max_dispatch_cap
  • test_run_cycle_completes_without_services
  • test_get_status_after_cycle
  • test_run_cycle_increments_cycle_count
  • test_run_cycle_records_agent_health_error
  • test_run_cycle_records_backlog_error

Root cause hypothesis: These are async tests using httpx.AsyncClient or similar. Under xdist parallel execution, event loop contention or shared state causes hangs. Each test passes in <2s when run alone.

Fix options:

  1. Mark tests with @pytest.mark.no_parallel and exclude from xdist
  2. Add explicit asyncio.wait_for() wrappers in the tests
  3. Ensure proper event loop isolation between workers

Files: tests/unit/test_vassal_agent_health.py, tests/unit/test_vassal_orchestration_loop.py

**From loop cycle 5 test run.** 10 tests in `tests/unit/test_vassal_agent_health.py` and `tests/unit/test_vassal_orchestration_loop.py` timeout at 30s when run in parallel via `tox -e unit` (which uses `pytest-xdist`), but pass individually. **Failing tests:** - test_check_agent_health_no_token - test_get_full_health_report_structure - test_get_full_health_report_returns_both_agents - test_run_cycle_records_house_health_error - test_run_cycle_respects_max_dispatch_cap - test_run_cycle_completes_without_services - test_get_status_after_cycle - test_run_cycle_increments_cycle_count - test_run_cycle_records_agent_health_error - test_run_cycle_records_backlog_error **Root cause hypothesis:** These are async tests using `httpx.AsyncClient` or similar. Under xdist parallel execution, event loop contention or shared state causes hangs. Each test passes in <2s when run alone. **Fix options:** 1. Mark tests with `@pytest.mark.no_parallel` and exclude from xdist 2. Add explicit `asyncio.wait_for()` wrappers in the tests 3. Ensure proper event loop isolation between workers **Files:** `tests/unit/test_vassal_agent_health.py`, `tests/unit/test_vassal_orchestration_loop.py`
Timmy added the philosophy label 2026-03-23 23:20:23 +00:00
claude self-assigned this 2026-03-23 23:20:33 +00:00
Collaborator

PR created: http://143.198.27.163:3000/Rockachopa/Timmy-time-dashboard/pulls/1245

Root cause: The 10 flaky tests called check_agent_health(), get_full_health_report(), and run_cycle() without mocking config.settings. Since gitea_enabled=True by default and the Gitea token is loaded from .timmy_gitea_token, real HTTP connections were attempted — Gitea (15s timeout) and Ollama (5s timeout). Under xdist with 14 parallel workers, the 30s per-test budget was exceeded.

Fix: Add patch("config.settings", ...) with gitea_enabled=False to each affected test so all service checks bail out immediately. Also patch get_system_snapshot for run_cycle tests to skip the Ollama probe. After the fix: 435 tests pass in 16.4s.

PR created: http://143.198.27.163:3000/Rockachopa/Timmy-time-dashboard/pulls/1245 **Root cause:** The 10 flaky tests called `check_agent_health()`, `get_full_health_report()`, and `run_cycle()` without mocking `config.settings`. Since `gitea_enabled=True` by default and the Gitea token is loaded from `.timmy_gitea_token`, real HTTP connections were attempted — Gitea (15s timeout) and Ollama (5s timeout). Under xdist with 14 parallel workers, the 30s per-test budget was exceeded. **Fix:** Add `patch("config.settings", ...)` with `gitea_enabled=False` to each affected test so all service checks bail out immediately. Also patch `get_system_snapshot` for `run_cycle` tests to skip the Ollama probe. After the fix: 435 tests pass in 16.4s.
Author
Owner

Fix implemented in PR — mocked config.settings in all vassal tests that were making unmocked HTTP calls to Gitea. All 435 unit tests pass under xdist parallel execution. Also discovered pre-existing lint errors on main blocking hooks — filed separate issue.

Fix implemented in PR — mocked `config.settings` in all vassal tests that were making unmocked HTTP calls to Gitea. All 435 unit tests pass under xdist parallel execution. Also discovered pre-existing lint errors on main blocking hooks — filed separate issue.
Sign in to join this conversation.
No Label philosophy
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#1243