Skip to content

test: make board heartbeat checks deterministic - #4447

Merged
dgageot merged 1 commit into
mainfrom
test/board-heartbeat-synctest
Sep 24, 2026
Merged

dgageot merged 1 commit into
mainfrom
test/board-heartbeat-synctest

Conversation

@dgageot

@dgageot dgageot commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

The three pkg/board heartbeat 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 streamIdleTimeout that tests mutated directly, and drove the SSE stream over
a real Unix socket even when the behavior under test had nothing to do with
transport.

This converts TestStreamEventsIdleWatchdogAbortsSilentStream,
TestStreamEventsHeartbeatLinesResetWatchdog, and
TestStreamEventsNoHeartbeatNoWatchdog to Go 1.27's testing/synctest,
backed by httptest.NewTestServer instead of a live socket, so fake time
drives the heartbeat cadence and watchdog timeout instantly and
deterministically. streamIdleTimeout becomes a const now that no test
needs to shrink it, and the watchdog test asserts the exact 45-second timeout
boundary (streamIdleTimeout - time.Nanosecond still running,
streamIdleTimeout triggering errStreamIdle) instead of a shortened
stand-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 TestClientUnixSocket keeps a dedicated integration test that still
talks 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, and
the watchdog/heartbeat semantics in pkg/board/client.go are untouched aside
from the var to const conversion.

@dgageot
dgageot requested a review from a team as a code owner September 24, 2026 19:49
@aheritier aheritier added area/agent For work that has to do with the general agent loop/agentic features of the app kind/test Test-only changes labels Sep 24, 2026
@dgageot
dgageot added this pull request to the merge queue Sep 24, 2026
Merged via the queue into main with commit feca089 Sep 24, 2026
15 checks passed
@dgageot
dgageot deleted the test/board-heartbeat-synctest branch September 24, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent For work that has to do with the general agent loop/agentic features of the app kind/test Test-only changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants