Complete Lab 5: implementation, fault scenarios, and Track 1 report

This commit is contained in:
2026-11-09 23:39:53 +03:00
parent 9049c404ed
commit fb8a43920e
32 changed files with 1252 additions and 18 deletions
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env python3
"""Requires worker recreated with FAULT_AFTER_S3_WRITE_ONCE=1 and timeout=5s."""
import json, subprocess, time
from pathlib import Path
from client import Client, arguments, check, run
def main():
a=arguments('Crash after deterministic S3 side effect, then verify redelivery')
c=Client(a.base_url,a.ca_file); alice,bob,_,chat=c.bootstrap()
before=int(subprocess.check_output(['docker','inspect','-f','{{.RestartCount}}','mtusi_lab5_solution-worker-1'],text=True).strip())
att,raw=c.attachment(alice,chat); started=time.monotonic(); ready=c.wait_ready(bob,att,wait_seconds=90)
after=int(subprocess.check_output(['docker','inspect','-f','{{.RestartCount}}','mtusi_lab5_solution-worker-1'],text=True).strip())
check(after>before,'fault injection did not restart the worker')
check(ready['status']=='ready' and len(ready['variants'])==3,'redelivery did not preserve one complete variant set')
result={'scenario':'crash after original+variant S3 writes, before PostgreSQL ready commit and consumer ack','attachment_id':att['id'],'worker_restart_count_before':before,'worker_restart_count_after':after,'status':'ready','variants':[v['name'] for v in ready['variants']],'original_sha256_matches':ready['sha256']==__import__('hashlib').sha256(raw).hexdigest(),'recovery_seconds':round(time.monotonic()-started,3),'delivery':'Redis Streams at-least-once; deterministic object keys; DB ready commit precedes ack'}
dest=Path('evidence/fault-redelivery.json'); dest.write_text(json.dumps(result,indent=2)+'\n'); print(json.dumps(result,indent=2))
if __name__=='__main__': run(main)