Repository navigation
Description
What changed
The four host-state tests that this item listed are tracked in #3585. This item keeps the time budget of the pytest step.
Budget
A full devops ci run on the agent worktree took 6m 53s for the pytest step. The budget is 5 minutes. The slowest test is tests/commands/test_ai_local_dry_run.py::test_local_ai_commands_run_cleanly, at 58 s.
pytest-xdist is already a test dependency, and the test row of CI runs in four shards (#3050). The last 20 runs of Tests & Coverage took 290 s on average, and the limit is 300 s. The slow runs are local runs on a host that other agents also load.
Expected
The pytest step of devops ci meets the 5-minute budget.
Proposed design
Problem statement
Four tests fail on the agent worktree host because each one reads host state that it does not control. The same tests fail on a clean checkout of origin/main at d254410. The pytest step of devops ci also takes 6m 53s, and the budget is 5 minutes. This change isolates the host state that each test reads, and it runs the suite in parallel workers.
Acceptance criteria
Requirement: SSH prefix test controls the project config
The test test_get_ssh_key_prefix_resolution SHALL set the project-config layer it reads to a file under tmp_path, so no config on the host supplies the prefix.
Scenario: Host config in an ancestor
- WHEN A
config.yamlthat namesssh.key_prefix: devops_clisits in an ancestor of the temporary root, and the test runs. - THEN The test passes and asserts the prefix
my_plain_repo.
Requirement: Project config path test controls the search root
The test test_find_project_config_path_skips_directory SHALL search from a base directory that the test controls, so a host file at /tmp/config.yaml does not change the result.
Scenario: Host file at the temporary root
- WHEN
/tmp/config.yamlexists and the test runs. - THEN The test passes, and
_find_project_config_pathreturnsNonefor the directory and the resolved path for the non-existent file.
Requirement: Install-tools status test controls tool detection
The test test_mark_only_commands_under_global_dry_run SHALL patch the tool detection that install-tools status reads, so the output does not depend on the programs on the host.
Scenario: Host has the tools installed
- WHEN Every tool of the install list is on the host and the test runs.
- THEN The test passes and the status output holds the
not installedline that it asserts.
Requirement: Direct executor test controls the tool and the network
The test test_the_direct_executor_refuses_a_network_profile_before_it_starts_the_tool[direct] SHALL patch the popeye lookup and the kube API address it reads, so the refusal does not depend on the host.
Scenario: Host has popeye and a loopback listener
- WHEN A
popeyebinary is on PATH and a listener answers on the kube API loopback port, and the test runs. - THEN The test passes with the
SandboxErrorthat names the network profile, and no process that it started stays after it.
Requirement: Pytest command uses parallel workers
The pytest command that devops ci test builds SHALL pass -n auto to pytest through pytest-xdist, which the project declares as a test dependency.
Scenario: Built pytest command
- WHEN A test reads the pytest arguments that
devops ci testbuilds. - THEN The arguments hold
-n auto.
Requirement: Suite meets the five-minute budget
The pytest step of devops ci test SHALL finish in less than 300 seconds on the agent worktree host, with every test passing.
Scenario: Full suite on the agent host
- WHEN The full suite runs on the agent worktree host with the parallel command.
- THEN The step reports less than 300 seconds and no failed test.
Existing Tool Considered
No alternatives check has run. pytest covers host-state isolation through monkeypatch, tmp_path and skipif. pytest-xdist covers the duration through parallel workers. Both are open and maintained. What they lack: neither isolates a test's host state or splits the suite for you. The four tests need their own isolation edits. The parallel workers need those edits first, because shared host state breaks under them.
Key questions
- Which host state does
test_get_ssh_key_prefix_resolutionread?: The test leaves the project-config layer to the host. It setsssh.key_prefixto None, and it asksget_ssh_key_prefixfor a directory under the temporary root. A config that the host holds in an ancestor of that root suppliesdevops_cli. [sources: tests/crypto/test_ssh.py:142, tests/crypto/test_ssh.py:144, src/devops_cli/crypto/ssh_keys.py, tests/telemetry/test_config_env_overrides.py] - Why does
test_find_project_config_path_skips_directoryresolve/tmp/config.yaml?:DEVOPS_CLI_CONFIGnames a directory, and the function skips it. The search then walks up frombase_dir, which is under the host's temporary root. Aconfig.yamlat that root is the result. [sources: tests/telemetry/test_config_env_overrides.py, src/devops_cli/config/settings.py] - Why does
test_mark_only_commands_under_global_dry_runreport the tool as installed?: The test asserts the literalnot installedin the output ofinstall-tools status. That command reads the programs installed on the host. On a host with the tools installed, the line is absent. [sources: tests/commands/test_devcontainer_install_tools_dry_run.py, src/devops_cli/commands/install_tools.py] - Why does the direct executor test error at teardown on the agent host?: The test leaves two host facts to the host. The first is whether a
popeyebinary is on PATH. The second is whether the kube API loopback port has a listener. The agent host has both, so the test does not reach the refusal that it asserts, and its teardown reports the error. [sources: tests/ai/test_tool_executor_contract.py, src/devops_cli/security/tool_executor.py] - How does each test isolate the host state it reads?: Each test sets the host input that it reads to a value under
tmp_pathwithmonkeypatch.DEVOPS_CLI_CONFIGnames a config file that the test writes.PATHor the tool lookup hides the host programs. The install-tools detector reports absent. A test usespytest.mark.skipifonly for a capability that it needs and cannot simulate, as thebwrapmark does. (best practice) [sources: tests/ai/test_tool_executor_contract.py]- Chosen: Set the input under
tmp_pathwithmonkeypatch. The test owns the value, so it passes on every host and keeps its coverage. - Rejected: Skip the test when the host state is present. The test stops checking on the hosts that show the defect, and the suite passes with the defect present.
- Rejected: Run the test in a subprocess with a clean environment. It adds a second runner and slows the suite, and the budget is already over.
- Chosen: Set the input under
- Which test sets the floor of the suite duration?:
tests/commands/test_ai_local_dry_run.py::test_local_ai_commands_run_cleanlytakes 58 s and runs 20 CLI commands. It is 9 percent of the 623 s. Cutting it alone leaves the step over the 5-minute budget. [sources: tests/commands/test_ai_local_dry_run.py] - How does the pytest step meet the 5-minute budget?: Run the suite with
pytest-xdistworkers through-n autoin the command thatdevops ci testbuilds. Do this after the four tests isolate host state. Addpytest-xdistto the test dependencies if the project does not declare it. (best practice) [sources: docs/adr/0004-ci-is-the-authoritative-gate.md, tests/commands/test_ai_local_dry_run.py]- Chosen: pytest-xdist with
-n auto. The workers divide 623 s of independent tests, so the wall time falls well under 300 s on a host with four or more cores. The tool is open and maintained, and pytest-cov supports it. - Rejected: Shard the suite across CI jobs. ADR 0004 rejects per-check scoping and matrix required checks, and a matrix needs an aggregating job.
- Rejected: Cut the slowest tests. The slowest test is 58 s of 623 s, so the step stays over 300 s.
- Rejected: Raise the 5-minute budget. The issue sets the budget, and the change must meet it.
- Chosen: pytest-xdist with
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Alternatives check of 2026-11-07: in-use.
The item already names this tool.
Tool: pytest-xdist (https://pypi.org/project/pytest-xdist), MIT, last activity 2025-07-01, not maintained.
Activity
dan-petty commentedon Nov 5, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(ci)scope of the title gives the scope.The CI gate is failing and blocks all development work.A broken CI gate blocks all merges and pushes.Four tests need host-state isolation and one needs a skip condition.Make the four host-state-dependent tests hermetic so they pass on any hostas the change that both ask for.Both items ask for the same four host-state tests to be fixed so they pass regardless of the host environment.A person closes one of the two if that is so.dan-petty commentedon Nov 5, 2026
The four host-state tests fail on a clean checkout of origin/main (commit d254410) in the devcontainer of this sandbox too:
Each run is
uv run devops ci test <file>. The change of feat/3039 does not touch these modules.dan-petty commentedon Nov 5, 2026
Evidence from the full
uv run devops ciof feat/3276-negative-search-accepts-repeated-e, run in the devcontainer on this host.tests/ai/test_tool_executor_contract.py.tests/commands/test_ai_local_dry_run.py::test_local_ai_commands_run_cleanlyat 70.7 s.The change for #3276 adds no test that takes time. Its new tests run in under a second each.
devops-cli-service commentedon Nov 5, 2026
Status set to Ready at d254410 (see proposed design in issue body).
dan-petty commentedon Nov 5, 2026
A review of the branch for #3276 found the same failures on this host.
uv run devops cion that branch ended with four failed tests and one error. The same four tests and the error also fail on a clean checkout of origin/main on this host:The same run warned that pytest took 5m 21s, over the 5m budget. Another gate run held the one gate slot during that time.
This comment adds evidence to this issue. It does not change its scope.
dan-petty commentedon Nov 5, 2026
Timing observed on 2026-11-05 in the local run of
uv run devops cifor pull request #3602. The pytest job took 6 min 43 s, over the 5 min budget. Its slowest test took 53.80 s (tests/commands/test_ai_local_dry_run.py::test_local_ai_commands_run_cleanly). A narrowed run oftests/roadmap,tests/ci,tests/invariantsandtests/openspectook 7 min 02 s for 4696 items.11 remaining items
docs(openspec): plan #3593 Record what the 5-minute test budget measures
fix(ci): State the budget's subject in the test guide (#3593)
docs(openspec): archive the change (#3593)
devops-cli-service commentedon Nov 8, 2026
Pull request #4189 is ready for review. The checks passed.
Spend: 27 model requests, 892239 input tokens, 9505 output tokens.
devops-cli-service commentedon Nov 8, 2026
The runner Job devops-cli-runner-20261108-221536-6c53 ended: succeeded.
Image digest: sha256:e625ddb622bcb2df4b4683329b37f666852516e9c7873fce95479b857cf7ab8b
The last lines of its log:
devops-cli-service commentedon Nov 8, 2026
Released in v0.96.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.96.0
devops-cli-service commentedon Nov 8, 2026
Live since 2026-11-08 23:37 UTC