Archive grade 4 verification and record SQLAlchemy failure evidence
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
date: 2026-11-05T19:31:22.371897+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'"'"')
|
||||
files=list((root/'"'"'detection'"'"').glob('"'"'*/*.json'"'"'))
|
||||
assert len(files)==12
|
||||
for path in files:
|
||||
d=json.loads(path.read_text())
|
||||
assert d['"'"'pass'"'"'] and all(d['"'"'checks'"'"'].values()),path
|
||||
assert d['"'"'detection_seconds'"'"'] <= d['"'"'declared_max_seconds'"'"'],path
|
||||
fail=json.loads((root/'"'"'failover-each/summary.json'"'"').read_text())
|
||||
assert len(fail)==2 and len({d['"'"'label'"'"'] for d in fail})==2
|
||||
paths=list((root/'"'"'failover-each'"'"').glob('"'"'*/result.json'"'"'))+[root/'"'"'rolling/result.json'"'"',root/'"'"'rolling-from-7fc911c/result.json'"'"']
|
||||
for path in paths:
|
||||
d=json.loads(path.read_text())
|
||||
assert d['"'"'pass'"'"'] and all(d['"'"'checks'"'"'].values()),path
|
||||
assert d['"'"'k6'"'"']['"'"'failed_ratio'"'"']==0 and d['"'"'k6'"'"']['"'"'dropped_iterations'"'"']==0,path
|
||||
assert d['"'"'history'"'"']['"'"'confirmed'"'"']==d['"'"'history'"'"']['"'"'stored'"'"']==d['"'"'probe'"'"']['"'"'attempts'"'"'],path
|
||||
assert d['"'"'probe'"'"']['"'"'failed_attempts'"'"']==0 and all(v==0 for v in d['"'"'lb_counters'"'"'].values()),path
|
||||
trace=list(csv.DictReader(io.StringIO((path.parent/'"'"'lb_up.csv'"'"').read_text().split('"'"'\n'"'"',1)[1])))
|
||||
assert min(int(r['"'"'up'"'"']) for r in trace)==d['"'"'lb_up_min'"'"'],path
|
||||
probes=list(csv.DictReader(io.StringIO((path.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'"'"')
|
||||
completed=float(first['"'"'t_rel_s'"'"'])+float(first['"'"'latency_ms'"'"'])/1000
|
||||
assert abs(completed-d['"'"'probe'"'"']['"'"'first_success_s'"'"'])<0.002,path
|
||||
if '"'"'rolling'"'"' in str(path):
|
||||
action=(path.parent/'"'"'action.txt'"'"').read_text()
|
||||
assert action.count('"'"'migrate once before the first replacement'"'"')==1
|
||||
assert len(re.findall('"'"'replace .+ image='"'"',action))==2
|
||||
assert d['"'"'lb_up_min'"'"']>=2
|
||||
print(path,'"'"'PASS'"'"',d['"'"'k6'"'"']['"'"'requests'"'"'],'"'"'requests;'"'"',d['"'"'history'"'"']['"'"'stored'"'"'],'"'"'confirmed messages'"'"')
|
||||
changed=subprocess.check_output(['"'"'git'"'"','"'"'diff'"'"','"'"'--name-only'"'"'],text=True).splitlines()
|
||||
untracked=subprocess.check_output(['"'"'git'"'"','"'"'ls-files'"'"','"'"'--others'"'"','"'"'--exclude-standard'"'"'],text=True).splitlines()
|
||||
pattern=re.compile(r'"'"'Bearer [A-Za-z0-9_-]{25,}|postgresql://[^ /\n]+:[^@ /\n]+@|redis://:[^@ /\n]+@|"token":\s*"[A-Za-z0-9_-]{25,}"'"'"')
|
||||
for name in changed+untracked:
|
||||
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'"'"')
|
||||
'
|
||||
Traceback (most recent call last):
|
||||
File "<string>", line 38, in <module>
|
||||
assert not pattern.search(p.read_text()),'possible credential in '+name
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
AssertionError: possible credential in evidence/grade4-evidence-audit.txt
|
||||
evidence/failover-each/7cfd91ddf780/result.json PASS 6001 requests; 645 confirmed messages
|
||||
evidence/failover-each/5bbf259ff136/result.json PASS 6001 requests; 642 confirmed messages
|
||||
evidence/rolling/result.json PASS 9001 requests; 913 confirmed messages
|
||||
evidence/rolling-from-7fc911c/result.json PASS 9001 requests; 913 confirmed messages
|
||||
|
||||
exit: 1 elapsed_seconds: 0.087
|
||||
Reference in New Issue
Block a user