|
|
|
@@ -521,6 +521,106 @@ test_drain_gate_refusal_no_build_staged_absent() {
|
|
|
|
|
assert_equals "aborted — nothing changed" "$result" "no-build+staged-absent refusal wording"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# fleetd #528 — the four tests above pin drain_gate_refusal(), and that is ALL they pin: they call
|
|
|
|
|
# the predicate directly and never touch the main flow's call site. That was measured to be not
|
|
|
|
|
# enough, the same way test_should_swap_true_when_build_ran/test_should_swap_false_when_build_skipped
|
|
|
|
|
# were not enough for #521: with the main flow reading `die "$(drain_gate_refusal "$DO_BUILD"
|
|
|
|
|
# "$JAR_STAGED")"`, replacing that whole line with a flat `die "aborted — nothing changed"` left this
|
|
|
|
|
# suite at exit 0 with zero FAIL lines and byte-identical output to a clean run. Nothing above could
|
|
|
|
|
# tell the difference, because none of it calls anything at or above the call site itself.
|
|
|
|
|
#
|
|
|
|
|
# So these four call refuse_drain_gate() — the function the main flow actually calls, holding the
|
|
|
|
|
# composed message and the die() together — with die() stubbed to RECORD whether it was called and
|
|
|
|
|
# with what message, instead of exiting the process. That fails if refuse_drain_gate stops consulting
|
|
|
|
|
# drain_gate_refusal, mangles what it passes it, or simply never calls die.
|
|
|
|
|
#
|
|
|
|
|
# What none of these four can catch: deleting the `refuse_drain_gate "$DO_BUILD" "$JAR_STAGED"` line
|
|
|
|
|
# from the main flow altogether — see the comment above refuse_drain_gate in redeploy-fleetd.sh for
|
|
|
|
|
# why no test in this file can do better than that (sourcing stops before the main flow runs).
|
|
|
|
|
DIED_CALLED=0
|
|
|
|
|
DIED_MESSAGE=""
|
|
|
|
|
stub_die_recorder() {
|
|
|
|
|
DIED_CALLED=0
|
|
|
|
|
DIED_MESSAGE=""
|
|
|
|
|
die() { DIED_CALLED=1; DIED_MESSAGE="$*"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test_refuse_drain_gate_build_ran_staged_present() {
|
|
|
|
|
source "$ROOT/scripts/redeploy-fleetd.sh"
|
|
|
|
|
local dir staged
|
|
|
|
|
dir="$TMP/refuse-drain-build-staged"; mkdir -p "$dir"
|
|
|
|
|
staged="$dir/fleetd-new.jar"
|
|
|
|
|
printf 'staged jar bytes' > "$staged"
|
|
|
|
|
stub_die_recorder
|
|
|
|
|
refuse_drain_gate 1 "$staged"
|
|
|
|
|
[ "$DIED_CALLED" = 1 ] \
|
|
|
|
|
|| fail "refuse_drain_gate build-ran+staged-present must call die, and did not"
|
|
|
|
|
printf '%s' "$DIED_MESSAGE" | grep -qF "$staged" \
|
|
|
|
|
|| fail "refuse_drain_gate build-ran+staged-present die message does not name the staged jar"
|
|
|
|
|
printf '%s' "$DIED_MESSAGE" | grep -qF 'Rerun WITHOUT --no-build' \
|
|
|
|
|
|| fail "refuse_drain_gate build-ran+staged-present die message is missing the rerun instruction"
|
|
|
|
|
if printf '%s' "$DIED_MESSAGE" | grep -qF 'nothing changed'; then
|
|
|
|
|
fail "refuse_drain_gate build-ran+staged-present must not claim nothing changed — the jar already moved"
|
|
|
|
|
fi
|
|
|
|
|
source "$ROOT/scripts/redeploy-fleetd.sh"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test_refuse_drain_gate_build_ran_staged_absent() {
|
|
|
|
|
source "$ROOT/scripts/redeploy-fleetd.sh"
|
|
|
|
|
local dir
|
|
|
|
|
dir="$TMP/refuse-drain-build-no-staged"; mkdir -p "$dir"
|
|
|
|
|
stub_die_recorder
|
|
|
|
|
refuse_drain_gate 1 "$dir/fleetd-new.jar"
|
|
|
|
|
[ "$DIED_CALLED" = 1 ] \
|
|
|
|
|
|| fail "refuse_drain_gate build-ran+staged-absent must call die, and did not"
|
|
|
|
|
assert_equals "aborted — nothing changed" "$DIED_MESSAGE" "refuse_drain_gate build-ran+staged-absent die message"
|
|
|
|
|
source "$ROOT/scripts/redeploy-fleetd.sh"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test_refuse_drain_gate_no_build_staged_present() {
|
|
|
|
|
source "$ROOT/scripts/redeploy-fleetd.sh"
|
|
|
|
|
local dir staged
|
|
|
|
|
dir="$TMP/refuse-drain-no-build-staged"; mkdir -p "$dir"
|
|
|
|
|
staged="$dir/fleetd-new.jar"
|
|
|
|
|
printf 'leftover staged jar bytes' > "$staged"
|
|
|
|
|
stub_die_recorder
|
|
|
|
|
refuse_drain_gate 0 "$staged"
|
|
|
|
|
[ "$DIED_CALLED" = 1 ] \
|
|
|
|
|
|| fail "refuse_drain_gate no-build+staged-present must call die, and did not"
|
|
|
|
|
assert_equals "aborted — nothing changed" "$DIED_MESSAGE" "refuse_drain_gate no-build+staged-present die message"
|
|
|
|
|
source "$ROOT/scripts/redeploy-fleetd.sh"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test_refuse_drain_gate_no_build_staged_absent() {
|
|
|
|
|
source "$ROOT/scripts/redeploy-fleetd.sh"
|
|
|
|
|
local dir
|
|
|
|
|
dir="$TMP/refuse-drain-no-build-no-staged"; mkdir -p "$dir"
|
|
|
|
|
stub_die_recorder
|
|
|
|
|
refuse_drain_gate 0 "$dir/fleetd-new.jar"
|
|
|
|
|
[ "$DIED_CALLED" = 1 ] \
|
|
|
|
|
|| fail "refuse_drain_gate no-build+staged-absent must call die, and did not"
|
|
|
|
|
assert_equals "aborted — nothing changed" "$DIED_MESSAGE" "refuse_drain_gate no-build+staged-absent die message"
|
|
|
|
|
source "$ROOT/scripts/redeploy-fleetd.sh"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# fleetd #528 — closes the one gap the four behavioural tests above cannot: they call
|
|
|
|
|
# refuse_drain_gate directly, and sourcing stops before the main flow ever runs (the SOURCED guard),
|
|
|
|
|
# so none of them can prove the main flow still CALLS refuse_drain_gate at all. Same shape as
|
|
|
|
|
# test_swap_ordered_after_wait_and_before_start: a source-text grep for the real call site. This is
|
|
|
|
|
# what actually kills the item-1 mutation from the ticket — replacing the main flow's call with a
|
|
|
|
|
# flat `die "aborted — nothing changed"` removes this exact needle, where none of the behavioural
|
|
|
|
|
# tests above would even notice.
|
|
|
|
|
#
|
|
|
|
|
# The grep ends `|| true`: this file runs under `set -euo pipefail`, so an ABSENT needle would fail
|
|
|
|
|
# the assignment and `set -e` would kill the whole suite before the `[ -n ... ] || fail` guard below
|
|
|
|
|
# ever ran — the exact dead-check shape fleetd #528 also flags as a sweep finding (see the PR body).
|
|
|
|
|
test_refuse_drain_gate_call_site_present() {
|
|
|
|
|
local src="$ROOT/scripts/redeploy-fleetd.sh" call_line
|
|
|
|
|
call_line="$(grep -Fn 'refuse_drain_gate "$DO_BUILD" "$JAR_STAGED"' "$src" | head -1 | cut -d: -f1 || true)"
|
|
|
|
|
[ -n "$call_line" ] \
|
|
|
|
|
|| fail "could not find the main flow's refuse_drain_gate call site in redeploy-fleetd.sh"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test_no_errors() {
|
|
|
|
|
cat > "$TMP/no-errors.log" <<'LOG'
|
|
|
|
|
2026-09-05 12:00:00 INFO fleetd listening
|
|
|
|
@@ -753,6 +853,11 @@ test_drain_gate_refusal_build_ran_staged_present
|
|
|
|
|
test_drain_gate_refusal_build_ran_staged_absent
|
|
|
|
|
test_drain_gate_refusal_no_build_staged_present
|
|
|
|
|
test_drain_gate_refusal_no_build_staged_absent
|
|
|
|
|
test_refuse_drain_gate_build_ran_staged_present
|
|
|
|
|
test_refuse_drain_gate_build_ran_staged_absent
|
|
|
|
|
test_refuse_drain_gate_no_build_staged_present
|
|
|
|
|
test_refuse_drain_gate_no_build_staged_absent
|
|
|
|
|
test_refuse_drain_gate_call_site_present
|
|
|
|
|
test_no_errors
|
|
|
|
|
test_recovery_patterns_match_source
|
|
|
|
|
test_attributed_recovered_connection_error
|
|
|
|
|