mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 20:44:32 +00:00
test(gateway): tighten health e2e timeout ceilings
This commit is contained in:
@@ -7,6 +7,10 @@ import { startGatewayServerHarness, type GatewayServerHarness } from "./server.e
|
|||||||
import { installGatewayTestHooks, onceMessage } from "./test-helpers.js";
|
import { installGatewayTestHooks, onceMessage } from "./test-helpers.js";
|
||||||
|
|
||||||
installGatewayTestHooks({ scope: "suite" });
|
installGatewayTestHooks({ scope: "suite" });
|
||||||
|
const HEALTH_E2E_TIMEOUT_MS = 30_000;
|
||||||
|
const PRESENCE_EVENT_TIMEOUT_MS = 6_000;
|
||||||
|
const SHUTDOWN_EVENT_TIMEOUT_MS = 3_000;
|
||||||
|
const FINGERPRINT_TIMEOUT_MS = 3_000;
|
||||||
|
|
||||||
let harness: GatewayServerHarness;
|
let harness: GatewayServerHarness;
|
||||||
|
|
||||||
@@ -29,7 +33,10 @@ afterAll(async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("gateway server health/presence", () => {
|
describe("gateway server health/presence", () => {
|
||||||
test("connect + health + presence + status succeed", { timeout: 60_000 }, async () => {
|
test(
|
||||||
|
"connect + health + presence + status succeed",
|
||||||
|
{ timeout: HEALTH_E2E_TIMEOUT_MS },
|
||||||
|
async () => {
|
||||||
const { ws } = await harness.openClient();
|
const { ws } = await harness.openClient();
|
||||||
|
|
||||||
const healthP = onceMessage<GatewayFrame>(ws, (o) => o.type === "res" && o.id === "health1");
|
const healthP = onceMessage<GatewayFrame>(ws, (o) => o.type === "res" && o.id === "health1");
|
||||||
@@ -61,7 +68,8 @@ describe("gateway server health/presence", () => {
|
|||||||
expect(Array.isArray(presence.payload)).toBe(true);
|
expect(Array.isArray(presence.payload)).toBe(true);
|
||||||
|
|
||||||
ws.close();
|
ws.close();
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
test("broadcasts heartbeat events and serves last-heartbeat", async () => {
|
test("broadcasts heartbeat events and serves last-heartbeat", async () => {
|
||||||
type HeartbeatPayload = {
|
type HeartbeatPayload = {
|
||||||
@@ -121,7 +129,10 @@ describe("gateway server health/presence", () => {
|
|||||||
ws.close();
|
ws.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("presence events carry seq + stateVersion", { timeout: 8000 }, async () => {
|
test(
|
||||||
|
"presence events carry seq + stateVersion",
|
||||||
|
{ timeout: PRESENCE_EVENT_TIMEOUT_MS },
|
||||||
|
async () => {
|
||||||
const { ws } = await harness.openClient();
|
const { ws } = await harness.openClient();
|
||||||
|
|
||||||
const presenceEventP = onceMessage<GatewayFrame>(
|
const presenceEventP = onceMessage<GatewayFrame>(
|
||||||
@@ -144,9 +155,10 @@ describe("gateway server health/presence", () => {
|
|||||||
expect(Array.isArray(evtPayload?.presence)).toBe(true);
|
expect(Array.isArray(evtPayload?.presence)).toBe(true);
|
||||||
|
|
||||||
ws.close();
|
ws.close();
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
test("agent events stream with seq", { timeout: 8000 }, async () => {
|
test("agent events stream with seq", { timeout: PRESENCE_EVENT_TIMEOUT_MS }, async () => {
|
||||||
const { ws } = await harness.openClient();
|
const { ws } = await harness.openClient();
|
||||||
|
|
||||||
const runId = randomUUID();
|
const runId = randomUUID();
|
||||||
@@ -169,13 +181,13 @@ describe("gateway server health/presence", () => {
|
|||||||
ws.close();
|
ws.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("shutdown event is broadcast on close", { timeout: 8000 }, async () => {
|
test("shutdown event is broadcast on close", { timeout: PRESENCE_EVENT_TIMEOUT_MS }, async () => {
|
||||||
const localHarness = await startGatewayServerHarness();
|
const localHarness = await startGatewayServerHarness();
|
||||||
const { ws } = await localHarness.openClient();
|
const { ws } = await localHarness.openClient();
|
||||||
const shutdownP = onceMessage<GatewayFrame>(
|
const shutdownP = onceMessage<GatewayFrame>(
|
||||||
ws,
|
ws,
|
||||||
(o) => o.type === "event" && o.event === "shutdown",
|
(o) => o.type === "event" && o.event === "shutdown",
|
||||||
5000,
|
SHUTDOWN_EVENT_TIMEOUT_MS,
|
||||||
);
|
);
|
||||||
await localHarness.close();
|
await localHarness.close();
|
||||||
const evt = await shutdownP;
|
const evt = await shutdownP;
|
||||||
@@ -183,7 +195,10 @@ describe("gateway server health/presence", () => {
|
|||||||
expect(evtPayload?.reason).toBeDefined();
|
expect(evtPayload?.reason).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("presence broadcast reaches multiple clients", { timeout: 8000 }, async () => {
|
test(
|
||||||
|
"presence broadcast reaches multiple clients",
|
||||||
|
{ timeout: PRESENCE_EVENT_TIMEOUT_MS },
|
||||||
|
async () => {
|
||||||
const clients = await Promise.all([
|
const clients = await Promise.all([
|
||||||
harness.openClient(),
|
harness.openClient(),
|
||||||
harness.openClient(),
|
harness.openClient(),
|
||||||
@@ -209,7 +224,8 @@ describe("gateway server health/presence", () => {
|
|||||||
for (const { ws } of clients) {
|
for (const { ws } of clients) {
|
||||||
ws.close();
|
ws.close();
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
test("presence includes client fingerprint", async () => {
|
test("presence includes client fingerprint", async () => {
|
||||||
const role = "operator";
|
const role = "operator";
|
||||||
@@ -231,7 +247,7 @@ describe("gateway server health/presence", () => {
|
|||||||
const presenceP = onceMessage<GatewayFrame>(
|
const presenceP = onceMessage<GatewayFrame>(
|
||||||
ws,
|
ws,
|
||||||
(o) => o.type === "res" && o.id === "fingerprint",
|
(o) => o.type === "res" && o.id === "fingerprint",
|
||||||
4000,
|
FINGERPRINT_TIMEOUT_MS,
|
||||||
);
|
);
|
||||||
ws.send(
|
ws.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
|
|||||||
Reference in New Issue
Block a user