forked from mtusi2026/mtusi2026lab5
Отделить обработку вложений от приёма файла.
Upload отвечает 202 после staging и записи задания, worker через RabbitMQ собирает thumbnail, crop и optimized и переживает разрыв до publish. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -28,6 +28,19 @@ def expect(status, got, label):
|
||||
raise SystemExit("FAIL %s returned 500" % label)
|
||||
if got != status:
|
||||
raise SystemExit("FAIL %s expected %s got %s" % (label, status, got))
|
||||
|
||||
|
||||
def wait_ready(api, attachment_id, token):
|
||||
deadline = time.monotonic() + 60
|
||||
while time.monotonic() < deadline:
|
||||
status, body, _ = api.call("GET", "/api/v1/attachments/" + attachment_id, token=token)
|
||||
expect(200, status, "poll attachment")
|
||||
if body["status"] == "failed":
|
||||
raise SystemExit("FAIL attachment failed")
|
||||
if body["status"] == "ready":
|
||||
return body
|
||||
time.sleep(0.3)
|
||||
raise SystemExit("FAIL attachment did not become ready")
|
||||
print("PASS", label, got)
|
||||
|
||||
|
||||
@@ -109,7 +122,7 @@ def peak_during(action):
|
||||
check=False,
|
||||
)
|
||||
for line in stats.stdout.splitlines():
|
||||
if "mtusi2026lab4-api-" not in line:
|
||||
if "mtusi2026lab5-api-" not in line:
|
||||
continue
|
||||
value = line.split()[1]
|
||||
number = float(value[:-3])
|
||||
@@ -251,9 +264,10 @@ def negatives(api, alice_token, bob_token, eve_token, chat_id):
|
||||
{"sha256": digest},
|
||||
token=alice_token,
|
||||
)
|
||||
expect(201, status, "complete happy path")
|
||||
if attachment["sha256"] != digest or attachment["status"] != "ready":
|
||||
expect(202, status, "complete happy path")
|
||||
if attachment["sha256"] != digest or attachment["status"] != "queued":
|
||||
raise SystemExit("FAIL complete metadata")
|
||||
attachment = wait_ready(api, attachment["id"], bob_token)
|
||||
status, _, downloaded = api.call("GET", "/api/v1/attachments/%s/content" % attachment["id"], token=bob_token)
|
||||
expect(200, status, "member downloads direct upload")
|
||||
if downloaded != small:
|
||||
@@ -272,7 +286,7 @@ def negatives(api, alice_token, bob_token, eve_token, chat_id):
|
||||
raw=small,
|
||||
content_type="image/png",
|
||||
)
|
||||
expect(201, status, "proxy endpoint still works")
|
||||
expect(202, status, "proxy endpoint still works")
|
||||
return proxy["id"]
|
||||
|
||||
|
||||
@@ -289,7 +303,7 @@ def compare(api, token, chat_id):
|
||||
content_type="image/png",
|
||||
)
|
||||
)
|
||||
if proxy["result"][0] != 201:
|
||||
if proxy["result"][0] != 202:
|
||||
raise SystemExit("FAIL proxy %s %s" % (label, proxy["result"][0]))
|
||||
status, started, _ = api.call(
|
||||
"POST",
|
||||
@@ -309,7 +323,7 @@ def compare(api, token, chat_id):
|
||||
token=token,
|
||||
)
|
||||
)
|
||||
if direct_complete["result"][0] != 201:
|
||||
if direct_complete["result"][0] != 202:
|
||||
raise SystemExit("FAIL complete %s %s" % (label, direct_complete["result"][0]))
|
||||
rows.append(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user