fix(deploy): smoke probe survives network failure (capture curl exit) + clearer label + 15s timeout
Browse files- C1 (Critical): Capture curl exit code instead of aborting script under set -e; network failures now
surface as FAIL lines with exit 1, not opaque curl exit codes like 7
- I1 (Important): Rename third probe label from "POST to unknown path is rejected" to
"fastapi :8000 not publicly routed (POST)" for clarity on test intent
- M3 (Minor): Add --max-time 15 to all curl calls to prevent indefinite hangs if HF Tornado
accepts TCP but stalls mid-response
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- scripts/smoke_hf_space.sh +10 -5
scripts/smoke_hf_space.sh
CHANGED
|
@@ -13,12 +13,17 @@ FAIL=0
|
|
| 13 |
|
| 14 |
probe() {
|
| 15 |
local label="$1" url="$2" expect="$3" method="${4:-GET}"
|
| 16 |
-
local actual
|
| 17 |
if [[ "$method" == "POST" ]]; then
|
| 18 |
-
actual="$(curl -sS -o /dev/null -w "%{http_code}"
|
| 19 |
-
-H 'content-type: application/json' -d '{}' "$url")"
|
| 20 |
else
|
| 21 |
-
actual="$(curl -sS -o /dev/null -w "%{http_code}" "$url")"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
fi
|
| 23 |
if [[ "$actual" == "$expect" ]]; then
|
| 24 |
printf " OK %-40s %s\n" "$label" "$actual"
|
|
@@ -31,7 +36,7 @@ probe() {
|
|
| 31 |
echo "Probing $BASE"
|
| 32 |
probe "frontend root" "$BASE/" "200" "GET"
|
| 33 |
probe "streamlit health" "$BASE/_stcore/health" "200" "GET"
|
| 34 |
-
probe "
|
| 35 |
|
| 36 |
echo
|
| 37 |
if [[ "$FAIL" == "0" ]]; then
|
|
|
|
| 13 |
|
| 14 |
probe() {
|
| 15 |
local label="$1" url="$2" expect="$3" method="${4:-GET}"
|
| 16 |
+
local actual curl_exit=0
|
| 17 |
if [[ "$method" == "POST" ]]; then
|
| 18 |
+
actual="$(curl -sS --max-time 15 -o /dev/null -w "%{http_code}" \
|
| 19 |
+
-X POST -H 'content-type: application/json' -d '{}' "$url")" || curl_exit=$?
|
| 20 |
else
|
| 21 |
+
actual="$(curl -sS --max-time 15 -o /dev/null -w "%{http_code}" "$url")" || curl_exit=$?
|
| 22 |
+
fi
|
| 23 |
+
if [[ "$curl_exit" -ne 0 ]]; then
|
| 24 |
+
printf " FAIL %-40s curl error %s\n" "$label" "$curl_exit"
|
| 25 |
+
FAIL=1
|
| 26 |
+
return
|
| 27 |
fi
|
| 28 |
if [[ "$actual" == "$expect" ]]; then
|
| 29 |
printf " OK %-40s %s\n" "$label" "$actual"
|
|
|
|
| 36 |
echo "Probing $BASE"
|
| 37 |
probe "frontend root" "$BASE/" "200" "GET"
|
| 38 |
probe "streamlit health" "$BASE/_stcore/health" "200" "GET"
|
| 39 |
+
probe "fastapi :8000 not publicly routed (POST)" "$BASE/predict/bbb" "403" "POST"
|
| 40 |
|
| 41 |
echo
|
| 42 |
if [[ "$FAIL" == "0" ]]; then
|