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
9 changes: 6 additions & 3 deletions test/backend-test/heartbeat-data-plane.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -798,9 +798,12 @@ describe("heartbeat data plane", () => {
});

test("retention cleanup racing a tracked write removes only expired data", async () => {
const { data, store } = await createRuntime("retention");
// Retention uses SQLite's wall clock, so keep the fixture and calculator on the same clock.
const now = dayjs.utc();
const { data, store } = await createRuntime("retention", now);
await store.exec(
"INSERT INTO heartbeat (monitor_id, status, msg, time, important) VALUES (1, 0, 'expired', '2000-01-01 00:00:00', 1)"
"INSERT INTO heartbeat (monitor_id, status, msg, time, important) VALUES (1, 0, 'expired', ?, 1)",
[store.isoDateTimeMillis(now.subtract(31, "day"))]
);
const coordinator = new DatabaseMaintenanceCoordinator();
const settings = {
Expand All @@ -811,7 +814,7 @@ describe("heartbeat data plane", () => {
};

await Promise.all([
coordinator.run(() => data.write(heartbeat(store))),
coordinator.run(() => data.write(heartbeat(store, { time: store.isoDateTimeMillis(now) }))),
coordinator.maintain(() => clearOldData(store, settings, data)),
]);

Expand Down
Loading