diff --git a/testing/static/scripts/admission-cap-test.sh b/testing/static/scripts/admission-cap-test.sh index 25fbd9c..843bdf5 100755 --- a/testing/static/scripts/admission-cap-test.sh +++ b/testing/static/scripts/admission-cap-test.sh @@ -87,13 +87,23 @@ CAP_IP=$(node_ip "$CAP_NODE") [ -n "$CAP_IP" ] || fail "could not resolve docker_ip for node-$CAP_NODE in $TOPO_FILE" info "cap'd node: node-$CAP_NODE (ip $CAP_IP, max_peers=$MAX_PEERS)" +# Read the cap'd node's peer_count, or the empty string if it did not answer. +# +# Empty is deliberately distinct from a real 0. An `|| echo 0` fallback cannot +# do that job here: `||` binds to the last stage of the pipeline, which succeeds +# on empty input, so the fallback never fires and an unreachable container would +# be reported as a legitimate zero. +read_peer_count() { + docker exec "fips-node-${CAP_NODE}${FIPS_CI_NAME_SUFFIX:-}" fipsctl show status 2>/dev/null \ + | grep -m1 peer_count | sed 's/.*: *//' | tr -d ',' +} + # ── Phase 1: wait for convergence ──────────────────────────────────── info "phase 1: wait for node-$CAP_NODE peer_count to reach $MAX_PEERS (90s timeout)" deadline=$(($(date +%s) + 90)) pc=0 while [ "$(date +%s)" -lt "$deadline" ]; do - pc=$(docker exec "fips-node-${CAP_NODE}${FIPS_CI_NAME_SUFFIX:-}" fipsctl show status 2>/dev/null \ - | grep -m1 peer_count | sed 's/.*: *//' | tr -d ',' || echo 0) + pc=$(read_peer_count) [ "$pc" = "$MAX_PEERS" ] && break sleep 2 done @@ -186,9 +196,21 @@ for n in $DENIED; do done # ── Phase 4: cap'd node still at exactly max_peers ─────────────────── -pc_final=$(docker exec "fips-node-${CAP_NODE}${FIPS_CI_NAME_SUFFIX:-}" fipsctl show status 2>/dev/null \ - | grep -m1 peer_count | sed 's/.*: *//' | tr -d ',' || echo 0) -info "node-$CAP_NODE final peer_count=$pc_final (expected $MAX_PEERS)" +# +# Polled rather than sampled once. The load driver above restarts the denied +# peers every 15s and its final restart lands in the same second this runs, so a +# single read can hit a daemon busy with those restarts and come back empty -- +# which is a harness race, not a cap regression. Retry briefly before believing +# the answer. A genuine regression still fails, just after the retry window, +# because the loop exits early only on the expected value. +pc_final="" +deadline=$(($(date +%s) + 30)) +while [ "$(date +%s)" -lt "$deadline" ]; do + pc_final=$(read_peer_count) + [ "$pc_final" = "$MAX_PEERS" ] && break + sleep 2 +done +info "node-$CAP_NODE final peer_count=${pc_final:-} (expected $MAX_PEERS)" [ "$pc_final" = "$MAX_PEERS" ] || OVERALL=1 if [ "$OVERALL" -eq 0 ]; then