test_upgrade_regime_performance.py
file-level
1
files
1
commits
0
hotspots
0
🧊 dead
0
💥 blast risk
| 1 | """Performance — Track O / O3 upgrade-regime dry-run bound (§O2.9 performance).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | import time |
| 6 | from pathlib import Path |
| 7 | |
| 8 | from cli.kit_root import kit_root |
| 9 | from tests.support import ( |
| 10 | FIXTURES, |
| 11 | make_runner, |
| 12 | muse_mirror_status_runner, |
| 13 | muse_status_runner, |
| 14 | ok, |
| 15 | run_cli, |
| 16 | seed_muse_substrate, |
| 17 | ) |
| 18 | |
| 19 | MAX_SINGLE_DRY_RUN_SECONDS = 15.0 |
| 20 | |
| 21 | |
| 22 | def test_single_dry_run_bounded(tmp_path: Path) -> None: |
| 23 | seed_muse_substrate(tmp_path) |
| 24 | assert ( |
| 25 | run_cli( |
| 26 | [ |
| 27 | "init", |
| 28 | "--from-config", |
| 29 | str(FIXTURES / "config-muse-only.yaml"), |
| 30 | "--non-interactive", |
| 31 | ], |
| 32 | cwd=tmp_path, |
| 33 | kit=kit_root(), |
| 34 | runner=muse_status_runner(tmp_path), |
| 35 | ) |
| 36 | == 0 |
| 37 | ) |
| 38 | base = muse_mirror_status_runner(tmp_path) |
| 39 | responses = dict(base.responses) |
| 40 | responses["git remote get-url origin"] = ok("[email protected]:o/r.git") |
| 41 | runner = make_runner(responses) |
| 42 | start = time.perf_counter() |
| 43 | code = run_cli( |
| 44 | ["upgrade-regime", "--from", "muse-only", "--to", "muse+git-mirror", "--dry-run"], |
| 45 | cwd=tmp_path, |
| 46 | kit=kit_root(), |
| 47 | runner=runner, |
| 48 | ) |
| 49 | elapsed = time.perf_counter() - start |
| 50 | assert code == 0 |
| 51 | assert elapsed < MAX_SINGLE_DRY_RUN_SECONDS, f"dry-run too slow: {elapsed:.2f}s" |