Files
Stefan-Sanger b87e6b790d feat: run-all-tests.sh auto-starts PG tunnel and telnet port-forward
Check if the SSH tunnel to PostgreSQL (port 14322) and the kubectl
port-forward for telnet (port 5582) are active before running the
testsuite. Start them automatically if missing. Clean up the
kubectl port-forward on exit if we started it.

Part-of: <http://gitlab.vnc.biz/uxf/vnctalk-prosody/-/merge_requests/3>
2026-07-15 17:58:02 +02:00

93 lines
3.5 KiB
Bash
Executable File

#!/bin/bash
#
# Run the full testsuite against an external (non-compose) Prosody deployment
# in a single pytest invocation (unified summary).
#
# For per-file selective runs, use run-tests.sh instead.
#
# Tests that need compose-specific infrastructure (docker exec, MOCK_URL,
# low smacks_hibernation_time) will skip automatically.
#
# Prerequisites:
# 1. SSH tunnel to PostgreSQL:
# ssh -p 60024 developer@148.251.101.234 -f -N -M -S /tmp/vncddb.sock -L 14322:127.0.0.1:5432
# 2. kubectl port-forward for telnet:
# kubectl port-forward services/telnet 5582:5582 -n prosody
#
set -euo pipefail
# ---------------------------------------------------------------------------
# 0. Verify prerequisites: SSH tunnel (PG) and kubectl port-forward (telnet)
# ---------------------------------------------------------------------------
SSH_SOCK=/tmp/vncddb.sock
PG_PORT=14322
TELNET_PORT=5582
check_pg_tunnel() {
if ! ss -tlnp 2>/dev/null | grep -q ":${PG_PORT} "; then
echo ">>> PostgreSQL tunnel not active — starting SSH tunnel"
ssh -p 60024 developer@148.251.101.234 -f -N -M -S "$SSH_SOCK" \
-L ${PG_PORT}:127.0.0.1:5432
sleep 1
if ! ss -tlnp 2>/dev/null | grep -q ":${PG_PORT} "; then
echo "ERROR: SSH tunnel to PostgreSQL failed to start" >&2
exit 1
fi
fi
echo ">>> PostgreSQL tunnel OK (port ${PG_PORT})"
}
check_telnet_pf() {
if ! ss -tlnp 2>/dev/null | grep -q ":${TELNET_PORT} "; then
echo ">>> Telnet port-forward not active — starting kubectl port-forward"
kubectl port-forward services/telnet ${TELNET_PORT}:5582 -n prosody &
KUBECTL_PF_PID=$!
sleep 2
if ! ss -tlnp 2>/dev/null | grep -q ":${TELNET_PORT} "; then
echo "ERROR: kubectl port-forward for telnet failed to start" >&2
exit 1
fi
fi
echo ">>> Telnet port-forward OK (port ${TELNET_PORT})"
}
check_pg_tunnel
check_telnet_pf
# ---------------------------------------------------------------------------
# 1. Test env vars
# ---------------------------------------------------------------------------
export XMPP_HOST=xmpp.microlab.zimbra-vnc.de
export XMPP_PORT=30522
export XMPP_JID=lisa.porter@microlab.zimbra-vnc.de
export XMPP_PASSWORD=q3tx65test
export XMPP_JID2=richard.watson@microlab.zimbra-vnc.de
export XMPP_PASSWORD2=q3tx65test
export XMPP_DOMAIN=microlab.zimbra-vnc.de
export BOSH_URL=https://xmpp.microlab.zimbra-vnc.de/http-bind
export WS_URL=wss://xmpp.microlab.zimbra-vnc.de/xmpp-websocket
export REST_URL=https://xmpprest.microlab.zimbra-vnc.de/rest
export MUC_DOMAIN=conference.microlab.zimbra-vnc.de
export ADMIN_TELNET_HOST=127.0.0.1
export ADMIN_TELNET_PORT=5582
export REST_USER=vnctalk
export REST_PASSWORD=ohtai2Eicai4aiting7bec2am6Aih
export PG_HOST=localhost
export PG_PORT=14322
export PG_DB=prosody
export PG_USER=prosody
export PG_PASSWORD=eS5Gi7ahzo3chaiXiel0ief
# ---------------------------------------------------------------------------
# 2. Run the testsuite
# ---------------------------------------------------------------------------
pytest tests/ -v -c tests/pytest.ini
# ---------------------------------------------------------------------------
# 3. Cleanup kubectl port-forward if we started it
# ---------------------------------------------------------------------------
if [[ -n "${KUBECTL_PF_PID:-}" ]]; then
echo ">>> stopping kubectl port-forward (PID ${KUBECTL_PF_PID})"
kill "$KUBECTL_PF_PID" 2>/dev/null || true
fi