From e21f3baf2296515b6f07feb222204ec617adbd00 Mon Sep 17 00:00:00 2001 From: archipelago Date: Thu, 9 Jul 2026 05:54:01 -0400 Subject: [PATCH] fix(tests): settle window for quadlet active-state asserts (123/124) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mempool-api exits at startup while electrumx is catching up to the daemon (7-day initial-sync ETA on .228), flapping through 'activating' for ~2 min after each lifecycle cycle before systemd heals it. The instant asserts probed inside that window both iterations. Poll up to 180s for converges-to-active — a genuine crash-loop still fails. Co-Authored-By: Claude Fable 5 --- .../bats/use-quadlet-backends-install.bats | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/tests/lifecycle/bats/use-quadlet-backends-install.bats b/tests/lifecycle/bats/use-quadlet-backends-install.bats index 884f5ccf..ddd660e1 100644 --- a/tests/lifecycle/bats/use-quadlet-backends-install.bats +++ b/tests/lifecycle/bats/use-quadlet-backends-install.bats @@ -147,8 +147,18 @@ require_quadlet_backends() { while read -r name; do [[ -z "$name" ]] && continue is_user_stopped "$name" && continue - run systemctl --user is-active "$name.service" - [[ "$status" -eq 0 ]] || fail "$name.service is '$output' — expected 'active'" + # Converges-to-active, not instantly-active: a dependency-degraded app + # (mempool-api while electrumx catches up to the daemon) exits at startup + # and flaps through 'activating' for a couple of minutes after a lifecycle + # cycle; systemd's Restart=on-failure heals it. A genuine crash-loop still + # fails after the settle window (gate 2026-07-09, .228 iterations 1+2). + local state="" deadline=$((SECONDS + 180)) + while (( SECONDS < deadline )); do + state="$(systemctl --user is-active "$name.service" 2>&1)" && break + sleep 5 + done + [[ "$state" == "active" ]] \ + || fail "$name.service is '$state' — did not reach 'active' within 180s" done < <(backend_quadlet_units) } @@ -157,9 +167,16 @@ require_quadlet_backends() { while read -r name; do [[ -z "$name" ]] && continue is_user_stopped "$name" && continue - run sh -c "podman inspect --format '{{.State.Running}}' '$name'" - [[ "$status" -eq 0 ]] || fail "$name not present in podman" - [[ "$output" == "true" ]] || fail "$name container exists but not running (state=$output)" + # Same settle window as the active-state assert above: a quadlet --rm + # container is absent for a few seconds around each systemd retry. + local state="" deadline=$((SECONDS + 180)) + while (( SECONDS < deadline )); do + state="$(podman inspect --format '{{.State.Running}}' "$name" 2>/dev/null)" \ + && [[ "$state" == "true" ]] && break + sleep 5 + done + [[ "$state" == "true" ]] \ + || fail "$name has no running container within 180s (state=${state:-absent})" done < <(backend_quadlet_units) }