OverviewFilesCommitsIssuesDocsReleasesPeers

hyperswarm-peer / integration / run_all.sh

76 lines · bash ref:
#!/usr/bin/env bash
# Run all integration test layers sequentially.
# Each layer is independent — failures in one don't skip others.
# Per-layer timeouts prevent any single layer from hanging the suite.
set -uo pipefail
cd "$(dirname "$0")"

echo "╔════════════════════════════════════════════════════╗"
echo "║  HyperswarmPeer Integration Tests — 10 Layers     ║"
echo "╚════════════════════════════════════════════════════╝"
echo ""

PASS=0
FAIL=0
SKIP=0

# Per-layer hard timeout (seconds) — generous enough for normal runs,
# hard cutoff for hangs. Includes startup + internal timeouts + buffer.
declare -A LAYER_TIMEOUT=(
    [1]=90    # smoke test
    [2]=90    # 2 peers, 45s internal wait
    [3]=120   # 3 peers, play + migration
    [4]=60    # single UDS test
    [5]=75    # 2 peers, 30s internal wait
    [6]=120   # 3 sidecars + 3 players
    [7]=120   # 3 peers, reconnect test
    [8]=120   # 3 peers, 60s internal wait
    [9]=150   # 3 peers, 90s internal wait
    [10]=240  # daemon + 3 peers, 120s internal wait
)

run_layer() {
    local num=$1
    local script="run_layer${num}.sh"
    local max_time=${LAYER_TIMEOUT[$num]:-120}

    if [ ! -f "$script" ]; then
        echo "SKIP: $script not found"
        SKIP=$((SKIP + 1))
        return
    fi

    echo ""
    echo "────────────────────────────────────────────────────"
    timeout -k 15 "$max_time" bash "$script"
    local rc=$?

    if [ $rc -eq 124 ] || [ $rc -eq 137 ]; then
        echo "=== Layer $num: KILLED (exceeded ${max_time}s hard timeout) ==="
        FAIL=$((FAIL + 1))
    elif [ $rc -eq 0 ]; then
        PASS=$((PASS + 1))
    else
        FAIL=$((FAIL + 1))
    fi
}

for layer in 1 2 3 4 5 6 7 8 9 10; do
    # Clean shared state and kill strays between layers
    rm -f /tmp/layer_bootstrap.txt /tmp/layer[0-9]_*.txt /tmp/layer[0-9][0-9]_*.txt
    pkill -f "layer[0-9]_testnet\|layer2_testnet" 2>/dev/null || true
    pkill -f "godot4.*layer[0-9]" 2>/dev/null || true
    sleep 2
    run_layer $layer
done

echo ""
echo "════════════════════════════════════════════════════════"
echo "Results: $PASS passed, $FAIL failed, $SKIP skipped"
echo "════════════════════════════════════════════════════════"

if [ $FAIL -gt 0 ]; then
    exit 1
fi
exit 0