-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcrash-replay.test.ts
More file actions
36 lines (33 loc) · 1.12 KB
/
crash-replay.test.ts
File metadata and controls
36 lines (33 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* This tests that transaction log replay works on crash. There is a bunch of data written to the system
* database, so replay needs to work for harper to startup.
*/
import { suite, test, before, after } from 'node:test';
import { startHarper, teardownHarper, sendOperation, type ContextWithHarper } from '@harperfast/integration-testing';
import { equal } from 'node:assert';
suite('Transaction log replay on crash', (ctx: ContextWithHarper) => {
before(async () => {
await startHarper(ctx, {
config: {},
env: {
HARPER_NO_FLUSH_ON_EXIT: true, // specifically don't flush, we are testing restart/replay and simulating a crash
},
});
});
after(async () => {
await teardownHarper(ctx);
});
test('crash and replay', async () => {
await new Promise((resolve) => {
ctx.harper.process.on('exit', resolve);
ctx.harper.process.kill('SIGKILL'); // violently kill to simulate a crash
});
await startHarper(ctx);
let response = await sendOperation(ctx.harper, {
operation: 'list_roles',
authorization: ctx.harper.admin,
});
equal(response.length, 1);
equal(response[0].role, 'super_user');
});
});