test_lac_performance.py
python
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
9 hours ago
| 1 | """Performance tests — Landing + access clarity (§LAC.12).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | import time |
| 6 | from pathlib import Path |
| 7 | |
| 8 | from tests.fixtures.app import seed_app_repo, start_test_app |
| 9 | from tools.app.engine import handle_health |
| 10 | from tools.landing.validate import validate_landing |
| 11 | |
| 12 | KIT_ROOT = Path(__file__).resolve().parents[2] |
| 13 | |
| 14 | |
| 15 | def test_landing_validator_within_k12_bound() -> None: |
| 16 | start = time.monotonic() |
| 17 | result = validate_landing(KIT_ROOT) |
| 18 | elapsed = time.monotonic() - start |
| 19 | assert result.ok, result.errors |
| 20 | assert elapsed < 0.5 |
| 21 | |
| 22 | |
| 23 | def test_health_additive_no_full_repo_walk(tmp_path: Path) -> None: |
| 24 | """repo_root on health is Path.resolve only — must stay sub-millisecond class locally.""" |
| 25 | seed_app_repo(tmp_path) |
| 26 | # Create a deep dummy tree that a naive walk would notice. |
| 27 | deep = tmp_path |
| 28 | for i in range(40): |
| 29 | deep = deep / f"d{i}" |
| 30 | deep.mkdir() |
| 31 | (deep / "f.txt").write_text("x" * 100, encoding="utf-8") |
| 32 | |
| 33 | start = time.monotonic() |
| 34 | for _ in range(200): |
| 35 | envelope = handle_health(port=1, bind="127.0.0.1", repo_root=tmp_path) |
| 36 | assert envelope.result is not None |
| 37 | assert envelope.result["repo_root"] == str(tmp_path.resolve()) |
| 38 | elapsed = time.monotonic() - start |
| 39 | assert elapsed < 0.25 |
| 40 | |
| 41 | handle, client = start_test_app(tmp_path) |
| 42 | try: |
| 43 | t0 = time.monotonic() |
| 44 | for _ in range(50): |
| 45 | status, health = client.get("/api/health") |
| 46 | assert status == 200 |
| 47 | assert health["result"]["repo_root"] == str(tmp_path.resolve()) |
| 48 | assert time.monotonic() - t0 < 2.0 |
| 49 | finally: |
| 50 | handle.shutdown() |
File History
1 commit
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
9 hours ago