fix(e2e): require kitchen sink ready body

This commit is contained in:
Vincent Koc
2026-06-06 18:00:47 +02:00
parent 9c2d243803
commit ec4c79cb38
2 changed files with 26 additions and 2 deletions

View File

@@ -994,10 +994,10 @@ export async function waitForGatewayReady(child, port, logPath, options = {}) {
throw outcome.error;
}
const readyz = outcome.readyz;
if (readyz.ok) {
if (readyz.ok && readyz.body?.ready === true) {
return;
}
lastError = `/readyz HTTP ${readyz.status}`;
lastError = `/readyz HTTP ${readyz.status} body=${JSON.stringify(readyz.body)}`;
} catch (error) {
lastError = error instanceof Error ? error.message : String(error);
}

View File

@@ -302,6 +302,30 @@ describe("kitchen-sink RPC gateway teardown", () => {
rmSync(root, { recursive: true, force: true });
}
});
it("requires /readyz body.ready before accepting gateway readiness", async () => {
const root = mkdtempSync(path.join(tmpdir(), "openclaw-kitchen-rpc-ready-body-"));
try {
const logPath = path.join(root, "gateway.log");
writeFileSync(logPath, "[gateway] ready\n");
const fetchImpl = vi
.fn()
.mockResolvedValueOnce(new Response('{"ready":false}', { status: 200 }))
.mockResolvedValueOnce(new Response('{"ready":true}', { status: 200 }));
await expect(
waitForGatewayReady({ exitCode: null, signalCode: null }, 9, logPath, {
fetchImpl,
pollDelayMs: 1,
timeoutMs: 100,
}),
).resolves.toBeUndefined();
expect(fetchImpl).toHaveBeenCalledTimes(2);
} finally {
rmSync(root, { recursive: true, force: true });
}
});
});
describe("kitchen-sink RPC gateway readiness logs", () => {