mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:20:43 +00:00
Wait for gateway version during restart
This commit is contained in:
committed by
Peter Steinberger
parent
f53ec52e7d
commit
b46ff081f7
@@ -572,6 +572,47 @@ describe("inspectGatewayRestart", () => {
|
||||
expect(sleep).toHaveBeenCalledTimes(185);
|
||||
});
|
||||
|
||||
it("keeps waiting when the expected gateway version is not available yet", async () => {
|
||||
const service = makeGatewayService({ status: "running", pid: 8000 });
|
||||
inspectPortUsage
|
||||
.mockResolvedValueOnce({
|
||||
port: 18789,
|
||||
status: "free",
|
||||
listeners: [],
|
||||
hints: [],
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
port: 18789,
|
||||
status: "busy",
|
||||
listeners: [{ pid: 8000, commandLine: "openclaw-gateway" }],
|
||||
hints: [],
|
||||
});
|
||||
probeGateway.mockResolvedValue({
|
||||
ok: true,
|
||||
close: null,
|
||||
server: { version: "2026.4.26", connId: "new" },
|
||||
});
|
||||
|
||||
const { waitForGatewayHealthyRestart } = await import("./restart-health.js");
|
||||
const snapshot = await waitForGatewayHealthyRestart({
|
||||
service,
|
||||
port: 18789,
|
||||
expectedVersion: "2026.4.26",
|
||||
attempts: 4,
|
||||
delayMs: 1_000,
|
||||
});
|
||||
|
||||
expect(snapshot).toMatchObject({
|
||||
healthy: true,
|
||||
gatewayVersion: "2026.4.26",
|
||||
expectedVersion: "2026.4.26",
|
||||
waitOutcome: "healthy",
|
||||
elapsedMs: 1_000,
|
||||
});
|
||||
expect(snapshot.versionMismatch).toBeUndefined();
|
||||
expect(sleep).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("annotates timeout waits when the health loop exhausts all attempts", async () => {
|
||||
const service = makeGatewayService({ status: "running", pid: 8000 });
|
||||
inspectPortUsage.mockResolvedValue({
|
||||
|
||||
@@ -123,6 +123,9 @@ function applyExpectedVersion(
|
||||
if (snapshot.gatewayVersion === expectedVersion) {
|
||||
return { ...snapshot, expectedVersion };
|
||||
}
|
||||
if (snapshot.gatewayVersion == null) {
|
||||
return { ...snapshot, healthy: false, expectedVersion };
|
||||
}
|
||||
return {
|
||||
...snapshot,
|
||||
healthy: false,
|
||||
|
||||
Reference in New Issue
Block a user