Files
jcoffey-dev b34fce62de check-test: the pre-flight check names what's broken (K-C5)
Runs pods shaped like the chart's server pod with one part of the data
layer broken on purpose: wrong PostgreSQL, S3 or NATS credentials, and NATS
or S3 refusing the namespace. Each must stop in its init container with the
right exit code and the part named in its termination message.

frontends-test: PORTS picks the local ports, and a port something else
already listens on stops the test: before, the port-forward failed quietly
and the test talked to whatever was there.
2026-11-18 22:09:28 -07:00

65 lines
2.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# The chart's webmail and console (K-C3) on the lab's seeded install:
# installs them (values-frontends.yaml), then
#
# - signs in to the webmail starting on one replica and finishing on the
# other, and uses the session on both (signin.py)
# - signs in to the console as its browser would (console-signin.py)
#
# SERVER_TAG=plan lab/chart/frontends-test.sh
# SERVER_TAG=plan WEBMAIL_TAG=kw4 lab/chart/frontends-test.sh
#
# WEBMAIL_TAG picks another inbuxa-lab/webmail image than the one in
# values-frontends.yaml.
set -euo pipefail
cd "$(dirname "$0")"
SERVER_TAG="${SERVER_TAG:?the server image tag in kind}"
EXTRA=()
[ -n "${WEBMAIL_TAG:-}" ] && EXTRA+=(--set webmail.image.tag="$WEBMAIL_TAG")
K=(kubectl --context kind-inbuxa-lab -n inbuxa)
CHART="${CHART:-../../../inbuxa-charts/charts/inbuxa}"
STATE="${STATE:-$HOME/.cache/inbuxa-lab}"
PIDS=()
cleanup() { for p in "${PIDS[@]}"; do kill "$p" 2>/dev/null || true; done; }
trap cleanup EXIT
forward() { # <local port> <target>
# Something else on the port would answer in the forward's place
if ss -ltn "sport = :$1" | grep -q LISTEN; then
echo "!! port $1 is in use by something else: PORTS=<first of four free ports> $0" >&2
exit 1
fi
"${K[@]}" port-forward "$2" "$1:8080" >/dev/null 2>&1 &
PIDS+=($!)
}
# Four local ports in a row, for the server, the two webmail pods and the console
P="${PORTS:-18080}"
echo "== install the webmail and the console"
helm --kube-context kind-inbuxa-lab -n inbuxa upgrade inbuxa "$CHART" \
-f values-lab.yaml -f values-frontends.yaml --set server.image.tag="$SERVER_TAG" "${EXTRA[@]}" \
--wait --timeout 10m >/dev/null
"${K[@]}" get pods -l 'app.kubernetes.io/component in (webmail,console)' --no-headers
# helm --wait returns before the old pods are gone: pick from the new ones
"${K[@]}" rollout status deployment/inbuxa-webmail --timeout 5m >/dev/null
sleep 5
mapfile -t webmail < <("${K[@]}" get pods -l app.kubernetes.io/component=webmail \
--field-selector status.phase=Running -o name | sort)
[ "${#webmail[@]}" -ge 2 ] || { echo "!! fewer than two webmail pods"; exit 1; }
forward $((P + 1)) "${webmail[0]}"
forward $((P + 2)) "${webmail[1]}"
forward $P svc/inbuxa-http
forward $((P + 3)) svc/inbuxa-console
sleep 3
echo "== webmail: start on ${webmail[0]#pod/}, finish on ${webmail[1]#pod/}"
python3 signin.py http://127.0.0.1:$((P + 1)) http://127.0.0.1:$((P + 2)) http://127.0.0.1:$P \
[email protected] "$STATE/alice.password"
echo "== console"
python3 console-signin.py http://127.0.0.1:$((P + 3)) http://127.0.0.1:$P \
https://admin.lab.test https://mail.lab.test [email protected] "$STATE/admin.password"
echo "== both pass"