fix(ci): E2E health check 增加網路診斷

- 增加 ping VIP 診斷
- 增加備用端點 (direct 120) fallback
- 增加 HTTP 狀態碼和回應內容輸出
- 改善錯誤訊息,方便除錯

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-03-29 20:21:52 +08:00
parent 2e9ccf4a26
commit 0f3339e977

View File

@@ -73,10 +73,32 @@ jobs:
run: |
API_URL="${{ github.event.inputs.api_url || env.DEFAULT_API_URL }}"
echo "🔗 檢查 API 健康狀態..."
if curl -s --connect-timeout 10 "$API_URL/health" > /dev/null; then
echo "✅ API 可用: $API_URL"
echo "📍 Runner: $(hostname)"
echo "🌐 Target: $API_URL"
# 診斷網路連通性
VIP_IP=$(echo "$API_URL" | sed -E 's|https?://([^:]+).*|\1|')
echo "🔍 Ping VIP ($VIP_IP)..."
ping -c 2 "$VIP_IP" || echo "⚠️ Ping failed (may be blocked)"
# 嘗試連線
echo "🔗 Curl health endpoint..."
HTTP_CODE=$(curl -s -o /tmp/health_response.txt -w "%{http_code}" --connect-timeout 15 "$API_URL/health" || echo "000")
if [ "$HTTP_CODE" = "200" ]; then
echo "✅ API 可用: $API_URL (HTTP $HTTP_CODE)"
cat /tmp/health_response.txt
else
echo "❌ API 無法連線: $API_URL"
echo "❌ API 無法連線: $API_URL (HTTP $HTTP_CODE)"
echo "📋 Response:"
cat /tmp/health_response.txt 2>/dev/null || echo "(empty)"
# 嘗試備用端點
FALLBACK_URL="http://192.168.0.120:32334"
echo "🔄 嘗試備用端點: $FALLBACK_URL"
FALLBACK_CODE=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 10 "$FALLBACK_URL/health" || echo "000")
echo " 備用結果: HTTP $FALLBACK_CODE"
exit 1
fi