Skip to content

test(coderd): share one server across the chat message pagination tests - #30965

Draft
ibetitsmike wants to merge 2 commits into
mainfrom
mike/coderd-chat-pagination-fixture
Draft

ibetitsmike wants to merge 2 commits into
mainfrom
mike/coderd-chat-pagination-fixture

Conversation

@ibetitsmike

Copy link
Copy Markdown
Collaborator

TestGetChatMessages_Pagination started a coderd server with its own database in each of its ten leaves, although the leaves differ only in cursors and their own chat rows. This PR builds the client, database, owner, and chat model once in the parent. The six successful-page leaves become one table (options, expected ID positions, HasMore, queued count), and the two malformed after_id leaves become another. The transposed or equal cursor case and the burst walk stay separate subtests, and every subtest keeps its name.

Why it is safe: every leaf still creates its own chat, messages, and queued message, and every request and query is scoped to that chat. No leaf changes users, roles, models, or deployment values. I ran 24 mutants of getChatMessages and its two paginated queries (limit+1 and HasMore, truncation, ASC dispatch, queued suppression, after_id parsing, the transposed check, cursor comparison, and ordering) against the old and the new test with go test -overlay. The new test fails on all 20 mutants that the old test fails on, in the same leaves. It also fails on the two mutants that drop the chat_id filter, which the old test missed because each leaf had its own database. Two mutants survive both tests: the DESC path fetching limit rows instead of limit+1, and HasMore using >=. No test on main covers them, and this PR does not add coverage.

Review focus: the shared database interleaves message IDs across leaves. Assertions use only the IDs that each leaf's seedChat returned, so interleaving cannot change a result for a correct handler. AfterIDAtOrAboveMaxReturnsEmpty now seeds five messages instead of three, like the other page cases, and still sets after_id to the last ID.

Timing (prebuilt test binaries, -test.parallel 4, median of 5 alternating runs on a shared host): binary wall time went from 1.21 s to 0.72 s. Leaf times summed went from 3.89 s to 0.39 s, plus 0.48 s for the one shared server, and coderd boots went from 10 to 1.

Validation:

  • go test ./coderd -run '^TestGetChatMessages_Pagination$' -count=10: pass
  • the same run with -race -count=2: pass
  • go vet ./coderd and golangci-lint run ./coderd/...: clean; the pre-commit hook passed

Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description.

TestGetChatMessages_Pagination started a coderd server with its own
database in each of its ten leaves. Build the server, owner, and chat
model once in the parent, merge the six successful-page leaves and the
two malformed after_id leaves into two tables, and keep the transposed
cursor and burst walk subtests. Each leaf still seeds its own chat.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T17:19:19.838254Z 6a94c63 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 1f50ae932d

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum, an AI agent, posted this comment for @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 6a94c63b45

ℹ️ 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".

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant