Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

test(coderd/x/chatd): pin TestGetWorkspaceConn_StatusCheck to mock clock - #25130

#25130
Merged
ibetitsmike merged 1 commit into
maincoder/coder:mainfrom
mike/codagt-369-fix-chatd-status-check-flakecoder/coder:mike/codagt-369-fix-chatd-status-check-flakeCopy head branch name to clipboard
May 11, 2026
Merged

test(coderd/x/chatd): pin TestGetWorkspaceConn_StatusCheck to mock clock#25130
ibetitsmike merged 1 commit into
maincoder/coder:mainfrom
mike/codagt-369-fix-chatd-status-check-flakecoder/coder:mike/codagt-369-fix-chatd-status-check-flakeCopy head branch name to clipboard

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented May 11, 2026

Copy link
Copy Markdown
Collaborator

The TimedOutAgentCacheHit, CacheHitHealthyAgent, and CacheHitDBError subtests of TestGetWorkspaceConn_StatusCheck built their WorkspaceAgent timestamps with time.Now() in the parent test's slice literal and then ran the actual check against the server's real wall clock (quartz.NewReal()). On slow Windows CI runners, more than agentInactiveDisconnectTimeout (30s) of wall time can elapse between slice construction and the parallel subtest body. In that window, the cached "healthy" agent gets reclassified as disconnected by agentDisconnectedFor, and CacheHitHealthyAgent fails with errChatAgentDisconnected instead of returning the cached connection.

Build each agent inside the subtest with quartz.NewMock(t) and feed the same clock into the Server so the agent timestamps and the status math share a single frozen now. This matches the pattern already used by TestGetWorkspaceConn_DialTimeoutDisconnectedRecoveryThreshold in the same file.

Closes coder/internal#1522

Verification

Inserting time.Sleep(35 * time.Second) at the top of each subtest's body reliably reproduces the original failure (errChatAgentDisconnected on CacheHitHealthyAgent) on the parent commit and passes with this change. After removing the synthetic sleep, go test ./coderd/x/chatd -run TestGetWorkspaceConn_StatusCheck -count=50 passes cleanly.

Generated by Coder Agents on behalf of the assignee.

The TimedOutAgentCacheHit, CacheHitHealthyAgent, and CacheHitDBError
subtests built their WorkspaceAgent timestamps with time.Now() in the
test slice literal and then ran the actual check against the server's
real wall clock. On slow runners, more than agentInactiveDisconnectTimeout
(30s) of wall time could elapse between slice construction and the
subtest body, so the cached agent was reclassified as disconnected and
CacheHitHealthyAgent failed with errChatAgentDisconnected.

Build each agent inside the subtest with quartz.NewMock(t) and feed the
same clock into the Server so the agent timestamps and status math share
one frozen now.

Reproducing the flake by inserting a 35s sleep at the top of the subtest
body reliably triggers the original failure on the parent commit and is
fixed by this change.

Closes coder/internal#1522

Co-authored-by: Coder Agents <noreply@coder.com>
ibetitsmike added a commit that referenced this pull request May 11, 2026
…ies (#25141)

PR bodies copied from a commit message body keep their 72/80-column hard
wraps, and GitHub renders those as ragged-right line breaks instead of
soft-wrapped paragraphs (e.g. the original body of #25130, fixed in this
branch).

The rule already exists in `.claude/docs/PR_STYLE_GUIDE.md`, but it is
buried in a 200-line style guide and easy to miss when an agent is
mechanically running `gh pr create`. This change adds a short "Body
Formatting" section directly to `.agents/skills/pull-requests/SKILL.md`,
which is the proximate context loaded at PR-write time, and explicitly
tells callers to unwrap commit-message paragraphs before reusing them as
a PR body.

> Generated by Coder Agents on behalf of the assignee.
@ibetitsmike
ibetitsmike marked this pull request as ready for review May 11, 2026 17:53
@ibetitsmike
ibetitsmike merged commit 6bb8877 into main May 11, 2026
59 of 62 checks passed
@ibetitsmike
ibetitsmike deleted the mike/codagt-369-fix-chatd-status-check-flake branch May 11, 2026 17:54
@github-actions github-actions Bot locked and limited conversation to collaborators May 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flake: TestGetWorkspaceConn_StatusCheck (CacheHitHealthyAgent)

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.