Files
news-platform/deploy/scripts/smoke-newsproject.sh
T
Artur Moreira 7095765669 feat(deploy): LXC bootstrap, smoke script, /health in nginx, deployment doc (BIT-426)
- Add deploy/lxc/setup.sh for Ubuntu 24 CT (nginx, redis, docker, node 22, pm2)
- Add deploy/scripts/smoke-newsproject.sh for /, /health, wp-json checks
- Proxy GET /health to Fastify in newsproject.bitreport.pt nginx config
- Update docs/deployment.md: remove stub, NPM hostname, bootstrap order, canonical nginx path

Made-with: Cursor
2026-03-24 02:03:40 +00:00

47 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Smoke tests for newsproject.bitreport.pt (or local Nginx on the CT).
# Usage:
# BASE_URL=https://newsproject.bitreport.pt ./deploy/scripts/smoke-newsproject.sh
# BASE_URL=http://127.0.0.1 ./deploy/scripts/smoke-newsproject.sh # on the LXC
set -euo pipefail
BASE_URL="${BASE_URL:-https://newsproject.bitreport.pt}"
BASE_URL="${BASE_URL%/}"
fail() { echo "SMOKE FAIL: $*" >&2; exit 1; }
ok() { echo "OK: $*"; }
code_for() {
local _url="$1"
curl -fsS -o /dev/null -w '%{http_code}' --max-time 25 "$_url"
}
log_json() {
curl -fsS --max-time 15 "$1" | head -c 400
echo ""
}
_c="$(code_for "$BASE_URL/")"
if [[ "$_c" != "200" ]]; then
fail "GET $BASE_URL/ expected HTTP 200, got $_c (sports homepage SSR)"
fi
ok "GET / → $_c"
_c="$(code_for "$BASE_URL/health")"
if [[ "$_c" != "200" ]]; then
fail "GET $BASE_URL/health expected HTTP 200, got $_c (bridge health via Nginx)"
fi
_body="$(log_json "$BASE_URL/health")"
if ! echo "$_body" | grep -q '"status"'; then
fail "GET /health body missing JSON status field"
fi
ok "GET /health → $_c (bridge JSON)"
_c="$(code_for "$BASE_URL/wp-json/wp/v2/")"
if [[ "$_c" != "200" ]]; then
fail "GET $BASE_URL/wp-json/wp/v2/ expected HTTP 200, got $_c (WordPress REST behind proxy)"
fi
ok "GET /wp-json/wp/v2/ → $_c"
echo "All smokes passed for BASE_URL=$BASE_URL"