Files
storyforge/scripts/smoke_public_storyforge.sh

71 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
BASE_URL="${STORYFORGE_PUBLIC_BASE_URL:-https://storyforge.hyzq.net}"
CURL_MAX_TIME="${STORYFORGE_PUBLIC_CURL_MAX_TIME:-60}"
need_cmd() {
if ! command -v "$1" >/dev/null 2>&1; then
echo "missing required command: $1" >&2
exit 1
fi
}
need_cmd curl
need_cmd python3
need_cmd rg
curl_fetch() {
curl -fsS --max-time "$CURL_MAX_TIME" "$@"
}
tmp_dir="$(mktemp -d)"
trap 'rm -rf "$tmp_dir"' EXIT
health_file="$tmp_dir/health.json"
html_file="$tmp_dir/index.html"
js_file="$tmp_dir/app.js"
openapi_file="$tmp_dir/openapi.json"
echo "[1/4] check public healthz"
curl_fetch "$BASE_URL/healthz" >"$health_file"
python3 - "$health_file" <<'PY'
import json
import pathlib
import sys
payload = json.loads(pathlib.Path(sys.argv[1]).read_text())
status = str(payload.get("status") or "").lower()
if status != "ok":
raise SystemExit(f"unexpected health status: {status!r}")
print("healthz ok")
PY
echo "[2/4] check public index"
curl_fetch "$BASE_URL/" >"$html_file"
rg -q "StoryForge" "$html_file"
echo "index ok"
echo "[3/4] check deployed web bundle"
curl_fetch "$BASE_URL/assets/app.js" >"$js_file"
rg -q "select-platform" "$js_file"
rg -q "trackingCursorMap" "$js_file"
rg -q "renderPlatformSwitchChips" "$js_file"
echo "bundle ok"
echo "[4/4] check public openapi routes"
curl_fetch "$BASE_URL/openapi.json" >"$openapi_file"
for route in \
'"/v2/xiaohongshu/accounts"' \
'"/v2/bilibili/accounts"' \
'"/v2/kuaishou/accounts"' \
'"/v2/wechat_video/accounts"' \
'"/v2/platform-agents"' \
'"/v2/tenant/quota"'
do
rg -q "$route" "$openapi_file"
done
echo "openapi ok"
echo "public smoke passed: $BASE_URL"