test: make board heartbeat checks deterministic - #4447
Merged
Merged
Conversation
aheritier
approved these changes
Sep 24, 2026
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.
The three
pkg/boardheartbeat tests slept in real time (50ms, 250ms, 120ms)to exercise the idle watchdog and cadence-reset logic, so they were slow and
prone to flaking under load. They also relied on a package-level
var streamIdleTimeoutthat tests mutated directly, and drove the SSE stream overa real Unix socket even when the behavior under test had nothing to do with
transport.
This converts
TestStreamEventsIdleWatchdogAbortsSilentStream,TestStreamEventsHeartbeatLinesResetWatchdog, andTestStreamEventsNoHeartbeatNoWatchdogto Go 1.27'stesting/synctest,backed by
httptest.NewTestServerinstead of a live socket, so fake timedrives the heartbeat cadence and watchdog timeout instantly and
deterministically.
streamIdleTimeoutbecomes aconstnow that no testneeds to shrink it, and the watchdog test asserts the exact 45-second timeout
boundary (
streamIdleTimeout - time.Nanosecondstill running,streamIdleTimeouttriggeringerrStreamIdle) instead of a shortenedstand-in value. The heartbeat-cadence test now waits out all six 15-second
pings, the production interval, and asserts the resulting 90-second elapsed
duration.
A new
TestClientUnixSocketkeeps a dedicated integration test that stilltalks to the client over a real Unix socket, since none of the synctest
conversions above exercise that transport anymore.
No production behavior changes:
streamIdleTimeout's value is unchanged, andthe watchdog/heartbeat semantics in
pkg/board/client.goare untouched asidefrom the
vartoconstconversion.