mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 12:51:25 +00:00
test(perf): dedupe fixtures and reduce flaky waits
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import fs from "node:fs";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
diagnosticSessionStates,
|
||||
getDiagnosticSessionStateCountForTest,
|
||||
getDiagnosticSessionState,
|
||||
pruneDiagnosticSessionStates,
|
||||
resetDiagnosticSessionStateForTest,
|
||||
} from "./diagnostic-session-state.js";
|
||||
|
||||
@@ -28,9 +30,16 @@ describe("diagnostic session state pruning", () => {
|
||||
});
|
||||
|
||||
it("caps tracked session states to a bounded max", () => {
|
||||
const now = Date.now();
|
||||
for (let i = 0; i < 2001; i += 1) {
|
||||
getDiagnosticSessionState({ sessionId: `session-${i}` });
|
||||
diagnosticSessionStates.set(`session-${i}`, {
|
||||
sessionId: `session-${i}`,
|
||||
lastActivity: now + i,
|
||||
state: "idle",
|
||||
queueDepth: 1,
|
||||
});
|
||||
}
|
||||
pruneDiagnosticSessionStates(now + 2002, true);
|
||||
|
||||
expect(getDiagnosticSessionStateCountForTest()).toBe(2000);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user