feat: add operator replay, fault injection scenarios and staging cleanup

This commit is contained in:
2026-11-16 14:02:27 +03:00
parent 350cc23e54
commit 3e0033fc79
9 changed files with 335 additions and 8 deletions
+29
View File
@@ -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)', () => {