test_hosted_dashboard_stress.py file-level

at main · View file ↗ · Intel ↗

History
1 files
1 commits
0 hotspots
0 🧊 dead
0 💥 blast risk
sha256:6 fix(ISR): default require_independent_second_reviewer to require Opera… · aaronrene · Sep 2, 2026
1 """Stress tests for hosted governance dashboard (§HGD.12)."""
2
3 from __future__ import annotations
4
5 from concurrent.futures import ThreadPoolExecutor, as_completed
6
7 from tests.fixtures.hosted_dashboard import FixtureUpstream, start_test_hosted
8 from tools.hosted_dashboard.config import parse_hosted_dashboard_config
9
10
11 def test_bounded_concurrent_gets() -> None:
12 handle, client, _ = start_test_hosted()
13 try:
14 def one(_: int) -> int:
15 status, _ = client.get("/api/org/summary")
16 return status
17
18 with ThreadPoolExecutor(max_workers=10) as pool:
19 futures = [pool.submit(one, i) for i in range(24)]
20 codes = [f.result() for f in as_completed(futures)]
21 assert all(c == 200 for c in codes)
22 # Process still healthy
23 status, health = client.get("/api/health", auth=False)
24 assert status == 200
25 finally:
26 handle.shutdown()
27
28
29 def test_large_doc_bounded_and_org_cap() -> None:
30 upstream = FixtureUpstream()
31 upstream.put_repo("acme", "big")
32 upstream.put_file("acme", "big", ".overseer/config.yaml", "docs:\n roadmap: ROADMAP.md\n handover: OVERSEER-HANDOVER.md\n")
33 big = "# big\n" + ("x" * 50_000)
34 upstream.put_file("acme", "big", "docs/ROADMAP.md", big)
35 upstream.put_file("acme", "big", "docs/OVERSEER-HANDOVER.md", "# h\n")
36
37 # enumeration cap
38 for i in range(120):
39 upstream.put_repo("orgcap", f"r{i}")
40
41 raw = {
42 "enabled": True,
43 "org_allowlist": ["acme/big", "orgcap"],
44 "enumeration_cap": 100,
45 "max_doc_bytes": 10_000,
46 "sources": {
47 "github_contents": True,
48 "github_meta": True,
49 "github_checks_advisory": False,
50 "musehub_read": False,
51 },
52 }
53 handle, client, _ = start_test_hosted(
54 upstream=upstream,
55 config=parse_hosted_dashboard_config(raw),
56 )
57 try:
58 status, roadmap = client.get("/api/repos/acme/big/roadmap")
59 assert status == 200
60 assert len(roadmap["result"]["text"].encode("utf-8")) <= 10_000
61
62 status, summary = client.get("/api/org/summary")
63 assert status == 200
64 # org enumeration capped — fewer than 120 orgcap repos listed (marker filter may drop all)
65 orgcap = [r for r in summary["result"]["repos"] if r["owner"] == "orgcap"]
66 assert len(orgcap) <= 100
67 finally:
68 handle.shutdown()