Allow protected scan terminal deploy smoke

This commit is contained in:
2569718930@qq.com
2026-06-14 06:49:28 +08:00
parent 56f31c0aa2
commit 2781a97d9d
2 changed files with 18 additions and 9 deletions
+14 -6
View File
@@ -209,25 +209,33 @@ warm_public_route() {
return 0
}
wait_for_scan_terminal_ready() {
wait_for_scan_terminal_snapshot() {
local name="$1"
local url="$2"
local timeout="${3:-35}"
local attempts="${4:-8}"
local delay="${5:-5}"
local output=""
local body=""
local compact=""
local http_status=""
local status=""
for i in $(seq 1 "$attempts"); do
if output=$(curl -fsS --max-time "$timeout" "$url" 2>&1); then
compact="$(printf '%s' "$output" | tr -d '\n\r\t ')"
if output=$(curl -sS -w "\nhttp=%{http_code}" --max-time "$timeout" "$url" 2>&1); then
http_status="$(printf '%s\n' "$output" | sed -n 's/^http=//p' | tail -n 1)"
body="$(printf '%s\n' "$output" | sed '$d')"
if [ "$http_status" = "401" ]; then
echo "$name protected after attempt $i/$attempts (http=401)"
return 0
fi
compact="$(printf '%s' "$body" | tr -d '\n\r\t ')"
if printf '%s' "$compact" | grep -q '"status":"ready"'; then
echo "$name ready after attempt $i/$attempts"
return 0
fi
status="$(printf '%s' "$compact" | sed -n 's/.*"status":"\([^"]*\)".*/\1/p' | head -n 1)"
echo " $name not ready attempt $i/$attempts status=${status:-unknown}"
echo " $name not ready attempt $i/$attempts http=${http_status:-unknown} status=${status:-unknown}"
else
echo " $name request failed attempt $i/$attempts ($output)"
fi
@@ -236,7 +244,7 @@ wait_for_scan_terminal_ready() {
fi
done
echo "$name did not return status=ready"
echo "$name did not return status=ready or http=401"
return 1
}
@@ -320,7 +328,7 @@ compose_up_retry "frontend" -d --no-deps polyweather_frontend
echo "Waiting for frontend..."
wait_for_local_service "frontend root" "http://127.0.0.1:3001/" 5 40 2 || FAILED_FRONTEND=1
wait_for_local_service "frontend terminal" "http://127.0.0.1:3001/terminal" 10 20 2 || FAILED_FRONTEND=1
wait_for_scan_terminal_ready "scan terminal snapshot" "http://127.0.0.1:3001/api/scan/terminal" 35 8 5 || FAILED_FRONTEND=1
wait_for_scan_terminal_snapshot "scan terminal snapshot" "http://127.0.0.1:3001/api/scan/terminal" 35 8 5 || FAILED_FRONTEND=1
FAILED_FRONTEND="${FAILED_FRONTEND:-0}"
if [ "$FAILED_FRONTEND" = "1" ]; then
echo "❌ Frontend did not become healthy"