mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-28 05:46:17 +00:00
fix(docker): require bounded e2e docker commands
This commit is contained in:
@@ -3,18 +3,29 @@
|
||||
# Shared helpers for Docker E2E scripts that keep a named container running
|
||||
# while polling readiness from the host.
|
||||
|
||||
docker_e2e_timeout_bin() {
|
||||
if command -v timeout >/dev/null 2>&1; then
|
||||
printf '%s\n' timeout
|
||||
elif command -v gtimeout >/dev/null 2>&1; then
|
||||
printf '%s\n' gtimeout
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
docker_e2e_timeout_cmd() {
|
||||
local timeout_value="$1"
|
||||
shift
|
||||
if command -v timeout >/dev/null 2>&1; then
|
||||
if timeout --kill-after=1s 1s true >/dev/null 2>&1; then
|
||||
timeout --kill-after=30s "$timeout_value" "$@"
|
||||
else
|
||||
timeout "$timeout_value" "$@"
|
||||
fi
|
||||
return
|
||||
local timeout_bin
|
||||
if ! timeout_bin="$(docker_e2e_timeout_bin)"; then
|
||||
echo "timeout command not found; cannot bound Docker command after ${timeout_value}" >&2
|
||||
return 127
|
||||
fi
|
||||
if "$timeout_bin" --kill-after=1s 1s true >/dev/null 2>&1; then
|
||||
"$timeout_bin" --kill-after=30s "$timeout_value" "$@"
|
||||
else
|
||||
"$timeout_bin" "$timeout_value" "$@"
|
||||
fi
|
||||
"$@"
|
||||
}
|
||||
|
||||
docker_e2e_docker_cmd() {
|
||||
|
||||
@@ -20,15 +20,22 @@ if ! declare -F docker_e2e_docker_run_cmd >/dev/null 2>&1; then
|
||||
return
|
||||
fi
|
||||
local timeout_value="${DOCKER_COMMAND_TIMEOUT:-${OPENCLAW_DOCKER_E2E_RUN_TIMEOUT:-3600s}}"
|
||||
local timeout_bin=""
|
||||
if command -v timeout >/dev/null 2>&1; then
|
||||
if timeout --kill-after=1s 1s true >/dev/null 2>&1; then
|
||||
timeout --kill-after=30s "$timeout_value" docker "$@"
|
||||
timeout_bin="timeout"
|
||||
elif command -v gtimeout >/dev/null 2>&1; then
|
||||
timeout_bin="gtimeout"
|
||||
fi
|
||||
if [ -n "$timeout_bin" ]; then
|
||||
if "$timeout_bin" --kill-after=1s 1s true >/dev/null 2>&1; then
|
||||
"$timeout_bin" --kill-after=30s "$timeout_value" docker "$@"
|
||||
else
|
||||
timeout "$timeout_value" docker "$@"
|
||||
"$timeout_bin" "$timeout_value" docker "$@"
|
||||
fi
|
||||
return
|
||||
fi
|
||||
docker "$@"
|
||||
echo "timeout command not found; cannot bound Docker run after ${timeout_value}" >&2
|
||||
return 127
|
||||
}
|
||||
fi
|
||||
|
||||
|
||||
@@ -360,6 +360,8 @@ const TOOLING_SOURCE_TEST_TARGETS = new Map([
|
||||
"scripts/deadcode-unused-files.allowlist.mjs",
|
||||
["test/scripts/check-deadcode-unused-files.test.ts"],
|
||||
],
|
||||
["scripts/lib/docker-e2e-container.sh", ["test/scripts/docker-build-helper.test.ts"]],
|
||||
["scripts/lib/docker-e2e-package.sh", ["test/scripts/docker-build-helper.test.ts"]],
|
||||
["scripts/lib/live-docker-stage.sh", ["test/scripts/live-docker-stage.test.ts"]],
|
||||
["scripts/lib/openclaw-test-state.mjs", ["test/scripts/openclaw-test-state.test.ts"]],
|
||||
["scripts/lib/vitest-local-scheduling.mjs", ["test/scripts/vitest-local-scheduling.test.ts"]],
|
||||
@@ -420,6 +422,7 @@ const TOOLING_TEST_TARGETS = new Map([
|
||||
["test/scripts/check-deadcode-unused-files.test.ts"],
|
||||
],
|
||||
["test/scripts/ci-docker-pull-retry.test.ts", ["test/scripts/ci-docker-pull-retry.test.ts"]],
|
||||
["test/scripts/docker-build-helper.test.ts", ["test/scripts/docker-build-helper.test.ts"]],
|
||||
["test/scripts/live-docker-stage.test.ts", ["test/scripts/live-docker-stage.test.ts"]],
|
||||
["test/scripts/openclaw-test-state.test.ts", ["test/scripts/openclaw-test-state.test.ts"]],
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user