From a0358bbf1857c6000eb7f7d69cfc31b20eb36f06 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 22 May 2026 17:43:45 +0100 Subject: [PATCH] test(release): wait for config reload log proof --- scripts/e2e/lib/config-reload/assert-log.mjs | 50 +++++++++++++++----- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/scripts/e2e/lib/config-reload/assert-log.mjs b/scripts/e2e/lib/config-reload/assert-log.mjs index 8d9c78a0d0d..b0c8b21f6c9 100644 --- a/scripts/e2e/lib/config-reload/assert-log.mjs +++ b/scripts/e2e/lib/config-reload/assert-log.mjs @@ -1,26 +1,50 @@ import fs from "node:fs"; -const log = fs.readFileSync("/tmp/config-reload-e2e.log", "utf8"); -const reloadLines = log - .split("\n") - .filter((line) => line.includes("config change detected; evaluating reload")); -const restartLines = log - .split("\n") - .filter((line) => line.includes("config change requires gateway restart")); +const logPath = process.env.OPENCLAW_CONFIG_RELOAD_LOG_PATH ?? "/tmp/config-reload-e2e.log"; +const deadlineMs = Date.now() + Number(process.env.OPENCLAW_CONFIG_RELOAD_LOG_TIMEOUT_MS ?? 30_000); -if (restartLines.length > 0) { - console.error(log.split("\n").slice(-160).join("\n")); +const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); + +function readLog() { + return fs.readFileSync(logPath, "utf8"); +} + +function inspectLog(log) { + const lines = log.split("\n"); + const reloadLines = lines.filter((line) => + line.includes("config change detected; evaluating reload"), + ); + const restartLines = lines.filter((line) => + line.includes("config change requires gateway restart"), + ); + return { lines, reloadLines, restartLines }; +} + +let log = ""; +let result = { lines: [], reloadLines: [], restartLines: [] }; + +while (Date.now() < deadlineMs) { + log = readLog(); + result = inspectLog(log); + if (result.restartLines.length > 0 || result.reloadLines.length > 0) { + break; + } + await sleep(500); +} + +if (result.restartLines.length > 0) { + console.error(result.lines.slice(-160).join("\n")); throw new Error("unexpected restart-required reload line found"); } -for (const line of reloadLines) { +for (const line of result.reloadLines) { for (const needle of ["gateway.auth.token", "plugins.entries.firecrawl.config.webFetch"]) { if (line.includes(needle)) { - console.error(log.split("\n").slice(-160).join("\n")); + console.error(result.lines.slice(-160).join("\n")); throw new Error(`runtime-only path appeared in reload diff: ${needle}`); } } } -if (reloadLines.length === 0) { - console.error(log.split("\n").slice(-160).join("\n")); +if (result.reloadLines.length === 0) { + console.error(result.lines.slice(-160).join("\n")); throw new Error("expected config reload detection log after metadata write"); }