Skip to content

fix(tests): the remaining test waits end on an event or a process exit, not on a deadline of their own #2138

Description

@dan-petty

What happened

#2092 made four tests wait for an event that the code under test signals, not for a time window, and added wait_while_running(condition, process) to tests/support/waits.py. Other waits in tests/ still keep a deadline of their own, so they can fail on a loaded host although the code works:

  • 16 waits of 5 s and 10 s in tests/test_ui_reactive.py.
  • Waits in tests/test_trace_propagation.py, tests/test_k8s_port_forward_daemon.py, tests/test_http_connection_pool.py, tests/test_roadmap_github_store.py, tests/test_github_session.py and tests/test_ai_client_network.py.
  • The 30 s waits on a new devops process in tests/test_cli_startup_imports.py and tests/test_github_session.py. On 2026-10-24 a new devops took more than 30 s to start under load, and 0.44 s to 0.51 s on a quiet host.

What should happen

Each wait ends on the event that the code signals, or on the exit of the process it waits for (wait_while_running), as docs/TESTING.md requires. A hang fails at the pytest timeout, not at a deadline in the test.

Evidence

Acceptance criteria

  • No test in the files above passes a deadline of its own to a wait for an event or a process.
  • Each changed test passes 50 times in a row under CPU load (uv run devops ci test <file> --repeat 50).

Source: #2092

Proposed design

Problem statement

Tests in eight files wait for events or process exits using hardcoded deadlines of 5 s, 10 s, or 30 s. These deadlines can expire on a loaded host even when the code works correctly. Each wait must end on the event the code signals or on the exit of the process it waits for, as docs/TESTING.md requires. A hang fails at the pytest timeout, not at a deadline in the test.

Acceptance criteria

  • Criterion 1: No test in the eight listed files passes a deadline of its own to a wait for an event or a process.
    Verification: git grep -n 'wait(.*timeout=[0-9]|join(timeout=[0-9])' tests/test_ui_reactive.py tests/test_trace_propagation.py tests/test_k8s_port_forward_daemon.py tests/test_http_connection_pool.py tests/test_roadmap_github_store.py tests/test_github_session.py tests/test_ai_client_network.py tests/test_cli_startup_imports.py returns no lines.
  • Criterion 2: Each changed test file passes 50 consecutive runs under CPU load.
    Verification: uv run devops ci test --repeat 50 exits 0 for each of the eight files.
  • Criterion 3: The 30 s waits on a new devops process in test_cli_startup_imports.py and test_github_session.py use wait_while_running.
    Verification: git grep -n 'wait_while_running' tests/test_cli_startup_imports.py tests/test_github_session.py shows the wait for the devops process uses wait_while_running.

Key questions

  • Should the 5 s and 10 s waits in test_ui_reactive.py use THREAD_HANDOFF_BOUND_SECONDS?: Yes. The waits.py docstring states that a wait expecting an event from another thread uses THREAD_HANDOFF_BOUND_SECONDS. [sources: tests/support/waits.py]
  • Should the 30 s waits on a new devops process use wait_while_running?: Yes. The waits.py docstring states that a wait for an event of a process the test started uses wait_while_running and has no bound of its own. [sources: tests/support/waits.py]
  • Do any waits in the listed files check that nothing happens and should keep their own window?: The issue states no test in the files above passes a deadline of its own to a wait for an event or a process. A wait that checks nothing happens keeps a short window with a comment, per the waits.py docstring. The issue does not name any such wait in the listed files. (proposed) [sources: tests/support/waits.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/test
    on Oct 24, 2026
  2. dan-petty commented on Oct 24, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.

    • Type: type/test. The candidate proposes changes to test behavior and waits for events or process exits rather than using hardcoded deadlines.
    • Priority: P2-Medium. Improves test reliability under load but does not fix a critical failure or security issue.
    • Value: High. Improves test stability, reduces flakiness, and helps with CI performance under load.
    • Effort: Medium. Requires modifying multiple test files to replace hardcoded timeouts with event-based waits.
    • Related: fix(tests): the process and session-exit tests finish under 5 seconds and hold under load #1748, which asks for a different change. Both items address test waits that fail under load, but the candidate focuses on event-based waiting while item 1748 addresses process and session-exit tests with bounded waits.
  3. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Status set to Ready at bb46660 (see proposed design in issue body).

  4. added
    priority/p2-medium
    status/ready
    effort/medium
    value/high
    type/bug
    status/in-progress
    and removed
    type/test
    status/ready
    on Oct 28, 2026
  5. removed
    status/in-progress
    on Oct 31, 2026
  6. added a commit that references this issue on Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumsource/agenttype/bugvalue/high

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions