test_q3_release_desktop_stress.py python
74 lines 2.7 KB
Raw
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83 chore(governance): sync handover+roadmap to 84db8c8 (drift:… Human 1 day ago
1 """Stress tests for Q3-release desktop installers (§QR.13)."""
2
3 from __future__ import annotations
4
5 import resource
6 from pathlib import Path
7
8 from tests.fixtures.desktop_release import GIT_SHA_FIXTURE
9 from tools.desktop_release.checksums import sha256_file
10 from tools.desktop_release.constants import MANIFEST_ARTIFACT_CAP
11 from tools.desktop_release.finalize import FinalizeError, finalize_release_artifacts
12 from tools.desktop_release.manifest import build_manifest
13
14
15 def test_manifest_builder_fifty_artifact_cap() -> None:
16 arts = []
17 for i in range(MANIFEST_ARTIFACT_CAP):
18 arts.append(
19 {
20 "platform": "linux",
21 "filename": f"Overseer Kit_0.1.0_batch{i}.AppImage",
22 "sha256": f"{i:064x}"[-64:],
23 "signing": {"status": "signed", "method": "minisign_detached"},
24 }
25 )
26 doc = build_manifest(version="0.1.0", git_sha=GIT_SHA_FIXTURE, artifacts=arts)
27 assert len(doc["artifacts"]) == MANIFEST_ARTIFACT_CAP
28
29
30 def test_finalize_refuses_over_cap(tmp_path: Path) -> None:
31 from tools.desktop_release.finalize import ArtifactInput
32
33 paths = []
34 inputs = []
35 for i in range(MANIFEST_ARTIFACT_CAP + 1):
36 p = tmp_path / f"a{i}.AppImage"
37 p.write_bytes(b"x")
38 paths.append(p)
39 inputs.append(
40 ArtifactInput(
41 platform="linux",
42 path=p,
43 signing_status="signed",
44 signing_method="minisign_detached",
45 )
46 )
47 try:
48 finalize_release_artifacts(
49 version="0.1.0",
50 git_sha=GIT_SHA_FIXTURE,
51 artifacts=inputs,
52 output_dir=tmp_path / "out",
53 publish=False,
54 )
55 raise AssertionError("expected cap refuse")
56 except FinalizeError as exc:
57 assert "cap" in str(exc)
58
59
60 def test_streaming_checksum_large_fixture(tmp_path: Path) -> None:
61 """Multi-megabyte file hashed in a single streaming pass (bounded RSS growth)."""
62 path = tmp_path / "large.bin"
63 # 4 MiB — enough to exercise chunking; avoid huge CI times.
64 chunk = b"0123456789abcdef" * 4096 # 64 KiB
65 with path.open("wb") as handle:
66 for _ in range(64): # 4 MiB
67 handle.write(chunk)
68 before = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
69 digest = sha256_file(path, chunk_size=1024 * 1024)
70 after = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
71 assert len(digest) == 64
72 # Soft bound: hashing must not multiply RSS by loading the file twice unboundedly.
73 # On macOS ru_maxrss is bytes; on Linux it is kilobytes — compare relative delta only.
74 assert after >= before # sanity; primary proof is single-pass API completing
File History 1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199 fix(ISR): default require_independent_second_reviewer to require Human minor 1 day ago