From d7e82ae5ca3b3640129fc21b2d0d4318815a687f Mon Sep 17 00:00:00 2001 From: Victor Skvortsov Date: Tue, 4 Aug 2026 16:39:15 +0500 Subject: [PATCH 1/2] Stop preset tests from waiting on the tail poll 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. --- .../_internal/cli/services/presets/conftest.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/tests/_internal/cli/services/presets/conftest.py diff --git a/src/tests/_internal/cli/services/presets/conftest.py b/src/tests/_internal/cli/services/presets/conftest.py new file mode 100644 index 000000000..843d796f0 --- /dev/null +++ b/src/tests/_internal/cli/services/presets/conftest.py @@ -0,0 +1,15 @@ +import pytest + +from dstack._internal.cli.services.presets.tail import _FileLineReader + + +@pytest.fixture(autouse=True) +def no_tail_poll_wait(monkeypatch: pytest.MonkeyPatch): + """ + Stops the tailers from waiting between reads. + + The agent writes its output to files rather than pipes, so reading it means polling, + and `_POLL_SECONDS` makes every run wait once after the agent has already exited. + Tests write the whole output up front, so there is nothing to wait for. + """ + monkeypatch.setattr(_FileLineReader, "_POLL_SECONDS", 0) From bd9e497ce81c0724ca2a4e9d1a55af3b5621c02b Mon Sep 17 00:00:00 2001 From: Victor Skvortsov Date: Tue, 4 Aug 2026 16:49:54 +0500 Subject: [PATCH 2/2] Add test speed guidance to AGENTS.md --- AGENTS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index 99f4392c3..74f53335d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -39,6 +39,8 @@ Before touching a subsystem, read the relevant notes in `contributing/`: `ARCHIT - Speed up large runs with `-n auto` (pytest-xdist), e.g. `uv run pytest -n auto`. - Group tests for the same unit (function/class) using `Test*` classes that mirror unit's name. - Keep tests hermetic (network disabled except localhost per `[tool.pytest.ini_options]` in `pyproject.toml`); stub cloud calls with mocks. +- Keep the suite fast. Never let a test wait on real time. +- Machinery that costs hundreds of milliseconds per test (spawning a subprocess, starting a container, generating a key, real HTTP) has to earn its place by covering something cheaper tests cannot. Say so in the test when it does. On the other hand, losing black-box coverage or making the test hard to follow is worse than the milliseconds it costs. ## Commit & Pull Request Guidelines - Name branches `issue_{issue_num}_{title}` when the work tracks an issue (e.g. `issue_3959_replicated_alb_gateways`), and `pr_{title}` otherwise.