forked from mtusi2026/mtusi2026lab5
feat: add operator replay, fault injection scenarios and staging cleanup
This commit is contained in:
@@ -241,6 +241,35 @@ describe('Сверка объектов S3 с метаданными (e2e)', ()
|
||||
const row = await prisma.attachment.findUniqueOrThrow({ where: { id: res.body.id } });
|
||||
expect(row.stagingKey).toBeNull();
|
||||
});
|
||||
|
||||
it('staging ready-вложения, оставшийся после сбоя worker, удаляется без ожидания срока хранения', async () => {
|
||||
const res = await request(server)
|
||||
.post(`/api/v1/chats/${chatId}/attachments?filename=a.png`)
|
||||
.set('Authorization', bearer(alice))
|
||||
.set('Content-Type', 'image/png')
|
||||
.send(SAMPLE_PNG)
|
||||
.expect(202);
|
||||
await expect(
|
||||
processAttachment(app, res.body.id, {
|
||||
afterCommit: async () => {
|
||||
throw new Error('worker crashed');
|
||||
},
|
||||
}),
|
||||
).rejects.toThrow('worker crashed');
|
||||
expect(await exists(`staging/${res.body.id}`)).toBe(true);
|
||||
const report = await reconcile(prisma, s3, {
|
||||
apply: true,
|
||||
graceMs: HOUR_MS,
|
||||
prefix: `staging/${res.body.id}`,
|
||||
stagingRetentionMs: 24 * HOUR_MS,
|
||||
});
|
||||
expect(report.staging_expired).toBeGreaterThanOrEqual(1);
|
||||
expect(await exists(`staging/${res.body.id}`)).toBe(false);
|
||||
await request(server)
|
||||
.get(`/api/v1/attachments/${res.body.id}/content`)
|
||||
.set('Authorization', bearer(alice))
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Готовность при отказе S3 (e2e)', () => {
|
||||
|
||||
Reference in New Issue
Block a user