mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:30:42 +00:00
test: harden active memory timeout specs
This commit is contained in:
@@ -2392,16 +2392,17 @@ describe("active-memory plugin", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("ignores late subagent payloads once the active-memory timeout signal has fired", async () => {
|
it("ignores late subagent payloads once the active-memory timeout signal has fired", async () => {
|
||||||
|
const CONFIGURED_TIMEOUT_MS = 25;
|
||||||
__testing.setMinimumTimeoutMsForTests(1);
|
__testing.setMinimumTimeoutMsForTests(1);
|
||||||
__testing.setSetupGraceTimeoutMsForTests(0);
|
__testing.setSetupGraceTimeoutMsForTests(0);
|
||||||
api.pluginConfig = {
|
api.pluginConfig = {
|
||||||
agents: ["main"],
|
agents: ["main"],
|
||||||
timeoutMs: 1,
|
timeoutMs: CONFIGURED_TIMEOUT_MS,
|
||||||
logging: true,
|
logging: true,
|
||||||
};
|
};
|
||||||
plugin.register(api as unknown as OpenClawPluginApi);
|
plugin.register(api as unknown as OpenClawPluginApi);
|
||||||
runEmbeddedPiAgent.mockImplementationOnce(async (params: { timeoutMs?: number }) => {
|
runEmbeddedPiAgent.mockImplementationOnce(async (params: { timeoutMs?: number }) => {
|
||||||
await new Promise((resolve) => setTimeout(resolve, (params.timeoutMs ?? 0) + 1));
|
await new Promise((resolve) => setTimeout(resolve, (params.timeoutMs ?? 0) + 25));
|
||||||
return {
|
return {
|
||||||
payloads: [{ text: "late timeout payload that should never become memory context" }],
|
payloads: [{ text: "late timeout payload that should never become memory context" }],
|
||||||
meta: { aborted: true },
|
meta: { aborted: true },
|
||||||
@@ -2433,12 +2434,13 @@ describe("active-memory plugin", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("does not spend the model timeout budget on active-memory subagent setup", async () => {
|
it("does not spend the model timeout budget on active-memory subagent setup", async () => {
|
||||||
const CONFIGURED_TIMEOUT_MS = 10;
|
const CONFIGURED_TIMEOUT_MS = 50;
|
||||||
|
const SETUP_GRACE_TIMEOUT_MS = 500;
|
||||||
__testing.setMinimumTimeoutMsForTests(1);
|
__testing.setMinimumTimeoutMsForTests(1);
|
||||||
api.pluginConfig = {
|
api.pluginConfig = {
|
||||||
agents: ["main"],
|
agents: ["main"],
|
||||||
timeoutMs: CONFIGURED_TIMEOUT_MS,
|
timeoutMs: CONFIGURED_TIMEOUT_MS,
|
||||||
setupGraceTimeoutMs: 100,
|
setupGraceTimeoutMs: SETUP_GRACE_TIMEOUT_MS,
|
||||||
logging: true,
|
logging: true,
|
||||||
};
|
};
|
||||||
plugin.register(api as unknown as OpenClawPluginApi);
|
plugin.register(api as unknown as OpenClawPluginApi);
|
||||||
@@ -2458,7 +2460,9 @@ describe("active-memory plugin", () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
expect(result?.prependContext).toContain("remember the ramen place");
|
expect(result?.prependContext).toContain("remember the ramen place");
|
||||||
expect(runEmbeddedPiAgent.mock.calls.at(-1)?.[0]?.timeoutMs).toBe(CONFIGURED_TIMEOUT_MS + 100);
|
expect(runEmbeddedPiAgent.mock.calls.at(-1)?.[0]?.timeoutMs).toBe(
|
||||||
|
CONFIGURED_TIMEOUT_MS + SETUP_GRACE_TIMEOUT_MS,
|
||||||
|
);
|
||||||
const infoLines = vi
|
const infoLines = vi
|
||||||
.mocked(api.logger.info)
|
.mocked(api.logger.info)
|
||||||
.mock.calls.map((call: unknown[]) => String(call[0]));
|
.mock.calls.map((call: unknown[]) => String(call[0]));
|
||||||
@@ -3607,11 +3611,12 @@ describe("active-memory plugin", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("skips recall after consecutive timeouts when circuit breaker trips (#74054)", async () => {
|
it("skips recall after consecutive timeouts when circuit breaker trips (#74054)", async () => {
|
||||||
|
const CONFIGURED_TIMEOUT_MS = 25;
|
||||||
__testing.setMinimumTimeoutMsForTests(1);
|
__testing.setMinimumTimeoutMsForTests(1);
|
||||||
__testing.setSetupGraceTimeoutMsForTests(0);
|
__testing.setSetupGraceTimeoutMsForTests(0);
|
||||||
api.pluginConfig = {
|
api.pluginConfig = {
|
||||||
agents: ["main"],
|
agents: ["main"],
|
||||||
timeoutMs: 1,
|
timeoutMs: CONFIGURED_TIMEOUT_MS,
|
||||||
logging: true,
|
logging: true,
|
||||||
circuitBreakerMaxTimeouts: 2,
|
circuitBreakerMaxTimeouts: 2,
|
||||||
circuitBreakerCooldownMs: 60_000,
|
circuitBreakerCooldownMs: 60_000,
|
||||||
@@ -3662,11 +3667,12 @@ describe("active-memory plugin", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("resets circuit breaker after a successful recall", async () => {
|
it("resets circuit breaker after a successful recall", async () => {
|
||||||
|
const CONFIGURED_TIMEOUT_MS = 25;
|
||||||
__testing.setMinimumTimeoutMsForTests(1);
|
__testing.setMinimumTimeoutMsForTests(1);
|
||||||
__testing.setSetupGraceTimeoutMsForTests(0);
|
__testing.setSetupGraceTimeoutMsForTests(0);
|
||||||
api.pluginConfig = {
|
api.pluginConfig = {
|
||||||
agents: ["main"],
|
agents: ["main"],
|
||||||
timeoutMs: 50,
|
timeoutMs: CONFIGURED_TIMEOUT_MS,
|
||||||
logging: true,
|
logging: true,
|
||||||
circuitBreakerMaxTimeouts: 1,
|
circuitBreakerMaxTimeouts: 1,
|
||||||
circuitBreakerCooldownMs: 60_000,
|
circuitBreakerCooldownMs: 60_000,
|
||||||
|
|||||||
Reference in New Issue
Block a user