fix: smoke-test med retry, verbose curl og health-check først
This commit is contained in:
parent
492503f0cf
commit
30a418c583
|
|
@ -66,19 +66,46 @@ steps:
|
||||||
- '-c'
|
- '-c'
|
||||||
- |
|
- |
|
||||||
echo "=== Smoke Test ==="
|
echo "=== Smoke Test ==="
|
||||||
|
BASE_URL="https://${_CLOUD_RUN_URL}"
|
||||||
|
|
||||||
TOKEN=$$(gcloud auth print-identity-token \
|
TOKEN=$$(gcloud auth print-identity-token \
|
||||||
--impersonate-service-account=${_AGENT_SA} \
|
--impersonate-service-account=${_AGENT_SA} \
|
||||||
--audiences="https://${_CLOUD_RUN_URL}") \
|
--audiences="$$BASE_URL") \
|
||||||
|| { echo "❌ Kunne ikke hente identity token"; exit 1; }
|
|| { echo "❌ Kunne ikke hente identity token"; exit 1; }
|
||||||
|
|
||||||
RESPONSE=$$(curl -sf \
|
# 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
|
||||||
|
STATUS=$$(curl -s -o /dev/null -w "%{http_code}" \
|
||||||
|
-H "Authorization: Bearer $$TOKEN" \
|
||||||
|
"$$BASE_URL/health")
|
||||||
|
echo " /health forsøk $$i: HTTP $$STATUS"
|
||||||
|
[ "$$STATUS" = "200" ] && break
|
||||||
|
sleep 10
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$$STATUS" != "200" ]; then
|
||||||
|
echo "❌ /health svarte ikke 200 etter 120s (siste: $$STATUS)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Kjør /run
|
||||||
|
RESPONSE=$$(curl -s -w "\nHTTP_STATUS:%{http_code}" \
|
||||||
-H "Authorization: Bearer $$TOKEN" \
|
-H "Authorization: Bearer $$TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{"user_id": "ci", "session_id": "smoke-$BUILD_ID", "message": "ping"}' \
|
-d '{"user_id": "ci", "session_id": "smoke-$BUILD_ID", "message": "ping"}' \
|
||||||
"https://${_CLOUD_RUN_URL}/run") \
|
"$$BASE_URL/run")
|
||||||
|| { echo "❌ Smoke test feilet — /run svarte ikke"; exit 1; }
|
HTTP_STATUS=$$(echo "$$RESPONSE" | grep "HTTP_STATUS:" | cut -d: -f2)
|
||||||
|
BODY=$$(echo "$$RESPONSE" | grep -v "HTTP_STATUS:")
|
||||||
|
|
||||||
echo "✅ Smoke test OK: $$RESPONSE"
|
echo " /run HTTP $$HTTP_STATUS"
|
||||||
|
if [ "$$HTTP_STATUS" != "200" ]; then
|
||||||
|
echo "❌ Smoke test feilet — /run svarte HTTP $$HTTP_STATUS"
|
||||||
|
echo "Body: $$BODY"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "✅ Smoke test OK: $$BODY"
|
||||||
echo "=== Smoke Test ferdig ==="
|
echo "=== Smoke Test ferdig ==="
|
||||||
|
|
||||||
# Steg 6: Deploy-notifikasjon til webhook/chat-app
|
# Steg 6: Deploy-notifikasjon til webhook/chat-app
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user