mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 10:16:44 +00:00
fix(ci): bound performance gateway health probes (#108621)
This commit is contained in:
@@ -745,8 +745,22 @@ jobs:
|
||||
>"$gateway_log" 2>&1 &
|
||||
gateway_pid="$!"
|
||||
|
||||
for _ in $(seq 1 120); do
|
||||
if curl -fsS "http://127.0.0.1:${gateway_port}/healthz" >/dev/null; then
|
||||
gateway_ready_timeout_seconds=120
|
||||
gateway_probe_timeout_seconds=5
|
||||
gateway_ready_deadline=$((SECONDS + gateway_ready_timeout_seconds))
|
||||
while true; do
|
||||
gateway_ready_remaining=$((gateway_ready_deadline - SECONDS))
|
||||
if (( gateway_ready_remaining <= 0 )); then
|
||||
cat "$gateway_log" >&2
|
||||
echo "Timed out after ${gateway_ready_timeout_seconds}s waiting for gateway health." >&2
|
||||
exit 1
|
||||
fi
|
||||
# Clamp each probe to the remaining startup budget so a stalled response cannot multiply the wait.
|
||||
gateway_probe_timeout="$gateway_ready_remaining"
|
||||
if (( gateway_probe_timeout > gateway_probe_timeout_seconds )); then
|
||||
gateway_probe_timeout="$gateway_probe_timeout_seconds"
|
||||
fi
|
||||
if curl -fsS --connect-timeout 2 --max-time "$gateway_probe_timeout" "http://127.0.0.1:${gateway_port}/healthz" >/dev/null; then
|
||||
break
|
||||
fi
|
||||
if ! kill -0 "$gateway_pid" 2>/dev/null; then
|
||||
@@ -755,7 +769,6 @@ jobs:
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
curl -fsS "http://127.0.0.1:${gateway_port}/healthz" >/dev/null
|
||||
|
||||
OPENCLAW_HOME="$gateway_home" OPENCLAW_STATE_DIR="$gateway_state" OPENCLAW_CONFIG_PATH="$gateway_config" OPENCLAW_GATEWAY_PORT="$gateway_port" \
|
||||
node --import tsx scripts/bench-cli-startup.ts \
|
||||
|
||||
@@ -191,6 +191,40 @@ describe("OpenClaw performance workflow", () => {
|
||||
expect(run.indexOf("pnpm build")).toBeLessThan(run.indexOf("pnpm test:gateway:cpu-scenarios"));
|
||||
});
|
||||
|
||||
it("keeps source gateway health waits within one startup budget", () => {
|
||||
const run = findStep("Run OpenClaw source performance probes", "source_performance").run ?? "";
|
||||
const deadline = "gateway_ready_deadline=$((SECONDS + gateway_ready_timeout_seconds))";
|
||||
const remaining = "gateway_ready_remaining=$((gateway_ready_deadline - SECONDS))";
|
||||
const deadlineFailure = [
|
||||
" if (( gateway_ready_remaining <= 0 )); then",
|
||||
' cat "$gateway_log" >&2',
|
||||
' echo "Timed out after ${gateway_ready_timeout_seconds}s waiting for gateway health." >&2',
|
||||
" exit 1",
|
||||
" fi",
|
||||
].join("\n");
|
||||
const probeCap = [
|
||||
' gateway_probe_timeout="$gateway_ready_remaining"',
|
||||
" if (( gateway_probe_timeout > gateway_probe_timeout_seconds )); then",
|
||||
' gateway_probe_timeout="$gateway_probe_timeout_seconds"',
|
||||
" fi",
|
||||
].join("\n");
|
||||
const boundedProbe =
|
||||
'curl -fsS --connect-timeout 2 --max-time "$gateway_probe_timeout" "http://127.0.0.1:${gateway_port}/healthz"';
|
||||
|
||||
expect(run).toContain("gateway_ready_timeout_seconds=120");
|
||||
expect(run).toContain("gateway_probe_timeout_seconds=5");
|
||||
expect(run).toContain(deadline);
|
||||
expect(run).toContain(remaining);
|
||||
expect(run).toContain(deadlineFailure);
|
||||
expect(run).toContain(probeCap);
|
||||
expect(run).toContain(boundedProbe);
|
||||
expect(run.split("/healthz")).toHaveLength(2);
|
||||
expect(run.indexOf(deadline)).toBeLessThan(run.indexOf(remaining));
|
||||
expect(run.indexOf(remaining)).toBeLessThan(run.indexOf(deadlineFailure));
|
||||
expect(run.indexOf(deadlineFailure)).toBeLessThan(run.indexOf(probeCap));
|
||||
expect(run.indexOf(probeCap)).toBeLessThan(run.indexOf(boundedProbe));
|
||||
});
|
||||
|
||||
it("isolates required publication in a fresh artifact-consuming job", () => {
|
||||
const workflow = readWorkflow();
|
||||
const publisher = workflow.jobs?.publish;
|
||||
|
||||
Reference in New Issue
Block a user