mirror of
https://github.com/Sea-Haven-Industries/seahaven-ap.git
synced 2026-09-30 06:53:18 +00:00
fix(cd): report the real health status when curl fails
This commit is contained in:
parent
da959dda93
commit
0a16df1cfe
2 changed files with 17 additions and 2 deletions
|
|
@ -19,7 +19,7 @@ assert_exit() {
|
|||
}
|
||||
|
||||
run_with_curl() {
|
||||
local name="$1" expected="$2" curl_body="$3"
|
||||
local name="$1" expected="$2" curl_body="$3" must="${4:-}" forbid="${5:-}"
|
||||
local dir
|
||||
dir="$(mktemp -d)"
|
||||
cat > "${dir}/curl" << CURL
|
||||
|
|
@ -51,6 +51,16 @@ CURL
|
|||
local code=$?
|
||||
set -e
|
||||
assert_exit "${name}" "${expected}" "${code}" "${log}"
|
||||
if [[ -n "${must}" ]] && ! grep -F "${must}" "${log}" >/dev/null; then
|
||||
echo "FAIL: ${name}: log missing ${must}" >&2
|
||||
sed -n '1,80p' "${log}" >&2
|
||||
failures=$((failures + 1))
|
||||
fi
|
||||
if [[ -n "${forbid}" ]] && grep -F "${forbid}" "${log}" >/dev/null; then
|
||||
echo "FAIL: ${name}: log contains ${forbid}" >&2
|
||||
sed -n '1,80p' "${log}" >&2
|
||||
failures=$((failures + 1))
|
||||
fi
|
||||
rm -rf "${dir}"
|
||||
}
|
||||
|
||||
|
|
@ -72,6 +82,11 @@ run_with_curl "health-503" 1 '
|
|||
exit 0
|
||||
'
|
||||
|
||||
run_with_curl "curl-failure" 1 '
|
||||
[[ -n "${write_out}" ]] && printf "000"
|
||||
exit 1
|
||||
' 'http=000 sha=' 'http=000000'
|
||||
|
||||
if [[ "${failures}" -ne 0 ]]; then
|
||||
echo "FAIL: ${failures} verify-api-health cases failed" >&2
|
||||
exit 1
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ attempt=0
|
|||
while [[ "${attempt}" -lt "${BUDGET}" ]]; do
|
||||
attempt=$((attempt + 1))
|
||||
tmp="$(mktemp)"
|
||||
last_code="$(curl -sS --max-time 30 -o "${tmp}" -w '%{http_code}' "${SITE_URL}/api/health" || printf '000')"
|
||||
last_code="$(curl -sS --max-time 30 -o "${tmp}" -w '%{http_code}' "${SITE_URL}/api/health" || true)"
|
||||
last_sha="$(python3 -c 'import json,sys
|
||||
try:
|
||||
print(json.load(open(sys.argv[1], encoding="utf-8")).get("sha") or "")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue