mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 12:56:01 -06:00
test(release): await restarted channel runtime
This commit is contained in:
@@ -328,10 +328,24 @@ async function waitClickClackSocket() {
|
||||
30,
|
||||
"ClickClack websocket timeout seconds",
|
||||
);
|
||||
await waitForClickClackSocket({ baseUrl, timeoutMs: timeoutSeconds * 1000 });
|
||||
const minimumSocketCount = readPositiveInt(
|
||||
process.argv[5],
|
||||
1,
|
||||
"ClickClack minimum websocket count",
|
||||
);
|
||||
await waitForClickClackSocket({
|
||||
baseUrl,
|
||||
timeoutMs: timeoutSeconds * 1000,
|
||||
minimumSocketCount,
|
||||
});
|
||||
}
|
||||
|
||||
export async function waitForClickClackSocket({ baseUrl, timeoutMs, pollIntervalMs = 250 }) {
|
||||
export async function waitForClickClackSocket({
|
||||
baseUrl,
|
||||
timeoutMs,
|
||||
minimumSocketCount = 1,
|
||||
pollIntervalMs = 250,
|
||||
}) {
|
||||
const deadline = Date.now() + timeoutMs;
|
||||
while (Date.now() < deadline) {
|
||||
const remainingMs = Math.max(1, deadline - Date.now());
|
||||
@@ -347,7 +361,7 @@ export async function waitForClickClackSocket({ baseUrl, timeoutMs, pollInterval
|
||||
},
|
||||
).catch(() => undefined);
|
||||
if (state) {
|
||||
if (Number(state.socketCount ?? 0) > 0) {
|
||||
if (Number(state.socketCount ?? 0) >= minimumSocketCount) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -355,7 +369,9 @@ export async function waitForClickClackSocket({ baseUrl, timeoutMs, pollInterval
|
||||
setTimeout(resolve, Math.min(pollIntervalMs, Math.max(0, deadline - Date.now())));
|
||||
});
|
||||
}
|
||||
throw new Error(`Timed out waiting for ClickClack websocket connection at ${baseUrl}`);
|
||||
throw new Error(
|
||||
`Timed out waiting for ${minimumSocketCount} ClickClack websocket connection(s) at ${baseUrl}`,
|
||||
);
|
||||
}
|
||||
|
||||
function assertClickClackState() {
|
||||
|
||||
@@ -244,6 +244,7 @@ node scripts/e2e/lib/release-user-journey/assertions.mjs wait-clickclack-reply "
|
||||
echo "Restarting Gateway and checking state survival..."
|
||||
stop_gateway
|
||||
start_gateway "$GATEWAY_2_LOG"
|
||||
node scripts/e2e/lib/release-user-journey/assertions.mjs wait-clickclack-socket "http://127.0.0.1:$CLICKCLACK_PORT" 45 2
|
||||
openclaw plugins inspect journey-plugin-b --runtime --json >"$PLUGIN_B_AFTER_RESTART_JSON" 2>&1
|
||||
openclaw channels status --json >"$STATUS_AFTER_RESTART_JSON" 2>"$STATUS_AFTER_RESTART_ERR"
|
||||
node scripts/e2e/lib/release-user-journey/assertions.mjs assert-channel-running clickclack "$STATUS_AFTER_RESTART_JSON"
|
||||
|
||||
@@ -326,8 +326,10 @@ describe("release user journey assertions", () => {
|
||||
it("accepts ready ClickClack fixture state", async () => {
|
||||
const root = mkdtempSync(path.join(tmpdir(), "openclaw-release-user-assertions-"));
|
||||
const home = path.join(root, "home");
|
||||
let requestCount = 0;
|
||||
const server = await startTcpFixtureServer((socket) => {
|
||||
const body = JSON.stringify({ socketCount: 1 });
|
||||
requestCount += 1;
|
||||
const body = JSON.stringify({ socketCount: requestCount });
|
||||
socket.end(
|
||||
`HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: ${Buffer.byteLength(body)}\r\n\r\n${body}`,
|
||||
);
|
||||
@@ -339,9 +341,11 @@ describe("release user journey assertions", () => {
|
||||
runReleaseUserJourneyAssertion("wait-clickclack-socket", [
|
||||
`http://127.0.0.1:${server.port}`,
|
||||
"1",
|
||||
"2",
|
||||
]),
|
||||
),
|
||||
).resolves.toBeUndefined();
|
||||
expect(requestCount).toBe(2);
|
||||
} finally {
|
||||
await server.stop();
|
||||
rmSync(root, { force: true, recursive: true });
|
||||
@@ -392,7 +396,7 @@ describe("release user journey assertions", () => {
|
||||
timeoutMs: 150,
|
||||
}),
|
||||
),
|
||||
).rejects.toThrow("Timed out waiting for ClickClack websocket connection");
|
||||
).rejects.toThrow("Timed out waiting for 1 ClickClack websocket connection");
|
||||
expect(Date.now() - startedAt).toBeLessThan(750);
|
||||
} finally {
|
||||
await server.stop();
|
||||
|
||||
Reference in New Issue
Block a user