fix: 修复 CI 卡死 + LZ4/SSTable/Checkpoint 多项 bug — 526 测试全通过
CI / test (18.x) (push) Successful in 10m1s
CI / test (20.x) (push) Successful in 10m6s
CI / test (22.x) (push) Successful in 10m2s
CI / test (24.x) (push) Successful in 10m6s

This commit is contained in:
thzxx
2026-07-27 20:28:23 +08:00
parent bc69d8f500
commit 620cd11521
16 changed files with 175 additions and 157 deletions
+23 -4
View File
@@ -119,26 +119,45 @@ describe('AriaEngine — WAL', () => {
});
// ===================================================================
// Checkpoint 测试
// Checkpoint 测试(使用安全 Mock,避免 null 引用导致 CI 卡死)
// ===================================================================
describe('AriaEngine — CheckpointManager', () => {
class MockFlushable implements Flushable { flushed = false; async flushAll() { this.flushed = true; } }
class MockLSM { flushed = false; async flush() { this.flushed = true; } }
class MockWAL { checkpointed = false; async checkpoint() { this.checkpointed = true; } async flush() {} }
it('tick 未达间隔不触发 checkpoint', async () => {
const lsm = new MockLSM();
const wal = new MockWAL();
const flushable = new MockFlushable();
const cm = new CheckpointManager(null as any, null as any, flushable, 100);
const cm = new CheckpointManager(lsm as any, wal as any, flushable, 100);
await cm.tick();
await cm.tick();
expect(cm.getOpCount()).toBe(2);
expect(flushable.flushed).toBe(false);
expect(lsm.flushed).toBe(false);
});
it('setInterval 修改间隔', async () => {
const cm = new CheckpointManager(null as any, null as any, null, 1000);
it('setInterval 修改间隔后 tick 触发 checkpoint', async () => {
const lsm = new MockLSM();
const wal = new MockWAL();
const cm = new CheckpointManager(lsm as any, wal as any, null, 1000);
cm.setInterval(2);
await cm.tick();
await cm.tick();
expect(cm.getOpCount()).toBe(0); // reset after checkpoint
expect(lsm.flushed).toBe(true);
expect(wal.checkpointed).toBe(true);
});
it('forceCheckpoint 强制触发', async () => {
const lsm = new MockLSM();
const wal = new MockWAL();
const cm = new CheckpointManager(lsm as any, wal as any, null, 100);
await cm.forceCheckpoint();
expect(cm.getOpCount()).toBe(0);
expect(lsm.flushed).toBe(true);
expect(wal.checkpointed).toBe(true);
});
});