Repository navigation
test(coderd): make the chatd idle wait fail on timeout - #30967
ibetitsmike wants to merge 3 commits into
Conversation
WaitUntilIdleForTest waited up to 10 seconds for the chat worker to go idle, dropped the timeout error, and then drained tracked work, so a test whose worker never went idle passed after a silent stall. It now takes the caller's context and returns an error when the context ends first. Its 26 callers wrap it in require.NoError. Move the poll loop from chatWorker.WaitIdle, whose only caller was the hook, into testhooks.go. It polls on a real ticker instead of the server clock, which a mock clock never advances.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9e894c22a1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
WaitUntilIdleForTest returned an error when ctx ended before the chat worker went idle, but it then drained tracked work with no bound, so a stalled title or summary call held it past the caller's deadline. Run the drain in a goroutine and return ctx's error if ctx ends first.
|
@codex review
|
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
chatd.WaitUntilIdleForTestwaited up to 10 seconds for the chat worker to go idle, dropped the timeout error, and then drained tracked work, so a test whose worker never went idle passed after a silent 10-second stall. The hook now takes the caller'sctxand returns an error whenctxends before the worker is idle or the tracked work finishes. Its 26 callers wrap it inrequire.NoError. The poll loop moves fromchatWorker.WaitIdle, whose only caller was the hook, intotesthooks.go. It polls on a real 10 ms ticker instead of the server clock, which a mock clock never advances.Why it is safe
drainInflight, now in a goroutine so thatctxbounds it; that goroutine exits onceClosecancels the tracked work.runnerManager.idleforced to returnfalse,TestCreateChatImmediatelyProcessesNewChatpasses onmainafter 10.2 s and fails on this branch at its 25 s context withwait for the chat worker to go idle: context deadline exceeded.nil. It now returnswait for tracked chat work to finish: context deadline exceededat 100 ms.main, with the hook instrumented to report errors and idle waits over 1 s, all 119 hook calls in the packages below returned in under 1 s without an error. The runs below pass with the bounded drain, so no test needed a fix.git grep WaitIdlefinds no other caller.Review focus
Callers now pass their own test context instead of getting a fresh 10 s one. Every direct caller, and every caller of
coderdtest.WaitForChatSettledandwaitForChatProcessed, passes a context oftestutil.WaitLongor longer, so the budget grows, but the rest of the test shares it.The goroutine around the drain adds 9 lines, so this PR adds 7 more lines than it removes. Without it, a stalled title or summary call holds the hook past its deadline.
Validation
go test ./coderd/x/chatd/ -count=3: pass.go test ./coderd/ -count=3 -run '<every test in exp_chats_test.go, exp_chats_workspace_file_test.go, and exp_chats_hooks_test.go>': pass.go test ./codersdk/toolsdk/ -count=3 -run '^(TestChatTools|TestCreateChatOrganizationDefaultModel)$': pass.go test -overlay; a copy with a syntax error fails to build, so the overlay applies.make pre-commit) passed.