From c89a375e5d61ad6521a32be30cda3d201123d170 Mon Sep 17 00:00:00 2001 From: Dai Ha Date: Sat, 12 Sep 2026 11:42:46 +0700 Subject: [PATCH 1/2] fleetd #521: extract should_swap so the swap guard can't be silently disabled Mutating the swap step's guard (if [ "$DO_BUILD" = 1 ] -> if false) left the whole test suite green: test_swap_ordered_after_wait_and_before_start only checks source positions, which an in-place if-condition edit never moves. Extracts the decision into should_swap(do_build), following the same shape as #510's wait_for_daemon_exit and #517's drain_gate_refusal, with a direct test for each value. --- scripts/redeploy-fleetd.sh | 18 +++++++++++++++++- scripts/test-redeploy-fleetd.sh | 17 +++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/scripts/redeploy-fleetd.sh b/scripts/redeploy-fleetd.sh index 36a423d..1cb18d5 100755 --- a/scripts/redeploy-fleetd.sh +++ b/scripts/redeploy-fleetd.sh @@ -178,6 +178,22 @@ swap_staged_jar() { may recover this once you find out why the move failed." } +# fleetd #521: extracted so the suite can call this decision directly, the same way #510 extracted +# wait_for_daemon_exit (so its ordering became checkable) and #517 extracted drain_gate_refusal (so +# its abort branch became checkable) — see the comments above each. Before this, the only test of +# the swap step was test_swap_ordered_after_wait_and_before_start, a SOURCE-POSITION test: it checks +# where swap_staged_jar's call site sits relative to wait_for_daemon_exit and the start step, by +# reading this script's own text. Mutating the swap step's guard (`if [ "$DO_BUILD" = 1 ]` -> `if +# false`) leaves every one of those line positions unchanged, so that test stayed green while the +# swap never ran — a live redeploy would then start (or try to start) with no jar at the live path, +# since stage_built_jar already moved it out during the build step above, regardless of this guard. +# Pure: decides only whether a swap should happen, no side effects, so a test can call it directly +# with both values of do_build instead of driving the real build/stop/start flow. +should_swap() { + local do_build="$1" + [ "$do_build" = 1 ] +} + # `launchctl list