test_track_o_stress.py python
51 lines 1.6 KB
Raw
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 1 day ago
1 """Stress tests — Track O harness on large duplicated fixtures (§O0.8 stress)."""
2
3 from __future__ import annotations
4
5 import time
6 from pathlib import Path
7
8 from tools.track_o.validate import (
9 MINIMAL_VALID_CONTRACT,
10 validate_contract_fixture,
11 validate_track_o_pack,
12 )
13
14 KIT_ROOT = Path(__file__).resolve().parents[2]
15 REPEAT_N = 20
16
17
18 def test_large_duplicated_heading_fixture_bounded() -> None:
19 """Duplicated stage headings must not hang or grow unboundedly."""
20 pad = "\n".join(
21 f"### Stage 1 — Start pad-{i}\n" + ("x" * 2000) for i in range(500)
22 )
23 body = MINIMAL_VALID_CONTRACT + "\n" + pad
24 start = time.monotonic()
25 result = validate_contract_fixture(body)
26 elapsed = time.monotonic() - start
27 assert result.ok, result.errors
28 assert elapsed < 2.0
29
30
31 def test_real_contract_repeated_n_times_bounded() -> None:
32 """Real contract doc repeated N≥20 times completes within a bound."""
33 text = (KIT_ROOT / "docs" / "TRACK-O-NORMIE-CUSTODY-PRODUCT-CONTRACT.md").read_text(
34 encoding="utf-8"
35 )
36 blob = "\n\n".join([text] * REPEAT_N)
37 assert blob.count("Stage 1 — Start") >= REPEAT_N
38 start = time.monotonic()
39 result = validate_contract_fixture(blob)
40 elapsed = time.monotonic() - start
41 assert result.ok, result.errors
42 assert elapsed < 2.0
43
44
45 def test_pack_validate_stress_idempotent_under_repeat() -> None:
46 start = time.monotonic()
47 for _ in range(REPEAT_N):
48 result = validate_track_o_pack(KIT_ROOT)
49 assert result.ok, result.errors
50 elapsed = time.monotonic() - start
51 assert elapsed < 5.0
File History 1 commit
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 1 day ago