Skip to content

test(app): wait for scheduler leadership before busy fire - #2635

Merged
jbeda merged 1 commit into
mainfrom
test/scheduler-native-readiness
Oct 31, 2026
Merged

jbeda merged 1 commit into
mainfrom
test/scheduler-native-readiness

Conversation

@jbeda

@jbeda jbeda commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fix the scheduler startup flake found while validating #2634.

Build starts scheduler leadership acquisition asynchronously. HasScheduler() proves the scheduler is wired, not that it has acquired the leader lease. The native-origin integration test could call FireNow during that startup window and get ErrScheduleNotLeader before reaching its intended busy-placement assertion.

  • Retry only server.ErrScheduleNotLeader, under a 10-second diagnostic deadline with a 1 ms polling interval.
  • Still require server.ErrPlacementChanged as the first non-leadership result. Success and all other errors fail immediately.
  • Keep the origin run registered throughout the readiness wait and preserve the existing assertions that a busy fire consumes no additional model turns.

Only internal/app/scheduler_native_test.go changes. No production retries, leadership changes, new helpers, or dependency changes.

Verification

  • Before the fix: go test -race ./internal/app -run '^TestBuiltSchedulerBorrowsNativeOriginAndPublishesEachFire$' -count=100 -cpu=1,2,4 -timeout=180s reproduced repeated ErrScheduleNotLeader failures.
  • After the fix: the same 300 race repetitions passed, along with 300 repetitions of neighboring TestMakeFireFuncReleasesSessionAfterLostNativeCommitResponse.
  • Negative control: temporarily draining and finishing the origin before the busy-fire assertion produced a successful fire and failed the assertion immediately. Reverted afterward.
  • task test passed (complete offline suite).
  • task lint passed.
  • task test:race passed (complete offline suite).
  • go run ./cmd/mecademo passed, including tool call, permission ask/approval, and result.
  • Focused independent synchronization/test-adequacy audit: no findings.

API compatibility

Test-only change. No wire, Go API, stored-data, or runtime behavior changes; no major/feature changes or upgrade implications.

Retry only the not-leader startup result before checking the native origin's exact busy-placement refusal. Keep the retry bounded and preserve model-call assertions.

Co-authored-by: Mecatl <[email protected]>
@jbeda
jbeda merged commit becb683 into main Oct 31, 2026
41 checks passed
@jbeda
jbeda deleted the test/scheduler-native-readiness branch October 31, 2026 22:12
@jbeda jbeda mentioned this pull request Oct 31, 2026
10 of 14 tasks
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Nov 18, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant