lab5: исправления по ревью
Concurrent complete no longer deletes the shared verified source; admission is atomic and covers pending presign rows; relay reconciles queued jobs lost to dead-lettering; failed staging is protected until failed_retention; timestamps normalized to UTC; reprocess prefers the durable original and keeps job->attachment lock order; heartbeat errors no longer burn attempts; confirm timeout enforced; pinned images and sanitized health responses.
This commit is contained in:
@@ -17,6 +17,17 @@ from tests_helpers import ROOT, compose, psql # noqa: E402
|
||||
FIXTURE = Path(__file__).resolve().parents[1] / 'tests/fixtures/sample.png'
|
||||
|
||||
|
||||
def wait_api_ready(client, timeout=60):
|
||||
deadline = time.monotonic() + timeout
|
||||
while time.monotonic() < deadline:
|
||||
try:
|
||||
client.call('GET', '/health/ready', schema='Health')
|
||||
return
|
||||
except Failure:
|
||||
time.sleep(0.2)
|
||||
raise Failure('API did not become ready after restart')
|
||||
|
||||
|
||||
def wait_state(client, actor, attachment, expected, timeout=60):
|
||||
deadline = time.monotonic() + timeout
|
||||
while time.monotonic() < deadline:
|
||||
@@ -46,7 +57,10 @@ def main():
|
||||
time.sleep(2)
|
||||
still = client.call('GET', '/api/v1/attachments/' + attached['id'], actor=alice, schema='Attachment')['json']
|
||||
check(still['status'] == 'queued', 'worker stopped but job was processed synchronously')
|
||||
print('worker down: 202 queued, content 409, queued attachment linked')
|
||||
# The README demo restarts the API after the 202 and before the worker.
|
||||
compose('restart', 'api')
|
||||
wait_api_ready(client)
|
||||
print('worker down: 202 queued, content 409, queued attachment linked, API restarted')
|
||||
finally:
|
||||
compose('up', '-d', '--no-deps', 'worker', check=False)
|
||||
|
||||
@@ -76,6 +90,7 @@ def main():
|
||||
|
||||
# 3. A full stack restart with volumes keeps ready data and the worker path.
|
||||
compose('restart', 'api', 'worker', 'relay')
|
||||
wait_api_ready(client)
|
||||
recovered = client.call('GET', '/api/v1/attachments/' + ready['id'], actor=bob, schema='Attachment')['json']
|
||||
check(recovered['status'] == 'ready', 'ready attachment lost across restart')
|
||||
body = client.call('GET', '/api/v1/attachments/' + ready['id'] + '/content', actor=bob)
|
||||
|
||||
Reference in New Issue
Block a user