forked from mtusi2026/mtusi2026lab3
Finalize lab 3 report and evidence provenance
Tie the grade 5 claim to the final SQLAlchemy revalidation and measured scaling results. Clarify clean-clone setup, failure timings, historical evidence, and operational constraints; record report-stage checks and evidence audits.
This commit is contained in:
@@ -0,0 +1,161 @@
|
||||
date: 2026-11-05T22:28:24.183630+00:00 commit: f591fa64e525679a31c9db7f942d36c789e1a12f
|
||||
worktree: report documentation changes only
|
||||
$ python3 <<'PY'
|
||||
import collections
|
||||
import csv
|
||||
import json
|
||||
import re
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from statistics import median
|
||||
|
||||
root = Path.cwd()
|
||||
track = root / "evidence/track1-sqlalchemy"
|
||||
report = (root / "REPORT.md").read_text()
|
||||
links = 0
|
||||
for name in ("REPORT.md", "AGENTS.md", "evidence/README.md"):
|
||||
path = root / name
|
||||
for target in re.findall(r"\]\(([^)]+)\)", path.read_text()):
|
||||
if "://" in target or target.startswith("#"):
|
||||
continue
|
||||
assert (path.parent / target.split("#")[0]).exists(), (name, target)
|
||||
links += 1
|
||||
print("PASS: local Markdown links exist:", links)
|
||||
for candidate in re.findall(r"`(evidence/[^`\s]+)`", report):
|
||||
if not any(char in candidate for char in "{}<>"):
|
||||
assert list(root.glob(candidate)), candidate
|
||||
print("PASS: explicit evidence paths and globs in REPORT exist")
|
||||
|
||||
all_rows = []
|
||||
series_rows = {}
|
||||
expected_sizes = {"series-a": 54, "series-b": 36, "compare": 18, "control-pool": 15, "control-cpus": 12}
|
||||
for name, size in expected_sizes.items():
|
||||
folder = track / name
|
||||
rows = list(csv.DictReader(line for line in (folder / "summary.csv").read_text().splitlines() if not line.startswith("#")))
|
||||
assert len(rows) == size
|
||||
groups = collections.defaultdict(list)
|
||||
for row in rows:
|
||||
groups[row["variant"], row["config"], row["rate"]].append(row)
|
||||
raw = folder / row["raw_dir"]
|
||||
metrics = json.loads((raw / "k6/summary.json").read_text())["metrics"]
|
||||
count = metrics["http_reqs{scenario:measure}"]["values"]["count"]
|
||||
failed = metrics["http_req_failed{scenario:measure}"]["values"]["rate"]
|
||||
dropped = metrics.get("dropped_iterations{scenario:measure}", {}).get("values", {}).get("count", 0)
|
||||
p95 = metrics["http_req_duration{scenario:measure}"]["values"]["p(95)"]
|
||||
assert int(row["requests"]) == count
|
||||
assert abs(float(row["ok_rps"]) - count * (1 - failed) / 30) <= 0.006
|
||||
assert abs(float(row["failed_ratio"]) - failed) <= 0.000006
|
||||
assert abs(float(row["p95_ms"]) - p95) <= 0.006
|
||||
assert int(row["dropped_iterations"]) == dropped
|
||||
assert row["disturbed"] == "False" and row["k6_exit"] == "0"
|
||||
metadata = json.loads((raw / "metadata.json").read_text())
|
||||
apis = [item for item in metadata["containers"] if "-api-" in item["name"]]
|
||||
assert len(apis) == int(row["replicas"])
|
||||
assert {item["NanoCpus"] for item in apis} == {round(float(row["cpus"]) * 1e9)}
|
||||
assert {item["Memory"] for item in apis} == {int(row["memory_mb"]) * 2**20}
|
||||
assert {item["CpusetCpus"] for item in apis} == {row["api_cpuset"]}
|
||||
assert all(len(items) == 3 and {item["repeat"] for item in items} == {"1", "2", "3"} for items in groups.values())
|
||||
series_rows[name] = rows
|
||||
all_rows.extend(rows)
|
||||
print("PASS:", name, size, "samples; raw k6 counts/latency/errors, 3 repeats, actual resources")
|
||||
assert len(all_rows) == 135
|
||||
assert sum(int(row["requests"]) for row in all_rows) == 8271783
|
||||
assert len(list((track / "plots").glob("*.png"))) == 12
|
||||
print("PASS: 135 samples, 8271783 requests, 12 PNG files")
|
||||
|
||||
comparison = {}
|
||||
for variant in ("before", "after"):
|
||||
for rate in (2400, 3600, 5400):
|
||||
rows = [row for row in series_rows["compare"] if row["variant"] == variant and int(row["rate"]) == rate]
|
||||
values = {field: median(float(row[field]) for row in rows) for field in ("ok_rps", "p95_ms", "p99_ms", "cpu_api")}
|
||||
comparison[variant, rate] = values
|
||||
line = next(line for line in report.splitlines() if line.startswith(f"| {rate} | {variant} |"))
|
||||
for field in ("ok_rps", "p95_ms", "p99_ms"):
|
||||
assert f"{values[field]:.2f}" in line, (variant, rate, field)
|
||||
print("PASS: REPORT comparison", variant, rate, values)
|
||||
for rate, field in ((2400, "p95_ms"), (5400, "ok_rps")):
|
||||
before = [float(row[field]) for row in series_rows["compare"] if row["variant"] == "before" and int(row["rate"]) == rate]
|
||||
after = [float(row[field]) for row in series_rows["compare"] if row["variant"] == "after" and int(row["rate"]) == rate]
|
||||
assert max(after) < min(before) if field == "p95_ms" else min(after) > max(before)
|
||||
gain = (comparison["after", 5400]["ok_rps"] / comparison["before", 5400]["ok_rps"] - 1) * 100
|
||||
cpu = (1 - comparison["after", 2400]["cpu_api"] / comparison["before", 2400]["cpu_api"]) * 100
|
||||
assert round(gain, 1) == 8.7 and round(cpu, 1) == 29.3
|
||||
print("PASS: non-overlapping ranges; throughput +8.7%, API CPU -29.3%")
|
||||
|
||||
for name in ("series-a", "series-b"):
|
||||
groups = collections.defaultdict(list)
|
||||
for row in series_rows[name]:
|
||||
groups[row["config"], row["rate"]].append(float(row["ok_rps"]))
|
||||
for config in sorted({key[0] for key in groups}):
|
||||
peak = max(median(values) for (cfg, rate), values in groups.items() if cfg == config)
|
||||
assert f"{peak:.2f}" in report, (name, config, peak)
|
||||
print("PASS: REPORT peak", name, config, f"{peak:.2f}")
|
||||
|
||||
validation = track / "revalidation"
|
||||
expected = {"a855a190991a": (1.018, 0.058, 14.480, 661), "d4dfe6128c9d": (1.145, 0.096, 16.127, 661)}
|
||||
for label, values in expected.items():
|
||||
folder = validation / "failover-each" / label
|
||||
data = json.loads((folder / "result.json").read_text())
|
||||
assert data["pass"] and all(data["checks"].values())
|
||||
assert (data["detection_seconds"], data["probe"]["first_success_s"], data["rejoin_seconds"], data["history"]["confirmed"]) == values
|
||||
assert data["history"]["confirmed"] == data["history"]["stored"] and data["history"]["exact_match"] and data["history"]["unique"]
|
||||
assert data["k6"]["failed_ratio"] == data["probe"]["failed_attempts"] == data["k6"]["dropped_iterations"] == 0
|
||||
assert label in (folder / "action.txt").read_text() and "Exited (0)" in (folder / "action.txt").read_text()
|
||||
print("PASS: REPORT failure", label, values, "zero errors/losses/duplicates, stopped container recorded")
|
||||
rolling = json.loads((validation / "rolling/result.json").read_text())
|
||||
assert rolling["pass"] and all(rolling["checks"].values())
|
||||
assert rolling["history"]["confirmed"] == rolling["history"]["stored"] == 938
|
||||
assert rolling["lb_up_min"] == 2 and rolling["probe"]["first_success_s"] == 0.037
|
||||
print("PASS: rolling, 938 messages preserved, minimum 2 UP")
|
||||
for scenario, expected_range in {"sigterm": (0.899, 1.326), "kill": (0.273, 0.795), "pause": (2.783, 3.281), "postgres": (1.201, 1.255)}.items():
|
||||
data = [json.loads(path.read_text()) for path in sorted(validation.glob(f"detection/run*/{scenario}.json"))]
|
||||
assert len(data) == 3 and all(item["pass"] for item in data)
|
||||
actual = [item["detection_seconds"] for item in data]
|
||||
assert (min(actual), max(actual)) == expected_range
|
||||
print("PASS: REPORT detection", scenario, expected_range)
|
||||
|
||||
paths = ["src", "alembic", "infra", "Dockerfile", "compose.yaml", "pyproject.toml", "uv.lock", "student-tests"]
|
||||
subprocess.run(["git", "diff", "--exit-code", "3fb741e", "--", *paths], check=True)
|
||||
subprocess.run(["git", "diff", "--exit-code", "upstream/main", "--", "contracts", "tests", "README.md", "COURSE.md"], check=True)
|
||||
subprocess.run(["git", "diff", "--exit-code", "f591fa6", "--", ".pipeline"], check=True)
|
||||
print("PASS: application/migrations/stack/tests unchanged since revalidation; normative files unchanged from upstream")
|
||||
subprocess.run(["git", "diff", "--check"], check=True)
|
||||
print("PASS: git diff --check")
|
||||
print("Context7 checked: /sqlalchemy/sqlalchemy/rel_2_0_45 lambda_stmt(enable_tracking=False); /sqlalchemy/alembic/rel_1_16_5 async run_sync/upgrade head")
|
||||
PY
|
||||
|
||||
PASS: local Markdown links exist: 40
|
||||
PASS: explicit evidence paths and globs in REPORT exist
|
||||
PASS: series-a 54 samples; raw k6 counts/latency/errors, 3 repeats, actual resources
|
||||
PASS: series-b 36 samples; raw k6 counts/latency/errors, 3 repeats, actual resources
|
||||
PASS: compare 18 samples; raw k6 counts/latency/errors, 3 repeats, actual resources
|
||||
PASS: control-pool 15 samples; raw k6 counts/latency/errors, 3 repeats, actual resources
|
||||
PASS: control-cpus 12 samples; raw k6 counts/latency/errors, 3 repeats, actual resources
|
||||
PASS: 135 samples, 8271783 requests, 12 PNG files
|
||||
PASS: REPORT comparison before 2400 {'ok_rps': 2400.03, 'p95_ms': 14.28, 'p99_ms': 63.16, 'cpu_api': 573.24}
|
||||
PASS: REPORT comparison before 3600 {'ok_rps': 3562.0, 'p95_ms': 223.99, 'p99_ms': 283.23, 'cpu_api': 774.41}
|
||||
PASS: REPORT comparison before 5400 {'ok_rps': 3629.17, 'p95_ms': 373.74, 'p99_ms': 480.28, 'cpu_api': 775.03}
|
||||
PASS: REPORT comparison after 2400 {'ok_rps': 2400.03, 'p95_ms': 4.63, 'p99_ms': 14.2, 'cpu_api': 405.23}
|
||||
PASS: REPORT comparison after 3600 {'ok_rps': 3587.4, 'p95_ms': 101.01, 'p99_ms': 156.31, 'cpu_api': 593.03}
|
||||
PASS: REPORT comparison after 5400 {'ok_rps': 3945.63, 'p95_ms': 317.43, 'p99_ms': 415.68, 'cpu_api': 614.42}
|
||||
PASS: non-overlapping ranges; throughput +8.7%, API CPU -29.3%
|
||||
PASS: REPORT peak series-a 1x4 2687.13
|
||||
PASS: REPORT peak series-a 2x2 2531.80
|
||||
PASS: REPORT peak series-a 4x1 2421.57
|
||||
PASS: REPORT peak series-b 1x1 750.93
|
||||
PASS: REPORT peak series-b 2x1 1306.80
|
||||
PASS: REPORT peak series-b 8x1 3420.37
|
||||
PASS: REPORT failure a855a190991a (1.018, 0.058, 14.48, 661) zero errors/losses/duplicates, stopped container recorded
|
||||
PASS: REPORT failure d4dfe6128c9d (1.145, 0.096, 16.127, 661) zero errors/losses/duplicates, stopped container recorded
|
||||
PASS: rolling, 938 messages preserved, minimum 2 UP
|
||||
PASS: REPORT detection sigterm (0.899, 1.326)
|
||||
PASS: REPORT detection kill (0.273, 0.795)
|
||||
PASS: REPORT detection pause (2.783, 3.281)
|
||||
PASS: REPORT detection postgres (1.201, 1.255)
|
||||
PASS: application/migrations/stack/tests unchanged since revalidation; normative files unchanged from upstream
|
||||
PASS: git diff --check
|
||||
Context7 checked: /sqlalchemy/sqlalchemy/rel_2_0_45 lambda_stmt(enable_tracking=False); /sqlalchemy/alembic/rel_1_16_5 async run_sync/upgrade head
|
||||
exit: 0
|
||||
|
||||
Final index audit: 40 local Markdown targets exist in git ls-files; exactly six report/documentation files staged.
|
||||
git diff --cached --check: exit 0
|
||||
Reference in New Issue
Block a user