2026-05-01 16:06:09 -04:00
|
|
|
|
#!/usr/bin/env bash
|
2026-06-22 18:12:41 -04:00
|
|
|
|
# tests/lifecycle/run-gate.sh — loop the lifecycle harness N times (default 5×, the release gate).
|
2026-05-01 16:06:09 -04:00
|
|
|
|
#
|
|
|
|
|
|
# Each iteration: setup-teardown → run.sh (with the same args you'd pass
|
|
|
|
|
|
# to run.sh) → setup-teardown. Tallies pass/fail per iteration and prints a
|
|
|
|
|
|
# summary at the end. Returns non-zero if any iteration failed.
|
|
|
|
|
|
#
|
|
|
|
|
|
# Env:
|
2026-06-22 18:12:41 -04:00
|
|
|
|
# ARCHY_ITERATIONS (default: 5)
|
2026-05-01 16:06:09 -04:00
|
|
|
|
# ARCHY_FAIL_FAST=1 stop on first failed iteration
|
|
|
|
|
|
# plus everything run.sh / lib/rpc.bash respects
|
|
|
|
|
|
# (ARCHY_PASSWORD, ARCHY_HOST, ARCHY_SCHEME, ARCHY_ALLOW_DESTRUCTIVE,
|
|
|
|
|
|
# ARCHY_ALLOW_CASCADE_DESTRUCTIVE, ARCHY_ALLOW_NOAUTH)
|
|
|
|
|
|
#
|
|
|
|
|
|
# Usage:
|
2026-06-22 18:12:41 -04:00
|
|
|
|
# tests/lifecycle/run-gate.sh # 5× full bats/ suite
|
|
|
|
|
|
# ARCHY_ITERATIONS=5 tests/lifecycle/run-gate.sh # 5× full suite
|
|
|
|
|
|
# tests/lifecycle/run-gate.sh bitcoin-knots # 5× a single suite
|
2026-05-01 16:06:09 -04:00
|
|
|
|
#
|
|
|
|
|
|
# Suggested release-gate invocation:
|
|
|
|
|
|
# ARCHY_PASSWORD=password123 ARCHY_ALLOW_DESTRUCTIVE=1 \
|
2026-06-22 18:12:41 -04:00
|
|
|
|
# tests/lifecycle/run-gate.sh
|
2026-05-01 16:06:09 -04:00
|
|
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
|
|
HERE="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
|
|
cd "$HERE"
|
|
|
|
|
|
|
2026-06-22 18:12:41 -04:00
|
|
|
|
ITER="${ARCHY_ITERATIONS:-5}"
|
2026-05-01 16:06:09 -04:00
|
|
|
|
if ! [[ "$ITER" =~ ^[1-9][0-9]*$ ]]; then
|
|
|
|
|
|
echo "ARCHY_ITERATIONS must be a positive integer, got: $ITER" >&2
|
|
|
|
|
|
exit 2
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
passed=0
|
|
|
|
|
|
failed=0
|
|
|
|
|
|
failures=()
|
|
|
|
|
|
start=$(date +%s)
|
|
|
|
|
|
|
2026-06-22 17:11:15 -04:00
|
|
|
|
# Best-effort settle: wait for the backend stack to be healthy before an
|
|
|
|
|
|
# iteration starts, so back-to-back destructive iterations don't compound
|
|
|
|
|
|
# restart churn (lnd wallet-unlock + the 4-container mempool stack reconnect
|
|
|
|
|
|
# need time to recover). On-node gate only (localhost probes); never fails the
|
|
|
|
|
|
# run — just delays up to the deadline. Disable with ARCHY_SETTLE=0.
|
|
|
|
|
|
settle_stack() {
|
|
|
|
|
|
[[ "${ARCHY_SETTLE:-1}" == "1" && "${ARCHY_ALLOW_DESTRUCTIVE:-0}" == "1" ]] || return 0
|
|
|
|
|
|
local deadline=$(( $(date +%s) + ${ARCHY_SETTLE_SECS:-180} ))
|
|
|
|
|
|
while (( $(date +%s) < deadline )); do
|
|
|
|
|
|
local ok=1
|
|
|
|
|
|
# mempool-api + frontend + bitcoin-ui = good proxies for "stack reconnected"
|
|
|
|
|
|
curl -fsS -m 4 -o /dev/null "http://127.0.0.1:8999/api/v1/backend-info" 2>/dev/null || ok=0
|
|
|
|
|
|
curl -fsS -m 4 -o /dev/null "http://127.0.0.1:4080/" 2>/dev/null || ok=0
|
|
|
|
|
|
podman exec lnd lncli --tlscertpath /root/.lnd/tls.cert \
|
|
|
|
|
|
--macaroonpath /root/.lnd/data/chain/bitcoin/mainnet/readonly.macaroon \
|
|
|
|
|
|
--rpcserver localhost:10009 getinfo >/dev/null 2>&1 || ok=0
|
|
|
|
|
|
(( ok == 1 )) && { echo " (stack settled)"; return 0; }
|
|
|
|
|
|
sleep 4
|
|
|
|
|
|
done
|
|
|
|
|
|
echo " (stack settle deadline reached — proceeding anyway)"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-01 16:06:09 -04:00
|
|
|
|
# One initial teardown so a previous run's cookies don't poison iteration 1.
|
|
|
|
|
|
./setup-teardown.sh
|
|
|
|
|
|
|
|
|
|
|
|
for i in $(seq 1 "$ITER"); do
|
|
|
|
|
|
echo
|
|
|
|
|
|
echo "═══ iteration $i / $ITER ═══"
|
|
|
|
|
|
iter_start=$(date +%s)
|
2026-06-22 17:11:15 -04:00
|
|
|
|
settle_stack
|
2026-05-01 16:06:09 -04:00
|
|
|
|
|
|
|
|
|
|
if ./run.sh "$@"; then
|
|
|
|
|
|
iter_end=$(date +%s)
|
|
|
|
|
|
passed=$((passed + 1))
|
|
|
|
|
|
echo "── iteration $i: PASS ($((iter_end - iter_start))s) ──"
|
|
|
|
|
|
else
|
|
|
|
|
|
rc=$?
|
|
|
|
|
|
iter_end=$(date +%s)
|
|
|
|
|
|
failed=$((failed + 1))
|
|
|
|
|
|
failures+=("$i")
|
|
|
|
|
|
echo "── iteration $i: FAIL (exit=$rc, $((iter_end - iter_start))s) ──"
|
|
|
|
|
|
if [[ "${ARCHY_FAIL_FAST:-0}" == "1" ]]; then
|
|
|
|
|
|
echo "ARCHY_FAIL_FAST=1, stopping early"
|
|
|
|
|
|
break
|
|
|
|
|
|
fi
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Teardown between iterations so iteration N+1 starts with a clean
|
|
|
|
|
|
# session-cookie state regardless of what iteration N did.
|
|
|
|
|
|
./setup-teardown.sh
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
end=$(date +%s)
|
|
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
|
echo "════════════════════════════════════════"
|
|
|
|
|
|
echo " RESULTS"
|
|
|
|
|
|
echo " iterations: $((passed + failed)) / $ITER"
|
|
|
|
|
|
echo " passed: $passed"
|
|
|
|
|
|
echo " failed: $failed"
|
|
|
|
|
|
if (( failed > 0 )); then
|
|
|
|
|
|
echo " failed at: ${failures[*]}"
|
|
|
|
|
|
fi
|
|
|
|
|
|
echo " wall time: $((end - start))s"
|
|
|
|
|
|
echo "════════════════════════════════════════"
|
|
|
|
|
|
|
|
|
|
|
|
if (( failed > 0 )); then
|
|
|
|
|
|
exit 1
|
|
|
|
|
|
fi
|