fix: smoke-test henter fersk token per forsøk, robustere health-poll
This commit is contained in:
parent
2057152468
commit
733f26b971
|
|
@ -68,14 +68,19 @@ steps:
|
|||
echo "=== Smoke Test ==="
|
||||
BASE_URL="https://${_CLOUD_RUN_URL}"
|
||||
|
||||
# Vent på at Cloud Run-instansen er klar (cold start kan ta opptil 90s)
|
||||
# Henter fersk token per forsøk siden token kan utløpe under lang cold start
|
||||
echo "Venter på /health ..."
|
||||
STATUS="000"
|
||||
for i in $$(seq 1 18); do
|
||||
TOKEN=$$(gcloud auth print-identity-token \
|
||||
--impersonate-service-account=${_AGENT_SA} \
|
||||
--audiences="$$BASE_URL") \
|
||||
|| { echo "❌ Kunne ikke hente identity token"; exit 1; }
|
||||
|
||||
# Vent på at Cloud Run-instansen er klar (cold start kan ta opptil 60s)
|
||||
echo "Venter på /health ..."
|
||||
for i in $$(seq 1 12); do
|
||||
--audiences="$$BASE_URL" 2>/dev/null)
|
||||
if [ -z "$$TOKEN" ]; then
|
||||
echo " /health forsøk $$i: kunne ikke hente token, venter..."
|
||||
sleep 10
|
||||
continue
|
||||
fi
|
||||
STATUS=$$(curl -s -o /dev/null -w "%{http_code}" \
|
||||
-H "Authorization: Bearer $$TOKEN" \
|
||||
"$$BASE_URL/health")
|
||||
|
|
@ -85,11 +90,14 @@ steps:
|
|||
done
|
||||
|
||||
if [ "$$STATUS" != "200" ]; then
|
||||
echo "❌ /health svarte ikke 200 etter 120s (siste: $$STATUS)"
|
||||
echo "❌ /health svarte ikke 200 etter 180s (siste: $$STATUS)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Kjør /run
|
||||
# Kjør /run med fersk token
|
||||
TOKEN=$$(gcloud auth print-identity-token \
|
||||
--impersonate-service-account=${_AGENT_SA} \
|
||||
--audiences="$$BASE_URL")
|
||||
RESPONSE=$$(curl -s -w "\nHTTP_STATUS:%{http_code}" \
|
||||
-H "Authorization: Bearer $$TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user