Проверить уровень 3, устойчивость и отрицательные сценарии, оформить отчёт

This commit is contained in:
2026-12-04 07:15:24 +03:00
parent d4f64bed85
commit 06459d3eed
54 changed files with 1934 additions and 126 deletions
+36
View File
@@ -0,0 +1,36 @@
"""Accepted queued upload survives worker stop; real broker redelivery and dedupe."""
from pathlib import Path
import subprocess
import sys
import time
ROOT=Path(__file__).resolve().parents[1]
sys.path.insert(0,str(ROOT/'tests'));sys.path.insert(0,str(ROOT/'scripts'))
from client import Client
from manage import env
def compose(*args):subprocess.run(['docker','compose',*args],cwd=ROOT,check=True)
def main():
client=Client('https://localhost:'+env()['HTTPS_PORT'],str(ROOT/'secrets/ca.crt'))
alice,bob,eve,chat=client.bootstrap()
try:
compose('stop','-t','5','worker')
attachment,content=client.attachment(alice,chat)
assert attachment['status']=='queued'
compose('run','--rm','verifier','python','/checks/redelivery.py','redeliver')
finally:
compose('start','worker')
ready=client.wait_ready(alice,attachment)
assert client.call('GET','/api/v1/attachments/'+ready['id']+'/content',actor=bob)['bytes']==content
assert len(ready['variants'])==1 and ready['variants'][0]['name']=='thumbnail'
compose('run','--rm','verifier','python','/checks/redelivery.py','duplicate',ready['id'])
time.sleep(3)
after=client.call('GET','/api/v1/attachments/'+ready['id'],actor=bob,schema='Attachment')['json']
assert after==ready
print('PASS accepted202 during worker stop -> ready with exact original/one thumbnail; no-ack redelivery and completed-job duplicate did not duplicate effects')
if __name__=='__main__':main()