Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions tests/e2e-real.sh
Original file line number Diff line number Diff line change
Expand Up @@ -630,13 +630,15 @@ perf() {
bad "perf: bench failed"
printf '%s\n' "$out" | tail -3 >&2
"$RIGFORGE" start >/dev/null 2>&1 || true
return 0
summary "perf"
return
fi
"$RIGFORGE" start >/dev/null 2>&1 || true
hr="$(printf '%s' "$out" | grep -oiE '[0-9.]+ H/s' | tail -1 | grep -oE '[0-9.]+')"
if [ -z "$hr" ]; then
bad "perf: no hashrate parsed from bench output"
return 0
summary "perf"
return
fi
if [ -n "${E2E_PERF_RECORD:-}" ]; then
# #214: judge BEFORE writing — recording is the only perf run most rigs ever get, and a
Expand All @@ -645,7 +647,8 @@ perf() {
if [ -f "$bl" ] && ! _perf_judge "$hr" "$bl" "$hist" "$tol"; then
if [ -z "${E2E_PERF_FORCE:-}" ]; then
bad "perf: NOT recorded — the measurement regressed (see above). Fix the regression, or consciously re-record with E2E_PERF_FORCE=1."
return 0
summary "perf"
return
fi
printf ' \033[1;33m∙\033[0m E2E_PERF_FORCE=1 — recording a REGRESSED measurement as the new baseline\n'
fi
Expand All @@ -657,14 +660,17 @@ perf() {
# dirty tracked files — say so now, not at the next deploy.
printf ' \033[1;33m∙\033[0m collect: %s and %s\n' "$bl" "$hist"
printf ' \033[1;33m∙\033[0m after they are committed upstream, reset this rig or the next tag deploy aborts: git checkout -- tests/perf-baselines/\n'
return 0
summary "perf"
return
fi
if [ ! -f "$bl" ]; then
printf ' \033[1;33m∙\033[0m no baseline for %s — measured %s H/s; record with E2E_PERF_RECORD=1 and commit tests/perf-baselines/\n' "$(hostname)" "$hr"
return 0
summary "perf"
return
fi
# The bad lines inside the judge already counted any failure; nothing more to decide here.
_perf_judge "$hr" "$bl" "$hist" "$tol" || true
summary "perf"
}

case "${1:-}" in
Expand Down
24 changes: 9 additions & 15 deletions tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5630,34 +5630,28 @@ fi
# paths — no root, no /var/lock — with background subshells as the competing "suites".
# #214: perf recording judges BEFORE it writes — the recording run is the only perf gate most
# rigs ever get, so a regressed measurement must fail the phase and leave the baseline untouched
# (E2E_PERF_FORCE=1 is the conscious override). Helpers extracted from e2e-real.sh the same way
# the rig_lock tests do it; ok/bad/phase and the bench are stubbed.
echo "== unit: e2e-real perf record gate (#214) =="
# (E2E_PERF_FORCE=1 is the conscious override). #267: the harness must exercise the REAL
# summary/exit plumbing (ok/bad/summary extracted verbatim from e2e-real.sh, same as the rig_lock
# tests do it below) rather than reimplement it — only phase and the bench are stubbed.
echo "== unit: e2e-real perf record gate (#214/#267) =="
PJ="$(mktemp -d "$SANDBOX/pj.XXXXXX")"
sed -n '/^_perf_judge()/,/^}/p' "$ROOT/tests/e2e-real.sh" >"$PJ/fns.sh"
sed -n '/^perf()/,/^}/p' "$ROOT/tests/e2e-real.sh" >>"$PJ/fns.sh"
sed -n '/^ok() {$/,/^}/p; /^bad() {$/,/^}/p; /^summary() {$/,/^}/p; /^_perf_judge()/,/^}/p; /^perf()/,/^}/p' "$ROOT/tests/e2e-real.sh" >"$PJ/fns.sh"
cat >"$PJ/rigforge-stub" <<'EOF'
#!/usr/bin/env bash
[ "$1" = bench ] && echo "${STUB_BENCH_HS:-10000.0} H/s"
exit 0
EOF
chmod +x "$PJ/rigforge-stub"
run_perf() { # env: STUB_BENCH_HS E2E_PERF_RECORD E2E_PERF_FORCE; prints output; rc = #bad calls
run_perf() { # env: STUB_BENCH_HS E2E_PERF_RECORD E2E_PERF_FORCE; prints output; rc = perf()'s real summary/exit
(
cd "$PJ" || exit 9
HERE="$PJ"
RIGFORGE="$PJ/rigforge-stub"
BADS=0
ok() { echo "OK: $1"; }
bad() {
echo "BAD: $1"
BADS=$((BADS + 1))
}
PASS=0
FAIL=0
phase() { :; }
source "$PJ/fns.sh"
set +e
perf
exit "$BADS"
perf 2>&1
)
}
host="$(hostname)"
Expand Down