mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-10 03:27:59 +00:00
test(recovery): seed interrupted native checkpoints (#3463)
Plant the complete interrupted-checkpoint state, including the checkpoint WAL and both lock files, for native source-preservation tests.
This commit is contained in:
parent
a5fd816d38
commit
f5673418a0
1 changed files with 15 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import lbug from '@ladybugdb/core';
|
||||
import fs from 'node:fs';
|
||||
import { createLbugDatabase } from '../../../src/core/lbug/lbug-config.ts';
|
||||
|
||||
const [dbPath, mode] = process.argv.slice(2);
|
||||
|
|
@ -19,7 +20,20 @@ await row('complete-0', 'complete', 0);
|
|||
await row('complete-1', 'complete', 1);
|
||||
await row('other', 'other', 0);
|
||||
await query('CHECKPOINT');
|
||||
if (mode === 'hard-kill') {
|
||||
if (mode === 'interrupted-checkpoint') {
|
||||
await row('checkpoint-only', 'checkpoint-only', 0);
|
||||
const main = fs.readFileSync(dbPath);
|
||||
const wal = fs.readFileSync(`${dbPath}.wal`);
|
||||
await conn.close();
|
||||
await db.close();
|
||||
// Restore the pre-close bytes: writable close has already checkpointed them.
|
||||
fs.writeFileSync(dbPath, main);
|
||||
fs.writeFileSync(`${dbPath}.wal.checkpoint`, wal);
|
||||
fs.writeFileSync(`${dbPath}.wal`, '');
|
||||
fs.writeFileSync(`${dbPath}.shadow`, '');
|
||||
fs.writeFileSync(`${dbPath}.checkpoint.intent.lock`, '');
|
||||
fs.writeFileSync(`${dbPath}.checkpoint.apply.lock`, '');
|
||||
} else if (mode === 'hard-kill') {
|
||||
await row('unsafe', 'unsafe-prefix', 0);
|
||||
process.kill(process.pid, 'SIGKILL');
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue