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
362 lines
9.4 KiB
TypeScript
362 lines
9.4 KiB
TypeScript
// Live Docker Auth tests cover live docker auth script behavior.
|
|
import { spawnSync } from "node:child_process";
|
|
import { chmodSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import path from "node:path";
|
|
import { afterEach, describe, expect, it } from "vitest";
|
|
|
|
const tempDirs: string[] = [];
|
|
|
|
function makeTempBin(prefix: string) {
|
|
const dir = mkdtempSync(path.join(tmpdir(), prefix));
|
|
tempDirs.push(dir);
|
|
return dir;
|
|
}
|
|
|
|
function writeExecutable(filePath: string, contents: string) {
|
|
writeFileSync(filePath, contents, "utf8");
|
|
chmodSync(filePath, 0o755);
|
|
}
|
|
|
|
function runDockerRunArgs(pathPrefix: string) {
|
|
const script = [
|
|
"source scripts/lib/live-docker-auth.sh",
|
|
"unset OPENCLAW_LIVE_DOCKER_DISABLE_RESOURCE_LIMITS OPENCLAW_DOCKER_E2E_DISABLE_RESOURCE_LIMITS",
|
|
"unset OPENCLAW_LIVE_DOCKER_MEMORY OPENCLAW_DOCKER_E2E_MEMORY",
|
|
"unset OPENCLAW_LIVE_DOCKER_CPUS OPENCLAW_DOCKER_E2E_CPUS",
|
|
"unset OPENCLAW_LIVE_DOCKER_PIDS_LIMIT OPENCLAW_DOCKER_E2E_PIDS_LIMIT",
|
|
"ARGS=()",
|
|
"openclaw_live_init_docker_run_args ARGS 42s || exit $?",
|
|
"printf '%s\\n' \"${ARGS[@]}\"",
|
|
].join("\n");
|
|
|
|
return spawnSync("/bin/bash", ["-c", script], {
|
|
cwd: process.cwd(),
|
|
encoding: "utf8",
|
|
env: {
|
|
...process.env,
|
|
PATH: pathPrefix,
|
|
},
|
|
});
|
|
}
|
|
|
|
function resolveDockerRunArgs(pathPrefix: string) {
|
|
const result = runDockerRunArgs(pathPrefix);
|
|
if (result.status !== 0) {
|
|
throw new Error(result.stderr || result.stdout);
|
|
}
|
|
return result.stdout.trimEnd().split("\n");
|
|
}
|
|
|
|
afterEach(() => {
|
|
while (tempDirs.length > 0) {
|
|
rmSync(tempDirs.pop()!, { force: true, recursive: true });
|
|
}
|
|
});
|
|
|
|
describe("scripts/lib/live-docker-auth.sh", () => {
|
|
it("reads positive integer env values before live Docker setup", () => {
|
|
const result = spawnSync(
|
|
"/bin/bash",
|
|
[
|
|
"-c",
|
|
[
|
|
"source scripts/lib/live-docker-auth.sh",
|
|
'fallback="$(openclaw_live_read_positive_int_env OPENCLAW_LIVE_SAMPLE_SECONDS 180)"',
|
|
'leading_zero="$(OPENCLAW_LIVE_SAMPLE_SECONDS=008 openclaw_live_read_positive_int_env OPENCLAW_LIVE_SAMPLE_SECONDS 180)"',
|
|
'printf "%s\\n%s\\n" "$fallback" "$leading_zero"',
|
|
].join("\n"),
|
|
],
|
|
{ cwd: process.cwd(), encoding: "utf8" },
|
|
);
|
|
const invalid = spawnSync(
|
|
"/bin/bash",
|
|
[
|
|
"-c",
|
|
[
|
|
"source scripts/lib/live-docker-auth.sh",
|
|
"OPENCLAW_LIVE_SAMPLE_SECONDS=30s openclaw_live_read_positive_int_env OPENCLAW_LIVE_SAMPLE_SECONDS 180",
|
|
].join("\n"),
|
|
],
|
|
{ cwd: process.cwd(), encoding: "utf8" },
|
|
);
|
|
|
|
expect(result.status).toBe(0);
|
|
expect(result.stdout.trimEnd().split("\n")).toEqual(["180", "008"]);
|
|
expect(invalid.status).toBe(2);
|
|
expect(invalid.stderr).toContain("invalid OPENCLAW_LIVE_SAMPLE_SECONDS: 30s");
|
|
});
|
|
|
|
it("adds a kill-after grace period when timeout supports it", () => {
|
|
const binDir = makeTempBin("openclaw-live-docker-auth-gnu-");
|
|
writeExecutable(
|
|
path.join(binDir, "timeout"),
|
|
[
|
|
"#!/bin/sh",
|
|
'if [ "$1" = "--kill-after=1s" ] && [ "$2" = "1s" ] && [ "$3" = "true" ]; then',
|
|
" exit 0",
|
|
"fi",
|
|
"exit 64",
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
|
|
expect(resolveDockerRunArgs(binDir)).toEqual([
|
|
"timeout",
|
|
"--kill-after=30s",
|
|
"42s",
|
|
"docker",
|
|
"run",
|
|
"--memory",
|
|
"8g",
|
|
"--cpus",
|
|
"16",
|
|
"--pids-limit",
|
|
"2048",
|
|
]);
|
|
});
|
|
|
|
it("caps default CPU limits to the runner capacity", () => {
|
|
const binDir = makeTempBin("openclaw-live-docker-auth-cpus-");
|
|
writeExecutable(
|
|
path.join(binDir, "timeout"),
|
|
[
|
|
"#!/bin/sh",
|
|
'if [ "$1" = "--kill-after=1s" ] && [ "$2" = "1s" ] && [ "$3" = "true" ]; then',
|
|
" exit 0",
|
|
"fi",
|
|
"exit 64",
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
|
|
const result = spawnSync(
|
|
"/bin/bash",
|
|
[
|
|
"-c",
|
|
[
|
|
"source scripts/lib/live-docker-auth.sh",
|
|
"ARGS=()",
|
|
"OPENCLAW_LIVE_DOCKER_AVAILABLE_CPUS=8 openclaw_live_init_docker_run_args ARGS 42s",
|
|
"printf '%s\\n' \"${ARGS[@]}\"",
|
|
].join("\n"),
|
|
],
|
|
{
|
|
cwd: process.cwd(),
|
|
encoding: "utf8",
|
|
env: {
|
|
...process.env,
|
|
PATH: binDir,
|
|
},
|
|
},
|
|
);
|
|
|
|
expect(result.status).toBe(0);
|
|
expect(result.stdout.trimEnd().split("\n")).toEqual([
|
|
"timeout",
|
|
"--kill-after=30s",
|
|
"42s",
|
|
"docker",
|
|
"run",
|
|
"--memory",
|
|
"8g",
|
|
"--cpus",
|
|
"8",
|
|
"--pids-limit",
|
|
"2048",
|
|
]);
|
|
});
|
|
|
|
it("falls back to plain timeout when kill-after is unavailable", () => {
|
|
const binDir = makeTempBin("openclaw-live-docker-auth-plain-");
|
|
writeExecutable(
|
|
path.join(binDir, "timeout"),
|
|
["#!/bin/sh", 'if [ "$1" = "--kill-after=1s" ]; then', " exit 1", "fi", "exit 0", ""].join(
|
|
"\n",
|
|
),
|
|
);
|
|
|
|
expect(resolveDockerRunArgs(binDir)).toEqual([
|
|
"timeout",
|
|
"42s",
|
|
"docker",
|
|
"run",
|
|
"--memory",
|
|
"8g",
|
|
"--cpus",
|
|
"16",
|
|
"--pids-limit",
|
|
"2048",
|
|
]);
|
|
});
|
|
|
|
it("uses gtimeout when timeout is unavailable", () => {
|
|
const binDir = makeTempBin("openclaw-live-docker-auth-gtimeout-");
|
|
writeExecutable(
|
|
path.join(binDir, "gtimeout"),
|
|
[
|
|
"#!/bin/sh",
|
|
'if [ "$1" = "--kill-after=1s" ] && [ "$2" = "1s" ] && [ "$3" = "true" ]; then',
|
|
" exit 0",
|
|
"fi",
|
|
"exit 64",
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
|
|
expect(resolveDockerRunArgs(binDir)).toEqual([
|
|
"gtimeout",
|
|
"--kill-after=30s",
|
|
"42s",
|
|
"docker",
|
|
"run",
|
|
"--memory",
|
|
"8g",
|
|
"--cpus",
|
|
"16",
|
|
"--pids-limit",
|
|
"2048",
|
|
]);
|
|
});
|
|
|
|
it("allows live Docker resource limits to be disabled", () => {
|
|
const binDir = makeTempBin("openclaw-live-docker-auth-no-limits-");
|
|
writeExecutable(
|
|
path.join(binDir, "timeout"),
|
|
[
|
|
"#!/bin/sh",
|
|
'if [ "$1" = "--kill-after=1s" ] && [ "$2" = "1s" ] && [ "$3" = "true" ]; then',
|
|
" exit 0",
|
|
"fi",
|
|
"exit 64",
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
|
|
const result = spawnSync(
|
|
"/bin/bash",
|
|
[
|
|
"-c",
|
|
[
|
|
"source scripts/lib/live-docker-auth.sh",
|
|
"ARGS=()",
|
|
"OPENCLAW_LIVE_DOCKER_DISABLE_RESOURCE_LIMITS=1 openclaw_live_init_docker_run_args ARGS 42s",
|
|
"printf '%s\\n' \"${ARGS[@]}\"",
|
|
].join("\n"),
|
|
],
|
|
{
|
|
cwd: process.cwd(),
|
|
encoding: "utf8",
|
|
env: {
|
|
...process.env,
|
|
PATH: binDir,
|
|
},
|
|
},
|
|
);
|
|
|
|
expect(result.status).toBe(0);
|
|
expect(result.stdout.trimEnd().split("\n")).toEqual([
|
|
"timeout",
|
|
"--kill-after=30s",
|
|
"42s",
|
|
"docker",
|
|
"run",
|
|
]);
|
|
});
|
|
|
|
it("normalizes live Docker pids limits", () => {
|
|
const binDir = makeTempBin("openclaw-live-docker-auth-pids-");
|
|
writeExecutable(
|
|
path.join(binDir, "timeout"),
|
|
[
|
|
"#!/bin/sh",
|
|
'if [ "$1" = "--kill-after=1s" ] && [ "$2" = "1s" ] && [ "$3" = "true" ]; then',
|
|
" exit 0",
|
|
"fi",
|
|
"exit 64",
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
|
|
const result = spawnSync(
|
|
"/bin/bash",
|
|
[
|
|
"-c",
|
|
[
|
|
"source scripts/lib/live-docker-auth.sh",
|
|
"ARGS=()",
|
|
"OPENCLAW_LIVE_DOCKER_PIDS_LIMIT=0008 openclaw_live_init_docker_run_args ARGS 42s",
|
|
"printf '%s\\n' \"${ARGS[@]}\"",
|
|
].join("\n"),
|
|
],
|
|
{
|
|
cwd: process.cwd(),
|
|
encoding: "utf8",
|
|
env: {
|
|
...process.env,
|
|
PATH: binDir,
|
|
},
|
|
},
|
|
);
|
|
|
|
expect(result.status).toBe(0);
|
|
expect(result.stdout.trimEnd().split("\n")).toContain("8");
|
|
});
|
|
|
|
it.each([
|
|
["live", "OPENCLAW_LIVE_DOCKER_PIDS_LIMIT"],
|
|
["shared", "OPENCLAW_DOCKER_E2E_PIDS_LIMIT"],
|
|
])("rejects invalid %s Docker pids limits before live Docker setup", (_label, envName) => {
|
|
const binDir = makeTempBin("openclaw-live-docker-auth-invalid-pids-");
|
|
writeExecutable(
|
|
path.join(binDir, "timeout"),
|
|
[
|
|
"#!/bin/sh",
|
|
'if [ "$1" = "--kill-after=1s" ] && [ "$2" = "1s" ] && [ "$3" = "true" ]; then',
|
|
" exit 0",
|
|
"fi",
|
|
"exit 64",
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
|
|
const result = spawnSync(
|
|
"/bin/bash",
|
|
[
|
|
"-c",
|
|
[
|
|
"source scripts/lib/live-docker-auth.sh",
|
|
"ARGS=()",
|
|
"openclaw_live_init_docker_run_args ARGS 42s",
|
|
].join("\n"),
|
|
],
|
|
{
|
|
cwd: process.cwd(),
|
|
encoding: "utf8",
|
|
env: {
|
|
...process.env,
|
|
OPENCLAW_DOCKER_E2E_PIDS_LIMIT:
|
|
envName === "OPENCLAW_DOCKER_E2E_PIDS_LIMIT" ? "many" : "",
|
|
OPENCLAW_LIVE_DOCKER_PIDS_LIMIT:
|
|
envName === "OPENCLAW_LIVE_DOCKER_PIDS_LIMIT" ? "many" : "",
|
|
PATH: binDir,
|
|
},
|
|
},
|
|
);
|
|
|
|
expect(result.status).toBe(2);
|
|
expect(result.stderr).toContain(`invalid ${envName}: many`);
|
|
expect(result.stdout).toBe("");
|
|
});
|
|
|
|
it("fails fast when no timeout wrapper is available", () => {
|
|
const binDir = makeTempBin("openclaw-live-docker-auth-no-timeout-");
|
|
|
|
const result = runDockerRunArgs(binDir);
|
|
expect(result.status).toBe(127);
|
|
expect(result.stderr).toContain(
|
|
"timeout command not found; cannot bound live Docker run after 42s",
|
|
);
|
|
});
|
|
});
|