Repository navigation
test(coderd/x/chatd): make the zero wait timeout test reach the default - #30985
ibetitsmike wants to merge 2 commits into
Conversation
ZeroTimeoutUsesDefault marked the child chat waiting before it called awaitSubagentCompletion with a zero timeout, so the call returned before it normalized the timeout and the test passed with the normalization deleted. Delete it and turn the Timeout subtest into a two-row table that checks the trapped subagent_await timer's duration (1s explicit, 5m for zero) before advancing the mock clock to the timeout.
|
@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. |
|
Codex Review: Didn't find any major issues. What shall we delve into next? 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". |
…o mike/chatd-subagent-await-timeout-test
|
@codex review
|
|
Codex Review: Didn't find any major issues. You're on a roll. 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". |
ZeroTimeoutUsesDefaultpassed a zero timeout toawaitSubagentCompletion, but it marked the child chatwaitingfirst, so the call returned before it normalized the timeout. The test passed with the normalization deleted. This PR deletes it and turns theTimeoutsubtest into a two-row table,Explicit(1 s) andZeroUsesDefault(0, which must become 5 minutes). Each row checks the duration of the trappedsubagent_awaittimer, then advances the mock clock until the call times out.Why it is safe
Mutants, applied with
go test -overlaytoTestAwaitSubagentCompletion:if timeout <= 0 { timeout = defaultSubagentWaitTimeout }ZeroUsesDefaultfails:0s, want5m0sdefaultSubagentWaitTimeout = 1 * time.MinuteZeroUsesDefaultfails:1m0s, want5m0sTimeoutfails after 25 sExplicitfails:5m0s, want1sZeroUsesDefaultexpects5 * time.Minuterather than the constant, so it also pins thewait_agentschema text "Defaults to 5 minutes." The deleted subtest's assertions (no error, the child's ID, its report) duplicateAlreadyWaiting, which runs the same early-return path. WithhandleSubagentDonemutated to return an error, an empty chat, or an empty report,AlreadyWaitingfails each time.Review focus
The clock moves in steps of at most 5 s, because the pubsub fallback poll ticks every 5 s and the mock clock cannot advance past a pending tick in one step. The zero row takes 60 steps and runs in about 0.2 s.
Validation
go test ./coderd/x/chatd/ -run '^TestAwaitSubagentCompletion$' -count=1: pass.go test ./coderd/x/chatd/ -race -run '^TestAwaitSubagentCompletion$/^Timeout$' -count=20: pass.subagent_manager.gowith a syntax error fails to build, so the overlay applies.make pre-commit) passed.Stack
This PR is stacked on #28758, which moves
awaitSubagentCompletionintosubagent_manager.go.