Skip to content

Stop preset tests from waiting on the tail poll - #4089

Merged
r4victor merged 2 commits into
masterfrom
pr_fix_slow_preset_tests
Aug 4, 2026
Merged

Stop preset tests from waiting on the tail poll#4089
r4victor merged 2 commits into
masterfrom
pr_fix_slow_preset_tests

Conversation

@r4victor

@r4victor r4victor commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

What

The preset agent writes its output to files rather than pipes, so reading it means polling: _FileLineReader._POLL_SECONDS = 0.2. When there is no new data and the agent process is still alive, the reader sleeps 200ms. Tests write the whole fake-agent output up front and the process exits in ~20ms, so every run_preset_agent call waited out a full poll it had nothing to wait for.

Tests that trigger a resume pay it 2-3 times, which matched the timings exactly:

attempts poll cost measured
1 200ms 218, 220, 234ms
2 400ms 441, 459ms
3 600ms 673ms

An autouse fixture in the presets test package sets the interval to 0.

Effect

test_agent.py goes from 4.18s to 1.65s, 41 passed. It was the most expensive test file in the suite.

What remains is genuine: test_creates_private_cli_home_and_dstack_wrapper spawns the real dstack CLI to prove the generated workspace wrapper executes, which cannot be shown without executing it.

No production code changed.

Also

Two notes in AGENTS.md on keeping the suite fast, since this was the same class of issue as the lock-retry sleeps fixed in #4088.


AI assistance: written with Claude Code.

The agent's output goes to files rather than pipes, so reading it polls every
200ms, and every `run_preset_agent` call waited once after the agent had already
exited. Tests write the whole output up front, so `test_agent.py` spent 2.5s of
its 4.3s sleeping.
@r4victor
r4victor merged commit 0d84fe0 into master Aug 4, 2026
27 checks passed
@r4victor
r4victor deleted the pr_fix_slow_preset_tests branch August 4, 2026 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant