forked from mtusi2026/mtusi2026lab2
44 lines
3.3 KiB
Plaintext
44 lines
3.3 KiB
Plaintext
date: 2026-11-05T19:32:57.655116+00:00 commit: 252e3e3ffeea5004cfd9dc342e686af1417a77a2
|
|
NO_PROXY=localhost,127.0.0.1,::1 COMPOSE_PROJECT_NAME=mtusi2026lab3-grade4-20261105 LB_HTTP_PORT=18083 LB_STATS_PORT=23083 API_REPLICAS=2
|
|
$ python3 -c 'import csv,io,json,re,subprocess
|
|
from pathlib import Path
|
|
root=Path('"'"'evidence'"'"')
|
|
det=list((root/'"'"'detection'"'"').glob('"'"'*/*.json'"'"'))
|
|
assert len(det)==12
|
|
for p in det:
|
|
d=json.loads(p.read_text())
|
|
assert d['"'"'pass'"'"'] and all(d['"'"'checks'"'"'].values()) and d['"'"'detection_seconds'"'"']<=d['"'"'declared_max_seconds'"'"']
|
|
fail=json.loads((root/'"'"'failover-each/summary.json'"'"').read_text())
|
|
assert len(fail)==2 and len({d['"'"'label'"'"'] for d in fail})==2
|
|
for p in list((root/'"'"'failover-each'"'"').glob('"'"'*/result.json'"'"'))+[root/'"'"'rolling/result.json'"'"',root/'"'"'rolling-from-7fc911c/result.json'"'"']:
|
|
d=json.loads(p.read_text())
|
|
assert d['"'"'pass'"'"'] and all(d['"'"'checks'"'"'].values())
|
|
assert d['"'"'k6'"'"']['"'"'failed_ratio'"'"']==d['"'"'k6'"'"']['"'"'dropped_iterations'"'"']==d['"'"'probe'"'"']['"'"'failed_attempts'"'"']==0
|
|
assert d['"'"'history'"'"']['"'"'confirmed'"'"']==d['"'"'history'"'"']['"'"'stored'"'"']==d['"'"'probe'"'"']['"'"'attempts'"'"']
|
|
assert all(v==0 for v in d['"'"'lb_counters'"'"'].values())
|
|
trace=list(csv.DictReader(io.StringIO((p.parent/'"'"'lb_up.csv'"'"').read_text().split('"'"'\n'"'"',1)[1])))
|
|
assert min(int(r['"'"'up'"'"']) for r in trace)==d['"'"'lb_up_min'"'"']
|
|
probes=list(csv.DictReader(io.StringIO((p.parent/'"'"'probe.csv'"'"').read_text().split('"'"'\n'"'"',1)[1])))
|
|
first=next(r for r in probes if float(r['"'"'t_rel_s'"'"'])>=0 and r['"'"'status'"'"']=='"'"'201'"'"')
|
|
assert abs(float(first['"'"'t_rel_s'"'"'])+float(first['"'"'latency_ms'"'"'])/1000-d['"'"'probe'"'"']['"'"'first_success_s'"'"'])<0.002
|
|
if '"'"'rolling'"'"' in str(p):
|
|
action=(p.parent/'"'"'action.txt'"'"').read_text()
|
|
assert action.count('"'"'migrate once before the first replacement'"'"')==1
|
|
assert len(re.findall('"'"'replace .+ image='"'"',action))==2 and d['"'"'lb_up_min'"'"']>=2
|
|
print(p,'"'"'PASS'"'"')
|
|
paths=subprocess.check_output(['"'"'git'"'"','"'"'diff'"'"','"'"'--name-only'"'"'],text=True).splitlines()+subprocess.check_output(['"'"'git'"'"','"'"'ls-files'"'"','"'"'--others'"'"','"'"'--exclude-standard'"'"'],text=True).splitlines()
|
|
pattern=re.compile(r'"'"'Bearer [A-Za-z0-9_-]{25,}|postgresql(?:\+asyncpg)?://[A-Za-z0-9_-]+:[A-Za-z0-9._~%+-]+@|redis://:[A-Za-z0-9._~%+-]+@|"token":\s*"[A-Za-z0-9_-]{25,}"'"'"')
|
|
for name in paths:
|
|
p=Path(name)
|
|
if p.is_file() and p.suffix in {'"'"'.txt'"'"','"'"'.json'"'"','"'"'.csv'"'"','"'"'.md'"'"'}:
|
|
assert not pattern.search(p.read_text()),'"'"'possible credential in '"'"'+name
|
|
print('"'"'PASS: 12 detection measurements, 4 load scenarios, raw CSV agreement, one migrate per rolling action, credential-pattern scan'"'"')
|
|
'
|
|
evidence/failover-each/7cfd91ddf780/result.json PASS
|
|
evidence/failover-each/5bbf259ff136/result.json PASS
|
|
evidence/rolling/result.json PASS
|
|
evidence/rolling-from-7fc911c/result.json PASS
|
|
PASS: 12 detection measurements, 4 load scenarios, raw CSV agreement, one migrate per rolling action, credential-pattern scan
|
|
|
|
exit: 0 elapsed_seconds: 0.065
|