Files
wx-win-agent/scripts/remote-control-smoke.sh
T
rogee 0d29b828bb
Build web service image / build (push) Successful in 48s
feat: harden control-plane deployment
2026-09-12 11:09:42 +08:00

45 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
port=${WXAGENT_SMOKE_PORT:-18090}
data_file=$(mktemp)
log_file=$(mktemp)
binary="${data_file}.control-plane"
cleanup() {
if [[ -n "${control_pid:-}" ]]; then
kill "$control_pid" 2>/dev/null || true
wait "$control_pid" 2>/dev/null || true
fi
rm -f "$data_file" "$log_file" "$binary"
}
trap cleanup EXIT
(
cd "$root/control-plane"
npm --prefix web ci --no-audit --no-fund >/dev/null
npm --prefix web run build >/dev/null
go build -o "$binary" ./cmd/wxagent-control-plane
WXAGENT_CONTROL_PLANE_ADDR="127.0.0.1:${port}" \
WXAGENT_CONTROL_PLANE_DATA="$data_file" \
WXAGENT_NODE_ID="smoke-node" \
WXAGENT_NODE_TOKEN="smoke-node-token" \
WXAGENT_WEB_USER="admin" \
WXAGENT_WEB_PASSWORD="smoke-web-password" \
"$binary"
) >"$log_file" 2>&1 &
control_pid=$!
for _ in $(seq 1 600); do
if curl -fsS "http://127.0.0.1:${port}/healthz" >/dev/null 2>&1; then break; fi
sleep 0.1
done
curl -fsS "http://127.0.0.1:${port}/healthz" >/dev/null
dotnet run --project "$root/tests/node-agent/WxAgent.Remote.Integration/WxAgent.Remote.Integration.csproj" --no-restore -- \
--base-url "http://127.0.0.1:${port}" \
--node-id smoke-node \
--node-token smoke-node-token \
--web-user admin \
--web-password smoke-web-password