mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 09:30:43 +00:00
refactor: reuse docker gateway e2e helpers
This commit is contained in:
@@ -9,6 +9,17 @@ openclaw_e2e_resolve_entrypoint() {
|
||||
echo "OpenClaw entrypoint not found under dist/" >&2
|
||||
return 1
|
||||
}
|
||||
openclaw_e2e_write_state_env() {
|
||||
local target="${1:-/tmp/openclaw-test-state-env}"
|
||||
{
|
||||
printf 'export HOME=%q\n' "$HOME"
|
||||
printf 'export OPENCLAW_HOME=%q\n' "$OPENCLAW_HOME"
|
||||
printf 'export OPENCLAW_STATE_DIR=%q\n' "$OPENCLAW_STATE_DIR"
|
||||
printf 'export OPENCLAW_CONFIG_PATH=%q\n' "$OPENCLAW_CONFIG_PATH"
|
||||
printf 'export OPENCLAW_AGENT_DIR=%q\n' "${OPENCLAW_AGENT_DIR-}"
|
||||
printf 'export PI_CODING_AGENT_DIR=%q\n' "${PI_CODING_AGENT_DIR-}"
|
||||
} >"$target"
|
||||
}
|
||||
openclaw_e2e_stop_process() {
|
||||
local pid="${1:-}" _
|
||||
[ -n "$pid" ] || return 0
|
||||
@@ -31,6 +42,7 @@ openclaw_e2e_wait_mock_openai() {
|
||||
node -e "$probe" "$port"
|
||||
}
|
||||
openclaw_e2e_start_gateway() { node "$1" gateway --port "$2" --bind loopback --allow-unconfigured >"$3" 2>&1 & printf '%s\n' "$!"; }
|
||||
openclaw_e2e_exec_gateway() { exec node "$1" gateway --port "$2" --bind "${3:-loopback}" --allow-unconfigured >"$4" 2>&1; }
|
||||
openclaw_e2e_wait_gateway_ready() {
|
||||
local pid="$1" log="$2" attempts="${3:-300}" _
|
||||
for _ in $(seq 1 "$attempts"); do
|
||||
@@ -47,6 +59,18 @@ openclaw_e2e_wait_gateway_ready() {
|
||||
tail -n 120 "$log" 2>/dev/null || true
|
||||
return 1
|
||||
}
|
||||
openclaw_e2e_probe_tcp() {
|
||||
node --input-type=module -e '
|
||||
import net from "node:net";
|
||||
const socket = net.createConnection({ host: process.argv[1], port: Number(process.argv[2]) });
|
||||
const timeout = setTimeout(() => { socket.destroy(); process.exit(1); }, Number(process.argv[3] ?? 400));
|
||||
socket.on("connect", () => { clearTimeout(timeout); socket.end(); process.exit(0); });
|
||||
socket.on("error", () => { clearTimeout(timeout); process.exit(1); });
|
||||
' "$1" "$2" "${3:-400}"
|
||||
}
|
||||
openclaw_e2e_probe_http_status() {
|
||||
node -e 'fetch(process.argv[1]).then(r=>process.exit(r.status===Number(process.argv[2])?0:1)).catch(()=>process.exit(1))' "$1" "${2:-200}"
|
||||
}
|
||||
openclaw_e2e_dump_logs() {
|
||||
local path
|
||||
for path in "$@"; do
|
||||
|
||||
Reference in New Issue
Block a user