mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-03 01:29:56 +00:00
test(gateway): prepare compaction before arming observers
The original F112 job replay failed the first manual compaction RPC under two-CPU pressure. Its lazy handler loaded after the RPC and operation-event observers started their deadlines. The RPC timed out, leaving both event promises unobserved until their own deadlines rejected. Prepare the narrow compaction handler in fixture setup under real timers, then immediately join the real RPC and both preinstalled event observers. Keep the existing deadlines and all response, event, and SQLite assertions. This removes cold test-module preparation from the observation interval and handles sibling promise failures without adding retries or timer overrides. The complete compaction file passes 22 tests on the pressure Testbox; pnpm test with one worker measured 148.35 seconds including cold transforms.
This commit is contained in:
parent
77b3233487
commit
5ea791a841
1 changed files with 7 additions and 12 deletions
|
|
@ -280,21 +280,16 @@ test("sessions.compact without maxLines runs embedded manual compaction without
|
|||
});
|
||||
|
||||
const { ws } = await openClient();
|
||||
// Prepare the lazy handler before arming the RPC and event observers.
|
||||
await import("./server-methods/sessions-compact.js");
|
||||
await rpcReq(ws, "sessions.subscribe", {});
|
||||
const startEventPromise = onceMessage(ws, (message) => isCompactOperationEvent(message, "start"));
|
||||
const endEventPromise = onceMessage(ws, (message) => isCompactOperationEvent(message, "end"));
|
||||
const compacted = await rpcReq<{
|
||||
ok: true;
|
||||
key: string;
|
||||
compacted: boolean;
|
||||
result?: { tokensAfter?: number };
|
||||
}>(ws, "sessions.compact", {
|
||||
key: "main",
|
||||
});
|
||||
const [startEvent, endEvent, compacted] = await Promise.all([
|
||||
onceMessage(ws, (message) => isCompactOperationEvent(message, "start")),
|
||||
onceMessage(ws, (message) => isCompactOperationEvent(message, "end")),
|
||||
rpcReq(ws, "sessions.compact", { key: "main" }),
|
||||
]);
|
||||
|
||||
expectMainCompactionResult(compacted, true);
|
||||
const startEvent = await startEventPromise;
|
||||
const endEvent = await endEventPromise;
|
||||
const startPayload = startEvent.payload as {
|
||||
operationId?: string;
|
||||
sessionKey?: string;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue