fleetd #517: pin the drain-gate abort branch and jar_id absent case #520
Reference in New Issue
Block a user
Delete Branch "worker/517-abort-branch-and-jar-id-41b641-2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
fleetd #517 — a source-text test pins what a message SAYS and never whether it is REACHED
Two mutation-testing survivors in
scripts/redeploy-fleetd.sh, both fixed. No Java in this unit — all shell.Defect 1: the drain-gate abort branch was not pinned
Extracted the decision into a pure function:
The main flow now calls
die "$(drain_gate_refusal "$DO_BUILD" "$JAR_STAGED")". Added 4 new tests covering all four combinations:--no-build--no-build, staged present → ALSO "nothing changed", deliberately —--no-buildnever builds or stages anything itself, so a staged jar found here is a leftover from an earlier, unrelated run; this run truly changed nothing. Documented in a comment above the function.--no-build, staged absent → "nothing changed"The existing source-text grep test (
test_drain_gate_abort_message_says_no_no_build) is kept, not deleted — it catches a re-wording, the new tests catch a dead branch. Neither replaces the other.Defect 2:
jar_id's "absent" branch was unpinnedAdded
test_jar_id_reports_absent_for_missing_file: points$JARat a path that does not exist and asserts the output is exactlyabsent, for both the no-argument default and an explicit missing path (the mutation sits on one shared|| echo, so both halves are covered).Acceptance
bash scripts/test-redeploy-fleetd.shexits 0. Test functions defined: 40 (was 35). Test functions invoked: 40 (was 35) — counts match (grep -c '^test_[a-zA-Z_]*() {'vsgrep -cE '^test_[a-zA-Z_]+$').bash -npasses on bothscripts/redeploy-fleetd.shandscripts/test-redeploy-fleetd.sh.if [ "$do_build" = 1 ] && [ -f "$staged_path" ]; then→if false; thenat the extracted function): suite went red —FAIL: build-ran+staged-present refusal does not name the staged jar path.jar_id'secho "absent"→echo "present"): suite went red —FAIL: jar_id with no arguments must report absent when $JAR does not exist: expected absent, got present.grep -nre-read of the exact line, then restored and confirmed byte-identical to the pre-mutation copy, then a green control run.scripts/redeploy-fleetd.shpristine hash before any edits:e502f7498f8cca0b8fb9cf83d10751445a0dfbe9c119fc44a980f4d660124dfa(matches the ticket's stated hash, confirmed withshasum -a 256at the start of this work). Every restore during mutation testing matched the fixed script's own hash (2cb83dc3...) byte-for-byte.Also (not fixed — separate ticket, per the brief)
Found one more branch with the same shape: the swap step's guard
if [ "$DO_BUILD" = 1 ]; thenat the line right beforeswap_staged_jar "$JAR_STAGED" "$JAR"is only checked bytest_swap_ordered_after_wait_and_before_start, which greps for line positions of call-site text in the source — it does not check that this guard is ever true. Mutating it toif false; thenwould leave every line position unchanged (a one-line in-place edit), so that test would still pass while the built jar would silently never get swapped into the live path after a "successful" redeploy.Prohibitions honored
Never ran
scripts/redeploy-fleetd.shagainst the live daemon (not even--check) — all testing was done by sourcing the script into throwaway shells / calling extracted functions directly, per the ticket's hard prohibition. Never printed the value of any env var — only checked presence (GITEA_TOKEN/GITEA_HOSTset: yes/yes). Staged only the two changed files explicitly (nogit add -A).