lab5: e2e, fault suite и доказательства

This commit is contained in:
2026-11-05 01:17:58 +03:00
parent d19824f546
commit 551cf70989
28 changed files with 2269 additions and 60 deletions
+29
View File
@@ -134,6 +134,35 @@ export function upload(
);
}
/**
* Lab5 uploads answer 202 before the worker runs. Poll metadata until ready;
* a failed attachment is a test failure, never a silent timeout.
*/
export async function waitReady(
token: string,
attachmentId: string,
timeoutMs = 60_000,
): Promise<Attachment> {
const deadline = Date.now() + timeoutMs;
for (;;) {
const result = await http<Attachment>(
`/api/v1/attachments/${attachmentId}`,
{ headers: bearer(token) },
);
expect(result.response.status).toBe(200);
if (result.body.status === 'failed')
throw new Error(
`attachment ${attachmentId} failed: ${result.body.error_code ?? 'unknown'}`,
);
if (result.body.status === 'ready') return result.body;
if (Date.now() >= deadline)
throw new Error(
`attachment ${attachmentId} did not become ready within ${timeoutMs}ms`,
);
await new Promise((resolve) => setTimeout(resolve, 200));
}
}
export async function download(
token: string,
attachmentId: string,