test(storage): cover chunked limits and preserve fault cleanup

This commit is contained in:
2026-11-15 20:52:35 +03:00
parent 3d5a5ca84a
commit f5a7a74f67
4 changed files with 42 additions and 7 deletions
+9 -5
View File
@@ -289,10 +289,14 @@ print(json.dumps(checks))
(parsed.host, parsed.port), timeout=3
) as raw:
request = (
f"POST /api/v1/chats/{chat['id']}/attachments?filename=partial.png HTTP/1.1\r\n"
f"Host: {parsed.host}\r\nAuthorization: Bearer {session['token']}\r\n"
"Content-Type: image/png\r\nContent-Length: 100000\r\n\r\n"
).encode() + PNG[:20]
(
f"POST /api/v1/chats/{chat['id']}/attachments?filename=partial.png HTTP/1.1\r\n"
f"Host: {parsed.host}\r\nAuthorization: Bearer {session['token']}\r\n"
"Content-Type: image/png\r\nContent-Length: 10000000\r\n\r\n"
).encode()
+ PNG
+ b"x" * (2 * 1024 * 1024)
)
raw.sendall(request)
time.sleep(1)
assert int(sql("SELECT count(*) FROM attachments")) == before
@@ -302,10 +306,10 @@ print(json.dumps(checks))
result["aborted_upload_has_no_intent_or_bytes"] = True
# Failure before any S3 PUT.
name = uuid4().hex + ".png"
objects_before = inside("print(len(list(s.objects())))")
sql(
"CREATE FUNCTION student_upload_fault() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN RAISE EXCEPTION 'synthetic'; END $$; CREATE TRIGGER student_upload_fault BEFORE INSERT ON attachments FOR EACH ROW EXECUTE FUNCTION student_upload_fault()"
)
objects_before = inside("print(len(list(s.objects())))")
try:
assert (
upload(client, session, chat, name=name).status_code == 500