koopa-admin-log/scripts/taler-shared/goa-regio-ng/goa-e2e-recreate-restore.sh

53 lines
2.1 KiB
Bash
Executable file

#!/bin/bash
set -euo pipefail
CTR=goa-regio-ng
LOG=/tmp/goa-e2e-recreate-restore.log
exec > >(tee -a "$LOG") 2>&1
echo "=== START $(date -u +%Y-%m-%dT%H:%M:%SZ) ==="
echo "=== 1) RECREATE (empty CTR) ==="
bash /tmp/goa-901x-recreate.sh
echo "RECREATE_RC=$?"
echo "=== wait ports / systemd settle ==="
for i in $(seq 1 60); do
if podman exec "$CTR" systemctl is-system-running >/dev/null 2>&1 \
|| podman exec "$CTR" systemctl is-system-running 2>&1 | grep -qE 'running|degraded'; then
echo "SYSTEMD_OK after ${i}s"
break
fi
sleep 5
done
podman ps --filter name="$CTR" --format '{{.Names}} {{.Status}}'
ss -lntp 2>/dev/null | grep -E '901[0-5]|9180|9322' || true
echo "=== pre-restore: expect empty/minimal DBs ==="
podman exec "$CTR" bash -lc 'sudo -u postgres psql -Atc "SELECT datname FROM pg_database WHERE datname ~ '"'"'exchange|libeufin|merchant'"'"' ORDER BY 1;"' || true
echo "=== 2) RESTORE from bak via script ==="
bash /tmp/goa-vanilla-restore-do.sh
echo "RESTORE_RC=$?"
echo "=== 3) post-restore smoke inside CTR ==="
podman exec "$CTR" bash -lc '
set +e
echo MASTER_SHA=$(sha256sum /var/lib/taler-exchange/offline/master.priv 2>/dev/null | awk "{print \$1}")
echo EXPECT=6a1cececf164063ecd48172c21d56061ce7881fbd7a88d4ffd25504552508706
for u in taler-exchange-httpd taler-merchant-httpd libeufin-bank libeufin-nexus; do
echo -n "$u: "; systemctl is-active $u 2>/dev/null || systemctl is-active ${u}.service 2>/dev/null
done
sudo -u postgres psql -Atc "SELECT datname FROM pg_database WHERE datname ~ '"'"'exchange|libeufin|merchant'"'"' ORDER BY 1;"
'
echo "=== 4) host probes 9010-9015 ==="
for p in 9010 9011 9012 9013 9014 9015; do
code=$(curl -sS -o /dev/null -w '%{http_code}' --connect-timeout 3 "http://127.0.0.1:${p}/" || echo ERR)
echo "PORT_${p}=${code}"
done
echo "=== 5) leftover hacktivism / failed units ==="
systemctl list-units --all --no-pager 'container-taler-hacktivism*' 2>/dev/null || true
systemctl list-units --failed --no-pager 2>/dev/null | head -40 || true
podman ps -a --format '{{.Names}} {{.Status}}' | grep -iE 'hacktivism|goa|taler' || true
echo "=== END $(date -u +%Y-%m-%dT%H:%M:%SZ) ==="