Files
MoneyFlix/tools/proxmox/smoke_moneyflix_prod.sh
Xika e570468610 infra(BIT-24694): add MoneyFlix prod LXC install and smoke scripts
- tools/proxmox/install_moneyflix_stack.sh: guest-side stack installer
  (MariaDB, PHP 8.1, nginx, Node.js 20, systemd unit moneyflix-redirector)
  Reads /etc/moneyflix/moneyflix.env; rejects placeholder credentials.
- tools/proxmox/smoke_moneyflix_prod.sh: post-deploy smoke from Paperclip host
  Checks redirector /health, /status, /test-db and CRM /system/status.

Paperclip-Issue: BIT-24694
Paperclip-Agent: devops
2026-06-08 13:14:25 +00:00

104 lines
3.3 KiB
Bash

#!/usr/bin/env bash
# Post-deploy smoke test for MoneyFlix production LXC (BIT-24694).
# Run from the Paperclip host (10.10.50.17) or any host on VLAN 1050.
# Usage: CT_IP=10.10.50.37 bash tools/proxmox/smoke_moneyflix_prod.sh
set -euo pipefail
CT_IP="${CT_IP:-10.10.50.37}"
CRM_PORT="${CRM_PORT:-8080}"
REDIRECTOR_PORT="${REDIRECTOR_PORT:-80}"
TIMEOUT="${TIMEOUT:-10}"
PASS=0
FAIL=0
RESULTS=()
check() {
local name="$1"
local cmd="$2"
local expect="${3:-200}"
local out
out="$(eval "$cmd" 2>/dev/null || true)"
local code="${out%%$'\n'*}" # first line = HTTP code when using -w '%{http_code}'
if echo "$out" | grep -qE "$expect"; then
PASS=$((PASS + 1))
RESULTS+=("PASS $name")
printf "PASS %s\n" "$name"
else
FAIL=$((FAIL + 1))
RESULTS+=("FAIL $name")
printf "FAIL %s\n" "$name"
printf " expected: %s\n" "$expect"
printf " got: %s\n" "$(echo "$out" | head -c 300)"
fi
}
echo "=== MoneyFlix prod smoke (BIT-24694) ==="
echo "Target CT: $CT_IP"
echo "CRM port: $CRM_PORT | Redirector port: $REDIRECTOR_PORT"
echo ""
# 1. Redirector health
check "redirector /health" \
"curl -sf --max-time $TIMEOUT http://${CT_IP}:${REDIRECTOR_PORT}/health" \
'"status"[[:space:]]*:[[:space:]]*"healthy"'
# 2. Redirector status
check "redirector /status" \
"curl -sf --max-time $TIMEOUT http://${CT_IP}:${REDIRECTOR_PORT}/status" \
'"status"[[:space:]]*:[[:space:]]*"running"'
# 3. Redirector DB connection
check "redirector /test-db" \
"curl -sf --max-time $TIMEOUT http://${CT_IP}:${REDIRECTOR_PORT}/test-db" \
'"status"[[:space:]]*:[[:space:]]*"ok"'
# 4. CRM system status
check "CRM /system/status" \
"curl -sf --max-time $TIMEOUT http://${CT_IP}:${CRM_PORT}/system/status" \
'"status"[[:space:]]*:[[:space:]]*"OK"'
# 5. nginx responding on :80 (redirector proxy)
HTTP_CODE="$(curl -s -o /dev/null -w '%{http_code}' --max-time "$TIMEOUT" \
"http://${CT_IP}:${REDIRECTOR_PORT}/" 2>/dev/null || echo 000)"
if [[ "$HTTP_CODE" =~ ^(200|301|302|404)$ ]]; then
PASS=$((PASS + 1))
RESULTS+=("PASS nginx :${REDIRECTOR_PORT} responding (HTTP $HTTP_CODE)")
printf "PASS nginx :%s responding (HTTP %s)\n" "$REDIRECTOR_PORT" "$HTTP_CODE"
else
FAIL=$((FAIL + 1))
RESULTS+=("FAIL nginx :${REDIRECTOR_PORT} (HTTP $HTTP_CODE)")
printf "FAIL nginx :%s (HTTP %s)\n" "$REDIRECTOR_PORT" "$HTTP_CODE"
fi
# 6. MariaDB reachable (via redirector /test-db already covers this, extra check via nc)
if command -v nc &>/dev/null; then
if nc -z -w3 "$CT_IP" 3306 2>/dev/null; then
PASS=$((PASS + 1))
RESULTS+=("PASS MariaDB :3306 reachable (LAN)")
echo "PASS MariaDB :3306 reachable (LAN)"
else
# Not necessarily an error — MariaDB may be firewalled externally
RESULTS+=("INFO MariaDB :3306 not reachable from this host (firewall expected)")
echo "INFO MariaDB :3306 not reachable from this host (firewall expected)"
fi
fi
echo ""
echo "=== Summary: $PASS passed, $FAIL failed ==="
printf '%s\n' "${RESULTS[@]}"
if [[ "$FAIL" -gt 0 ]]; then
echo ""
echo "Troubleshoot:"
echo " ssh root@$CT_IP 'systemctl status moneyflix-redirector nginx php8.1-fpm mariadb'"
echo " ssh root@$CT_IP 'journalctl -u moneyflix-redirector -n 50'"
exit 1
fi
echo ""
echo "All smoke checks passed."
echo "Next: configure NPM CT 102 proxy hosts — see docs/runbooks/MONEYFLIX_LXC_DEPLOY_BIT24694.md § NPM"