mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-22 06:32:00 +00:00
Tests: stabilize shard-2 queue and channel state
This commit is contained in:
committed by
Vignesh
parent
9c185faba9
commit
4d54376483
@@ -29,6 +29,7 @@ let getActiveTaskCount: CommandQueueModule["getActiveTaskCount"];
|
||||
let getQueueSize: CommandQueueModule["getQueueSize"];
|
||||
let markGatewayDraining: CommandQueueModule["markGatewayDraining"];
|
||||
let resetAllLanes: CommandQueueModule["resetAllLanes"];
|
||||
let resetCommandQueueStateForTest: CommandQueueModule["resetCommandQueueStateForTest"];
|
||||
let setCommandLaneConcurrency: CommandQueueModule["setCommandLaneConcurrency"];
|
||||
let waitForActiveTasks: CommandQueueModule["waitForActiveTasks"];
|
||||
|
||||
@@ -67,10 +68,11 @@ describe("command queue", () => {
|
||||
getQueueSize,
|
||||
markGatewayDraining,
|
||||
resetAllLanes,
|
||||
resetCommandQueueStateForTest,
|
||||
setCommandLaneConcurrency,
|
||||
waitForActiveTasks,
|
||||
} = await import("./command-queue.js"));
|
||||
resetAllLanes();
|
||||
resetCommandQueueStateForTest();
|
||||
// Queue state is global across module instances, so reset main lane
|
||||
// concurrency explicitly to avoid cross-file leakage.
|
||||
setCommandLaneConcurrency(CommandLane.Main, 1);
|
||||
|
||||
@@ -254,6 +254,18 @@ export function clearCommandLane(lane: string = CommandLane.Main) {
|
||||
return removed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test-only hard reset that discards all queue state, including preserved
|
||||
* queued work from previous generations. Use this when a suite needs an
|
||||
* isolated baseline across shared-worker runs.
|
||||
*/
|
||||
export function resetCommandQueueStateForTest(): void {
|
||||
const queueState = getQueueState();
|
||||
queueState.gatewayDraining = false;
|
||||
queueState.lanes.clear();
|
||||
queueState.nextTaskId = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset all lane runtime state to idle. Used after SIGUSR1 in-process
|
||||
* restarts where interrupted tasks' finally blocks may not run, leaving
|
||||
|
||||
Reference in New Issue
Block a user