test: retry real-herdr smoke tests on treehouse contention#16
Merged
Conversation
The real-herdr smoke tests fail under fleet load when fm-spawn.sh waits for treehouse get and the pane never moves into a worktree. A shared test-only lock would serialize these two scripts with each other, but live fleet treehouse operations would not take that lock. A bounded whole-script retry fits the existing end-to-end test shape better: it only retries the exact treehouse-get timeout signature, while unrelated failures still surface immediately and deterministic regressions still fail after the retry budget.
…herdr smoke tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Make the real-herdr/treehouse smoke tests reliable under concurrent fleet load. The known flake was root-caused as environmental treehouse lease contention, not a production code bug. Keep production bin/ behavior unchanged and scope the change to tests. Characterize the contention surface first, then choose the least weakening fix: I chose a bounded whole-script retry because a test-only lock would serialize these two tests with each other but cannot be honored by live fleet treehouse operations. The retry only triggers on fm-spawn.sh's exact treehouse timeout signature ('error: treehouse get did not enter a worktree within 60s; inspect window ...'), so unrelated failures still fail immediately and deterministic regressions still fail after the retry budget. Prove with shellcheck, repeated target test runs, and a scratch held-lease run without touching existing fleet leases or herdr sessions.
What Changed
tests/real-herdr-smoke-retry.sh, a bounded whole-script retry wrapper that re-runs a real-herdr/treehouse smoke test up to a fixed attempt budget, but only when the failure matches fm-spawn.sh's exact treehouse-timeout signature (error: treehouse get did not enter a worktree within 60s; inspect window ...) — any other failure, including a genuine deterministic regression, still fails immediately or after the retry budget is exhausted.tests/fm-backend-autodetect-smoke.test.shandtests/fm-backend-herdr-workspace-per-home-e2e.test.shto run through the new retry wrapper.docs/herdr-backend.mdandCONTRIBUTING.mdto document the retry behavior and why it exists (environmental treehouse lease contention under concurrent fleet load, not a production code bug).No changes to production
bin/behavior — this is scoped entirely to test reliability.Risk Assessment
✅ Low: Test-only change (no bin/ production code touched), the retry is tightly scoped to one exact, verified error string, bounded to 3 attempts, cleans up its own temp dirs on every exit path, preserves the existing no-herdr skip behavior on CI, and shellcheck is clean with no new warnings.
Testing
Ran the two real-herdr/treehouse smoke tests multiple times end-to-end against actual herdr 0.7.2 and treehouse v2.0.0 installs (all passed, no leaked sessions), shellchecked the new retry script and both modified test files at warning+ severity (clean, no regressions vs base), and independently reproduced the treehouse-contention retry logic in an isolated scratch harness that never touched real fleet leases or herdr sessions — confirming it retries only on the exact timeout signature, ignores unrelated failures, and fails after exhausting its bounded retry budget. All evidence supports the stated intent; no issues found.
Evidence: real-herdr autodetect smoke test (2 real runs)
Evidence: real-herdr workspace-per-home e2e smoke test (real run)
Evidence: scratch held-lease retry proof (no real herdr/treehouse touched)
Evidence: shellcheck on new/changed files
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
tests/real-herdr-smoke-retry.sh:15- The whole-script retry re-execs the entire test file from scratch on a treehouse-contention timeout. fm-backend-herdr-workspace-per-home-e2e.test.sh makes three sequential fm-spawn.sh calls; if contention hits the 2nd or 3rd call, the retry replays the 1st (and 2nd) call's already-passed assertions again, so a retried run's combined stdout contains duplicate 'ok' lines from the earlier, already-successful portion of the previous attempt.tests/real-herdr-smoke-retry.sh:24- Matching is purely on the fm-spawn.sh error string, so a genuine deterministic worktree-mount regression that always produces this exact message (not just lease contention) would also be retried up to 3x (each waiting out the full 60s poll) before finally failing, adding ~2-3 minutes to the failure feedback loop. This is a bounded, intentional tradeoff per the stated design (deterministic regressions still fail after the retry budget), not a functional bug.✅ **Test** - passed
✅ No issues found.
command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"shellcheck -S warning on tests/real-herdr-smoke-retry.sh, tests/fm-backend-autodetect-smoke.test.sh, tests/fm-backend-herdr-workspace-per-home-e2e.test.sh (clean, no new issues vs base commit)bash tests/fm-backend-autodetect-smoke.test.sh run 3x against real herdr/treehouse — all pass, no leaked herdr sessions afterward (verified viaherdr server list)bash tests/fm-backend-herdr-workspace-per-home-e2e.test.sh run against real herdr/treehouse — all 10 assertions passScratch fake-script test sourcing tests/real-herdr-smoke-retry.sh directly to simulate a held-lease/contention failure on attempt 1 then success on attempt 2 — confirms retry fires only on the exact 'treehouse get did not enter a worktree within 60s' signature and recoversScratch fake-script test simulating an unrelated deterministic failure — confirms no retry occurs, fails immediately (0s elapsed)Scratch fake-script test simulating persistent contention across all 3 attempts — confirms it retries exactly attempts-1 times then fails for good, matching the bounded-retry design✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.