test_q4b_ui_stress.py python
47 lines 1.6 KB
Raw
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83 chore(governance): sync handover+roadmap to 84db8c8 (drift:… Human 1 day ago
1 """Stress tests for Track Q / Q4b Path B UI redesign (§Q4A.15)."""
2
3 from __future__ import annotations
4
5 import urllib.request
6 from concurrent.futures import ThreadPoolExecutor, as_completed
7 from pathlib import Path
8
9 from tests.fixtures.app import seed_app_repo, start_test_app
10
11 DIAGRAMS = (
12 "/assets/diagrams/lanes.svg",
13 "/assets/diagrams/regimes.svg",
14 "/assets/diagrams/layers.svg",
15 "/assets/diagrams/kit-consumer.svg",
16 )
17
18
19 def test_concurrent_diagrams_and_status(tmp_path: Path) -> None:
20 seed_app_repo(tmp_path)
21 handle, client = start_test_app(tmp_path)
22 try:
23
24 def one_round(i: int) -> tuple[int, int]:
25 status, payload = client.get("/api/status")
26 assert payload["result"]["initialized"] is True
27 path = DIAGRAMS[i % len(DIAGRAMS)]
28 req = urllib.request.Request(
29 f"{client.base_url}{path}",
30 headers={"Authorization": f"Bearer {client.session}"},
31 )
32 with urllib.request.urlopen(req, timeout=5) as response:
33 svg_status = response.status
34 assert b"<svg" in response.read()
35 return status, svg_status
36
37 with ThreadPoolExecutor(max_workers=20) as pool:
38 futures = [pool.submit(one_round, i) for i in range(24)]
39 results = [future.result() for future in as_completed(futures)]
40 assert all(status == 200 and svg == 200 for status, svg in results)
41
42 # Auth still works after concurrent load.
43 status, health = client.get("/api/health")
44 assert status == 200
45 assert health["ok"] is True
46 finally:
47 handle.shutdown()
File History 1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199 fix(ISR): default require_independent_second_reviewer to require Human minor 1 day ago