Vendor OpenClaw source as Adolf fork baseline
Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
This commit is contained in:
447
test/scripts/upgrade-survivor-probe-gateway.test.ts
Normal file
447
test/scripts/upgrade-survivor-probe-gateway.test.ts
Normal file
@@ -0,0 +1,447 @@
|
||||
// Upgrade Survivor Probe Gateway tests cover upgrade survivor probe gateway script behavior.
|
||||
import { spawn } from "node:child_process";
|
||||
import fs from "node:fs";
|
||||
import { createServer as createHttpServer } from "node:http";
|
||||
import { createServer as createTcpServer, type Server, type Socket } from "node:net";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { createBoundedChildOutput } from "../helpers/bounded-child-output.js";
|
||||
|
||||
const probePath = path.resolve("scripts/e2e/lib/upgrade-survivor/probe-gateway.mjs");
|
||||
const dockerSurvivorPath = path.resolve("scripts/e2e/upgrade-survivor-docker.sh");
|
||||
const tempDirs: string[] = [];
|
||||
|
||||
function makeTempDir(): string {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-upgrade-probe-"));
|
||||
tempDirs.push(dir);
|
||||
return dir;
|
||||
}
|
||||
|
||||
interface ProbeResult {
|
||||
error?: Error;
|
||||
signal: NodeJS.Signals | null;
|
||||
status: number | null;
|
||||
stderr: string;
|
||||
stdout: string;
|
||||
}
|
||||
|
||||
function runProbe(
|
||||
args: string[],
|
||||
timeout = 5_000,
|
||||
env: NodeJS.ProcessEnv = {},
|
||||
): Promise<ProbeResult> {
|
||||
return new Promise((resolve) => {
|
||||
const child = spawn(process.execPath, [probePath, ...args], {
|
||||
env: { ...process.env, ...env },
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
});
|
||||
const stdout = createBoundedChildOutput();
|
||||
const stderr = createBoundedChildOutput();
|
||||
let timedOut = false;
|
||||
child.stdout.setEncoding("utf8");
|
||||
child.stderr.setEncoding("utf8");
|
||||
child.stdout.on("data", (chunk) => {
|
||||
stdout.append(chunk);
|
||||
});
|
||||
child.stderr.on("data", (chunk) => {
|
||||
stderr.append(chunk);
|
||||
});
|
||||
const timer = setTimeout(() => {
|
||||
timedOut = true;
|
||||
child.kill("SIGKILL");
|
||||
}, timeout);
|
||||
child.on("error", (error) => {
|
||||
clearTimeout(timer);
|
||||
resolve({ error, signal: null, status: null, stderr: stderr.text(), stdout: stdout.text() });
|
||||
});
|
||||
child.on("exit", (status, signal) => {
|
||||
clearTimeout(timer);
|
||||
resolve({
|
||||
error: timedOut ? new Error(`probe timed out after ${timeout}ms`) : undefined,
|
||||
signal,
|
||||
status,
|
||||
stderr: stderr.text(),
|
||||
stdout: stdout.text(),
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function listen(server: Server): Promise<string> {
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
server.once("error", reject);
|
||||
server.listen(0, "127.0.0.1", () => {
|
||||
server.off("error", reject);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
const address = server.address();
|
||||
if (!address || typeof address === "string") {
|
||||
throw new Error("test server did not expose a TCP port");
|
||||
}
|
||||
return `http://127.0.0.1:${address.port}`;
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
for (const dir of tempDirs.splice(0)) {
|
||||
fs.rmSync(dir, { force: true, recursive: true });
|
||||
}
|
||||
});
|
||||
|
||||
describe("scripts/e2e/lib/upgrade-survivor/probe-gateway.mjs", () => {
|
||||
it("does not hard-code degraded ready allowlists into Docker survivor probes", () => {
|
||||
const script = fs.readFileSync(dockerSurvivorPath, "utf8");
|
||||
|
||||
expect(script).not.toContain("--allow-failing discord,telegram,whatsapp,feishu,matrix");
|
||||
});
|
||||
|
||||
it("rejects loose numeric probe limits instead of parsing prefixes", async () => {
|
||||
const out = path.join(makeTempDir(), "invalid.json");
|
||||
const timeoutResult = await runProbe([
|
||||
"--base-url",
|
||||
"http://127.0.0.1:9",
|
||||
"--path",
|
||||
"/readyz",
|
||||
"--expect",
|
||||
"ready",
|
||||
"--out",
|
||||
out,
|
||||
"--timeout-ms",
|
||||
"1e3",
|
||||
]);
|
||||
|
||||
expect(timeoutResult.status).not.toBe(0);
|
||||
expect(timeoutResult.stderr).toContain("invalid --timeout-ms: 1e3");
|
||||
|
||||
const bodyLimitResult = await runProbe(
|
||||
["--base-url", "http://127.0.0.1:9", "--path", "/readyz", "--expect", "ready", "--out", out],
|
||||
5_000,
|
||||
{
|
||||
OPENCLAW_UPGRADE_SURVIVOR_PROBE_MAX_BODY_BYTES: "64bytes",
|
||||
},
|
||||
);
|
||||
|
||||
expect(bodyLimitResult.status).not.toBe(0);
|
||||
expect(bodyLimitResult.stderr).toContain(
|
||||
"invalid OPENCLAW_UPGRADE_SURVIVOR_PROBE_MAX_BODY_BYTES: 64bytes",
|
||||
);
|
||||
});
|
||||
|
||||
it("writes a result when the ready probe matches", async () => {
|
||||
const server = createHttpServer((_request, response) => {
|
||||
response.writeHead(200, { "content-type": "application/json" });
|
||||
response.end(JSON.stringify({ ready: true }));
|
||||
});
|
||||
const baseUrl = await listen(server);
|
||||
const out = path.join(makeTempDir(), "ready.json");
|
||||
try {
|
||||
const result = await runProbe([
|
||||
"--base-url",
|
||||
baseUrl,
|
||||
"--path",
|
||||
"/readyz",
|
||||
"--expect",
|
||||
"ready",
|
||||
"--out",
|
||||
out,
|
||||
"--timeout-ms",
|
||||
"1000",
|
||||
]);
|
||||
|
||||
expect(result.status).toBe(0);
|
||||
expect(JSON.parse(fs.readFileSync(out, "utf8"))).toMatchObject({
|
||||
body: { ready: true },
|
||||
path: "/readyz",
|
||||
status: 200,
|
||||
url: `${baseUrl}/readyz`,
|
||||
});
|
||||
} finally {
|
||||
server.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects degraded ready responses by default even when failing components are allowlisted", async () => {
|
||||
const server = createHttpServer((_request, response) => {
|
||||
response.writeHead(503, { "content-type": "application/json" });
|
||||
response.end(JSON.stringify({ ready: false, failing: ["telegram"] }));
|
||||
});
|
||||
const baseUrl = await listen(server);
|
||||
const out = path.join(makeTempDir(), "ready-degraded.json");
|
||||
try {
|
||||
const result = await runProbe([
|
||||
"--base-url",
|
||||
baseUrl,
|
||||
"--path",
|
||||
"/readyz",
|
||||
"--expect",
|
||||
"ready",
|
||||
"--allow-failing",
|
||||
"telegram",
|
||||
"--out",
|
||||
out,
|
||||
"--timeout-ms",
|
||||
"300",
|
||||
]);
|
||||
|
||||
expect(result.status).not.toBe(0);
|
||||
expect(result.stderr).toContain("probe failed with HTTP 503");
|
||||
expect(fs.existsSync(out)).toBe(false);
|
||||
} finally {
|
||||
server.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps failed probe retries inside the total timeout", async () => {
|
||||
const server = createHttpServer((_request, response) => {
|
||||
response.writeHead(503, { "content-type": "application/json" });
|
||||
response.end(JSON.stringify({ ready: false, failing: ["gateway"] }));
|
||||
});
|
||||
const baseUrl = await listen(server);
|
||||
const out = path.join(makeTempDir(), "ready-timeout.json");
|
||||
const startedAt = Date.now();
|
||||
try {
|
||||
const result = await runProbe([
|
||||
"--base-url",
|
||||
baseUrl,
|
||||
"--path",
|
||||
"/readyz",
|
||||
"--expect",
|
||||
"ready",
|
||||
"--out",
|
||||
out,
|
||||
"--timeout-ms",
|
||||
"50",
|
||||
"--attempt-timeout-ms",
|
||||
"25",
|
||||
]);
|
||||
|
||||
expect(result.status).not.toBe(0);
|
||||
expect(Date.now() - startedAt).toBeLessThan(300);
|
||||
expect(result.stderr).toContain("probe did not satisfy ready within 50ms");
|
||||
expect(fs.existsSync(out)).toBe(false);
|
||||
} finally {
|
||||
server.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("allows degraded ready responses only when degraded readiness is explicit", async () => {
|
||||
const server = createHttpServer((_request, response) => {
|
||||
response.writeHead(503, { "content-type": "application/json" });
|
||||
response.end(JSON.stringify({ ready: false, failing: ["telegram"] }));
|
||||
});
|
||||
const baseUrl = await listen(server);
|
||||
const out = path.join(makeTempDir(), "ready-degraded.json");
|
||||
try {
|
||||
const result = await runProbe([
|
||||
"--base-url",
|
||||
baseUrl,
|
||||
"--path",
|
||||
"/readyz",
|
||||
"--expect",
|
||||
"ready",
|
||||
"--allow-failing",
|
||||
"telegram",
|
||||
"--allow-degraded-ready",
|
||||
"--out",
|
||||
out,
|
||||
"--timeout-ms",
|
||||
"300",
|
||||
]);
|
||||
|
||||
expect(result.status).toBe(0);
|
||||
expect(JSON.parse(fs.readFileSync(out, "utf8"))).toMatchObject({
|
||||
body: { failing: ["telegram"], ready: false },
|
||||
path: "/readyz",
|
||||
status: 503,
|
||||
});
|
||||
} finally {
|
||||
server.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("does not let degraded ready mode convert generic server errors into success", async () => {
|
||||
const server = createHttpServer((_request, response) => {
|
||||
response.writeHead(500, { "content-type": "application/json" });
|
||||
response.end(JSON.stringify({ ready: true }));
|
||||
});
|
||||
const baseUrl = await listen(server);
|
||||
const out = path.join(makeTempDir(), "ready-server-error.json");
|
||||
try {
|
||||
const result = await runProbe([
|
||||
"--base-url",
|
||||
baseUrl,
|
||||
"--path",
|
||||
"/readyz",
|
||||
"--expect",
|
||||
"ready",
|
||||
"--allow-failing",
|
||||
"telegram",
|
||||
"--allow-degraded-ready",
|
||||
"--out",
|
||||
out,
|
||||
"--timeout-ms",
|
||||
"300",
|
||||
]);
|
||||
|
||||
expect(result.status).not.toBe(0);
|
||||
expect(result.stderr).toContain("probe failed with HTTP 500");
|
||||
expect(fs.existsSync(out)).toBe(false);
|
||||
} finally {
|
||||
server.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects declared oversized probe bodies before waiting on the stream", async () => {
|
||||
const server = createHttpServer((_request, response) => {
|
||||
response.writeHead(200, {
|
||||
"content-length": "65",
|
||||
"content-type": "application/json",
|
||||
});
|
||||
response.flushHeaders();
|
||||
});
|
||||
const baseUrl = await listen(server);
|
||||
const out = path.join(makeTempDir(), "oversized.json");
|
||||
const startedAt = Date.now();
|
||||
try {
|
||||
const result = await runProbe(
|
||||
[
|
||||
"--base-url",
|
||||
baseUrl,
|
||||
"--path",
|
||||
"/healthz",
|
||||
"--expect",
|
||||
"live",
|
||||
"--out",
|
||||
out,
|
||||
"--timeout-ms",
|
||||
"1000",
|
||||
],
|
||||
5_000,
|
||||
{ OPENCLAW_UPGRADE_SURVIVOR_PROBE_MAX_BODY_BYTES: "64" },
|
||||
);
|
||||
|
||||
expect(result.error).toBeUndefined();
|
||||
expect(result.status).not.toBe(0);
|
||||
expect(result.stderr).toContain(`${baseUrl}/healthz probe body exceeded 64 bytes`);
|
||||
expect(fs.existsSync(out)).toBe(false);
|
||||
expect(Date.now() - startedAt).toBeLessThan(3_500);
|
||||
} finally {
|
||||
server.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("bounds probes when a server accepts the connection but never responds", async () => {
|
||||
const sockets = new Set<Socket>();
|
||||
const server = createTcpServer((socket) => {
|
||||
sockets.add(socket);
|
||||
socket.on("close", () => sockets.delete(socket));
|
||||
socket.on("data", () => {});
|
||||
});
|
||||
const baseUrl = await listen(server);
|
||||
const out = path.join(makeTempDir(), "stall.json");
|
||||
const startedAt = Date.now();
|
||||
try {
|
||||
const result = await runProbe([
|
||||
"--base-url",
|
||||
baseUrl,
|
||||
"--path",
|
||||
"/healthz",
|
||||
"--expect",
|
||||
"live",
|
||||
"--out",
|
||||
out,
|
||||
"--timeout-ms",
|
||||
"300",
|
||||
"--attempt-timeout-ms",
|
||||
"100",
|
||||
]);
|
||||
const elapsedMs = Date.now() - startedAt;
|
||||
|
||||
expect(result.error).toBeUndefined();
|
||||
expect(result.status).not.toBe(0);
|
||||
expect(result.stderr).toContain("probe did not satisfy live within 300ms");
|
||||
expect(elapsedMs).toBeLessThan(2_500);
|
||||
expect(fs.existsSync(out)).toBe(false);
|
||||
} finally {
|
||||
for (const socket of sockets) {
|
||||
socket.destroy();
|
||||
}
|
||||
server.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps the attempt timeout active while reading probe bodies", async () => {
|
||||
const sockets = new Set<Socket>();
|
||||
const server = createHttpServer((_request, response) => {
|
||||
response.writeHead(200, { "content-type": "application/json" });
|
||||
response.write('{"ok":');
|
||||
});
|
||||
server.on("connection", (socket) => {
|
||||
sockets.add(socket);
|
||||
socket.on("close", () => sockets.delete(socket));
|
||||
});
|
||||
const baseUrl = await listen(server);
|
||||
const out = path.join(makeTempDir(), "body-stall.json");
|
||||
const startedAt = Date.now();
|
||||
try {
|
||||
const result = await runProbe([
|
||||
"--base-url",
|
||||
baseUrl,
|
||||
"--path",
|
||||
"/healthz",
|
||||
"--expect",
|
||||
"live",
|
||||
"--out",
|
||||
out,
|
||||
"--timeout-ms",
|
||||
"300",
|
||||
"--attempt-timeout-ms",
|
||||
"100",
|
||||
]);
|
||||
const elapsedMs = Date.now() - startedAt;
|
||||
|
||||
expect(result.error).toBeUndefined();
|
||||
expect(result.status).not.toBe(0);
|
||||
expect(result.stderr).toContain("probe attempt timed out after 100ms");
|
||||
expect(elapsedMs).toBeLessThan(2_500);
|
||||
expect(fs.existsSync(out)).toBe(false);
|
||||
} finally {
|
||||
for (const socket of sockets) {
|
||||
socket.destroy();
|
||||
}
|
||||
server.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("caps response bodies before parsing probe JSON", async () => {
|
||||
const server = createHttpServer((_request, response) => {
|
||||
response.writeHead(200, { "content-type": "application/json" });
|
||||
response.end("x".repeat(256));
|
||||
});
|
||||
const baseUrl = await listen(server);
|
||||
const out = path.join(makeTempDir(), "oversized.json");
|
||||
try {
|
||||
const result = await runProbe([
|
||||
"--base-url",
|
||||
baseUrl,
|
||||
"--path",
|
||||
"/readyz",
|
||||
"--expect",
|
||||
"ready",
|
||||
"--out",
|
||||
out,
|
||||
"--timeout-ms",
|
||||
"300",
|
||||
"--max-body-bytes",
|
||||
"64",
|
||||
]);
|
||||
|
||||
expect(result.status).not.toBe(0);
|
||||
expect(result.stderr).toContain("probe body exceeded 64 bytes");
|
||||
expect(fs.existsSync(out)).toBe(false);
|
||||
} finally {
|
||||
server.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user