Files
mtusi2026lab5/scripts/verify_redelivery.py
T

22 lines
1.1 KiB
Python

"""Recheck the post-COMMIT/pre-ack fault after the full campaign has drained."""
import json
import time
from verify import EVIDENCE,dbtool,save,check
campaign = json.loads((EVIDENCE/'pipeline-results.json').read_text(encoding='utf-8'))
case = next(x for x in campaign['scenarios'] if x['scenario']=='after_result_commit')
deadline = time.monotonic()+40
while True:
final = dbtool('inspect',case['job']['attachment_id'])
if any(e['event']=='duplicate_ignored' for e in final['events']):
break
check(time.monotonic()<deadline,'committed crash did not redeliver')
time.sleep(0.5)
check(final['objects']==case['job']['objects'],'redelivery rewrote successful objects')
check(final['jobs']==case['job']['jobs'],'redelivery changed committed job')
check('staging/'+final['attachment_id'] not in dbtool('staging')['keys'],'staging cleanup missing')
queue = dbtool('queue')
check(queue['length']==0,'campaign queue did not drain')
save('post-commit-redelivery.json',{'result':'PASS','job':final,'queue':queue})
print('PASS: actual post-COMMIT redelivery was a no-op, staging removed, queue drained.')