fix(e2e): bound cleanup smoke logs

This commit is contained in:
Vincent Koc
2026-06-07 11:50:33 +02:00
parent cdbf6d95ac
commit 901f963f62
2 changed files with 37 additions and 3 deletions
+28 -3
View File
@@ -6,9 +6,34 @@ cd /repo
export OPENCLAW_STATE_DIR="/tmp/openclaw-test"
export OPENCLAW_CONFIG_PATH="${OPENCLAW_STATE_DIR}/openclaw.json"
print_log_tail() {
local log_file="$1"
local max_bytes="${OPENCLAW_CLEANUP_SMOKE_LOG_PRINT_BYTES:-65536}"
if ! [[ "$max_bytes" =~ ^[0-9]+$ ]] || [ "$max_bytes" -lt 1 ]; then
max_bytes="65536"
else
max_bytes="$((10#$max_bytes))"
fi
if [ ! -f "$log_file" ]; then
return 0
fi
local log_bytes
log_bytes="$(wc -c <"$log_file" 2>/dev/null || echo 0)"
log_bytes="${log_bytes//[[:space:]]/}"
if ! [[ "$log_bytes" =~ ^[0-9]+$ ]]; then
log_bytes="0"
fi
if [ "$log_bytes" -le "$max_bytes" ]; then
cat "$log_file"
return 0
fi
echo "--- ${log_file} truncated: showing last ${max_bytes} of ${log_bytes} bytes ---"
tail -c "$max_bytes" "$log_file"
}
echo "==> Build"
if ! pnpm build >/tmp/openclaw-cleanup-build.log 2>&1; then
cat /tmp/openclaw-cleanup-build.log
print_log_tail /tmp/openclaw-cleanup-build.log
exit 1
fi
@@ -21,7 +46,7 @@ echo 'session' >"${OPENCLAW_STATE_DIR}/agents/main/sessions/sessions.json"
echo "==> Reset (config+creds+sessions)"
if ! pnpm openclaw reset --scope config+creds+sessions --yes --non-interactive >/tmp/openclaw-cleanup-reset.log 2>&1; then
cat /tmp/openclaw-cleanup-reset.log
print_log_tail /tmp/openclaw-cleanup-reset.log
exit 1
fi
@@ -35,7 +60,7 @@ echo '{}' >"${OPENCLAW_CONFIG_PATH}"
echo "==> Uninstall (state only)"
if ! pnpm openclaw uninstall --state --yes --non-interactive >/tmp/openclaw-cleanup-uninstall.log 2>&1; then
cat /tmp/openclaw-cleanup-uninstall.log
print_log_tail /tmp/openclaw-cleanup-uninstall.log
exit 1
fi
+9
View File
@@ -58,6 +58,7 @@ const BUNDLED_PLUGIN_INSTALL_UNINSTALL_PROBE_PATH =
const BUNDLED_PLUGIN_INSTALL_UNINSTALL_RUNTIME_SMOKE_PATH =
"scripts/e2e/lib/bundled-plugin-install-uninstall/runtime-smoke.mjs";
const CLEANUP_SMOKE_DOCKERFILE_PATH = "scripts/docker/cleanup-smoke/Dockerfile";
const CLEANUP_SMOKE_RUN_PATH = "scripts/docker/cleanup-smoke/run.sh";
const PLUGINS_DOCKER_E2E_PATH = "scripts/e2e/plugins-docker.sh";
const PLUGINS_DOCKER_SWEEP_PATH = "scripts/e2e/lib/plugins/sweep.sh";
const PLUGINS_DOCKER_MARKETPLACE_PATH = "scripts/e2e/lib/plugins/marketplace.sh";
@@ -192,6 +193,14 @@ describe("docker build helper", () => {
expect(installE2eSmoke).not.toContain("docker run --rm \\");
});
it("bounds cleanup-smoke failure log output", () => {
const cleanupRun = readFileSync(CLEANUP_SMOKE_RUN_PATH, "utf8");
expect(cleanupRun).toContain("OPENCLAW_CLEANUP_SMOKE_LOG_PRINT_BYTES");
expect(cleanupRun.match(/print_log_tail \/tmp\/openclaw-cleanup-/g)).toHaveLength(3);
expect(cleanupRun).not.toContain("cat /tmp/openclaw-cleanup-");
});
it("prints Docker MCP client logs through the bounded helper", () => {
for (const scriptPath of BOUNDED_CLIENT_LOG_DOCKER_E2E_SCRIPTS) {
const script = readFileSync(scriptPath, "utf8");