mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-30 17:16:52 +00:00
Gateway: tighten node pending drain semantics (#41429)
Merged via squash.
Prepared head SHA: 361c2eb5c8
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
acknowledgeNodePendingWork,
|
||||
drainNodePendingWork,
|
||||
enqueueNodePendingWork,
|
||||
getNodePendingWorkStateCountForTests,
|
||||
resetNodePendingWorkForTests,
|
||||
} from "./node-pending-work.js";
|
||||
|
||||
@@ -43,4 +44,24 @@ describe("node pending work", () => {
|
||||
const afterAck = drainNodePendingWork("node-2");
|
||||
expect(afterAck.items.map((item) => item.id)).toEqual(["baseline-status"]);
|
||||
});
|
||||
|
||||
it("keeps hasMore true when the baseline status item is deferred by maxItems", () => {
|
||||
enqueueNodePendingWork({ nodeId: "node-3", type: "location.request" });
|
||||
|
||||
const drained = drainNodePendingWork("node-3", { maxItems: 1 });
|
||||
|
||||
expect(drained.items.map((item) => item.type)).toEqual(["location.request"]);
|
||||
expect(drained.hasMore).toBe(true);
|
||||
});
|
||||
|
||||
it("does not allocate state for drain-only nodes with no queued work", () => {
|
||||
expect(getNodePendingWorkStateCountForTests()).toBe(0);
|
||||
|
||||
const drained = drainNodePendingWork("node-4");
|
||||
const acked = acknowledgeNodePendingWork({ nodeId: "node-4", itemIds: ["baseline-status"] });
|
||||
|
||||
expect(drained.items.map((item) => item.id)).toEqual(["baseline-status"]);
|
||||
expect(acked).toEqual({ revision: 0, removedItemIds: [] });
|
||||
expect(getNodePendingWorkStateCountForTests()).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user