From c6312a688106a8bdbbb95192a85be215a5aa01c5 Mon Sep 17 00:00:00 2001 From: "pithead-developer[bot]" <4933481+pithead-developer[bot]@users.noreply.github.com> Date: Thu, 26 Nov 2026 22:03:46 -0600 Subject: [PATCH 1/2] test(os): bound the miner fastpath receipt by the trial's journal cursor The #3375 rig row judged the fastpath restart by grepping the recovery unit's journal since a marker written after the backup call returned, so a restart recorded between the proxy recreation and that marker stayed invisible, and a red verdict carried no evidence of which case it was. The receipt now searches from a journal cursor captured before the backup request (marker window kept as fallback) and, when the restart is missing, prints the window used and the recovery unit's own restart lines so a timing miss can be told from a real defect. Co-Authored-By: Claude Code --- tests/os/appliance-miner-recovery-leg.sh | 38 ++++++++++++++++++--- tests/os/selftest-miner-recovery.sh | 42 ++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 5 deletions(-) diff --git a/tests/os/appliance-miner-recovery-leg.sh b/tests/os/appliance-miner-recovery-leg.sh index eeec1e927d..d18af355ef 100644 --- a/tests/os/appliance-miner-recovery-leg.sh +++ b/tests/os/appliance-miner-recovery-leg.sh @@ -92,11 +92,38 @@ miner_watch_restore() { return "$failed" } miner_fastpath_receipt() { - [ -e /usr/local/sbin/pithead-miner-recovery ] || return 0 - grep -Fq 'proxy was recreated' /usr/local/sbin/pithead-miner-recovery || return 0 - timeout 10 journalctl --no-pager --since "@$(cat "$T3375/backup-at")" \ - -u pithead-miner-recovery.service | grep -Fq 'proxy was recreated' || return 1 - printf '%s\n' 'pithead-t3375: fastpath_restart=observed' + local recovery_bin cursor='' matches='' window='' found=0 + recovery_bin=${MINER_RECOVERY_BIN:-/usr/local/sbin/pithead-miner-recovery} + [ -e "$recovery_bin" ] || return 0 + grep -Fq 'proxy was recreated' "$recovery_bin" || return 0 + if [ -s "$T3375/fastpath-cursor" ]; then + window=journal-cursor + cursor=$(cat "$T3375/fastpath-cursor") + if timeout 10 journalctl --no-pager --after-cursor="$cursor" -u pithead-miner-recovery.service | + grep -Fq 'proxy was recreated'; then + found=1 + fi + else + window=backup-at-marker + if timeout 10 journalctl --no-pager --since "@$(cat "$T3375/backup-at")" -u pithead-miner-recovery.service | + grep -Fq 'proxy was recreated'; then + found=1 + fi + fi + if [ "$found" = 1 ]; then + printf '%s\n' 'pithead-t3375: fastpath_restart=observed' + return 0 + fi + printf 'pithead-t3375: fastpath_restart=missing window=%s backup_at=%s\n' \ + "$window" "$(cat "$T3375/backup-at" 2>/dev/null || printf 'unknown')" + matches=$(timeout 10 journalctl --no-pager --since '-30 minutes' -u pithead-miner-recovery.service | + grep -E 'restarting xmrig' | tail -n 5) || matches='' + if [ -n "$matches" ]; then + printf 'pithead-t3375: recovery unit restart lines in the last 30 minutes:\n%s\n' "$matches" + else + printf '%s\n' 'pithead-t3375: no recovery restart line in the last 30 minutes' + fi + return 1 } miner_watch() { local end=$((SECONDS + 1200)) @@ -340,6 +367,7 @@ miner_guest_dispatch() { identity) podman inspect --format '{{.Id}} {{.State.StartedAt}}' xmrig-proxy ;; backup-ready) podman inspect --format '{{.Id}}' xmrig-proxy >"$T3375/proxy-id" + timeout 10 journalctl --no-pager -n 0 --show-cursor | sed -n 's/^cursor: //p' >"$T3375/fastpath-cursor" || true ;; backup-applied) touch "$T3375/backup-applied" diff --git a/tests/os/selftest-miner-recovery.sh b/tests/os/selftest-miner-recovery.sh index bdff2a3af4..42e9603eb3 100644 --- a/tests/os/selftest-miner-recovery.sh +++ b/tests/os/selftest-miner-recovery.sh @@ -317,3 +317,45 @@ if miner_watch_restore; then fi [ -e "$T3375/paused" ] printf '%s\n' 'PASS: failed watchdog restoration retains its control files' +MINER_RECOVERY_BIN="$work/recovery" +printf '%s\n' 'pithead-miner-recovery: local miner proxy was recreated while the miner was disconnected; restarting xmrig' >"$MINER_RECOVERY_BIN" +printf '%s\n' 's=0000000000000000;i=0;b=0;m=0;r=0;u=00000000000000000000000000000000' >"$T3375/fastpath-cursor" +printf '%s\n' 1700000000 >"$T3375/backup-at" +journalctl() { + case "$*" in + *--after-cursor*) printf '%s\n' 'Nov 26 10:00:00 guest pithead-miner-recovery[9]: pithead-miner-recovery: proxy was recreated' ;; + *) : ;; + esac +} +miner_fastpath_receipt >"$work/receipt" +grep -Fxq 'pithead-t3375: fastpath_restart=observed' "$work/receipt" +journalctl() { :; } +if miner_fastpath_receipt >"$work/receipt"; then + echo 'FAIL: a trial with no recovery restart line passed the receipt' + exit 1 +fi +grep -Fq 'fastpath_restart=missing window=journal-cursor' "$work/receipt" +grep -Fq 'no recovery restart line in the last 30 minutes' "$work/receipt" +printf '%s\n' 'PASS: a restart recorded only before the trial cursor window is never credited to it' +journalctl() { + case "$*" in + *'--since @'*) printf '%s\n' 'Nov 26 10:00:00 guest pithead-miner-recovery[9]: pithead-miner-recovery: proxy was recreated' ;; + *) : ;; + esac +} +rm -f "$T3375/fastpath-cursor" +miner_fastpath_receipt >"$work/receipt" +grep -Fxq 'pithead-t3375: fastpath_restart=observed' "$work/receipt" +journalctl() { + case "$*" in + *'--since -30 minutes'*) printf '%s\n' 'Nov 26 10:00:00 guest pithead-miner-recovery[9]: pithead-miner-recovery: active local miner disconnected for 300 seconds; restarting xmrig' ;; + *) : ;; + esac +} +if miner_fastpath_receipt >"$work/receipt"; then + echo 'FAIL: an absent restart inside the marker window passed the receipt' + exit 1 +fi +grep -Fq 'fastpath_restart=missing window=backup-at-marker' "$work/receipt" +grep -Fq 'disconnected for 300 seconds; restarting xmrig' "$work/receipt" +printf '%s\n' 'PASS: the fastpath receipt keeps the marker fallback and records why a missing restart was judged' From b77b413d7aa8f6f1da8b98695e685254296d7047 Mon Sep 17 00:00:00 2001 From: "pithead-developer[bot]" <4933481+pithead-developer[bot]@users.noreply.github.com> Date: Thu, 26 Nov 2026 22:32:17 -0600 Subject: [PATCH 2/2] test(os): capture the trial cursor from journalctl's real cursor line journalctl prints its cursor as "-- cursor: ", so the capture pattern from the first commit never matched and every real trial would have silently kept the marker window. The selftest now drives the backup-ready capture through that exact shape and pins the cursor the receipt later searches from. Co-Authored-By: Claude Code --- tests/os/appliance-miner-recovery-leg.sh | 2 +- tests/os/selftest-miner-recovery.sh | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/os/appliance-miner-recovery-leg.sh b/tests/os/appliance-miner-recovery-leg.sh index d18af355ef..c375f62ec9 100644 --- a/tests/os/appliance-miner-recovery-leg.sh +++ b/tests/os/appliance-miner-recovery-leg.sh @@ -367,7 +367,7 @@ miner_guest_dispatch() { identity) podman inspect --format '{{.Id}} {{.State.StartedAt}}' xmrig-proxy ;; backup-ready) podman inspect --format '{{.Id}}' xmrig-proxy >"$T3375/proxy-id" - timeout 10 journalctl --no-pager -n 0 --show-cursor | sed -n 's/^cursor: //p' >"$T3375/fastpath-cursor" || true + timeout 10 journalctl --no-pager -n 0 --show-cursor | sed -n 's/^-- cursor: //p' >"$T3375/fastpath-cursor" || true ;; backup-applied) touch "$T3375/backup-applied" diff --git a/tests/os/selftest-miner-recovery.sh b/tests/os/selftest-miner-recovery.sh index 42e9603eb3..b3a52becc8 100644 --- a/tests/os/selftest-miner-recovery.sh +++ b/tests/os/selftest-miner-recovery.sh @@ -319,14 +319,17 @@ fi printf '%s\n' 'PASS: failed watchdog restoration retains its control files' MINER_RECOVERY_BIN="$work/recovery" printf '%s\n' 'pithead-miner-recovery: local miner proxy was recreated while the miner was disconnected; restarting xmrig' >"$MINER_RECOVERY_BIN" -printf '%s\n' 's=0000000000000000;i=0;b=0;m=0;r=0;u=00000000000000000000000000000000' >"$T3375/fastpath-cursor" printf '%s\n' 1700000000 >"$T3375/backup-at" +export PROXY_STARTED_AT=4444 journalctl() { case "$*" in + *--show-cursor*) printf -- '-- cursor: s=0000000000000000;i=2;b=0;m=0;r=0;u=11111111111111111111111111111111\n' ;; *--after-cursor*) printf '%s\n' 'Nov 26 10:00:00 guest pithead-miner-recovery[9]: pithead-miner-recovery: proxy was recreated' ;; *) : ;; esac } +miner_guest_dispatch backup-ready +[ "$(cat "$T3375/fastpath-cursor")" = 's=0000000000000000;i=2;b=0;m=0;r=0;u=11111111111111111111111111111111' ] miner_fastpath_receipt >"$work/receipt" grep -Fxq 'pithead-t3375: fastpath_restart=observed' "$work/receipt" journalctl() { :; }