Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/minidb/test/e2e/stress.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { MiniDb } from '../../src/index.js';
import { startServer } from '../../src/server.js';
import { tmpDir, rmrf } from './helpers/tmp.js';
import { mulberry32 } from './helpers/prng.js';
import { waitFor } from '../helpers.js';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

Expand Down Expand Up @@ -570,7 +571,11 @@ test(
await db.set(`ek${i}`, { i, pad: 'e'.repeat(1100) });
if (i % 7 === 0) db.get(`ek${Math.max(0, i - 3)}`);
}
expect(db.stats.compactions).toBeGreaterThan(0);
// Auto-compaction is fire-and-forget through the maintenance scheduler,
// so the write loop finishing does not imply a run has completed yet —
// wait for the churn this scenario requires instead of assuming the
// loop outlasted it (flakes on loaded CI runners).
await waitFor(() => db.stats.compactions > 0, 'auto compaction under churn');
expect(db.store.bytes).toBeLessThanOrEqual(Math.ceil(budget * 1.05));
expect(db.stats.evictions).toBeGreaterThan(0);
} catch (err) {
Expand Down
Loading