Skip to content

test(coderd/nats): use a random cluster port in TestPubsub/CloseIdempotent - #31056

Merged
ibetitsmike merged 1 commit into
mainfrom
mike/nats-test-random-cluster-port
Oct 20, 2026
Merged

ibetitsmike merged 1 commit into
mainfrom
mike/nats-test-random-cluster-port

Conversation

@ibetitsmike

Copy link
Copy Markdown
Collaborator

TestPubsub/CloseIdempotent in coderd/nats flakes in CI with "embedded nats server not ready within 10s" (for example in test-go-pg-17 on main).

It is the only subtest that calls nats.New with nats.Options{} directly. With ClusterPort unset, buildServerOptions falls back to the fixed production cluster port 6222. Test packages run in parallel, and cli TestServer/SpammyLogs runs coder server --cluster-host 127.0.0.1, which holds 127.0.0.1:6222. When the route listener cannot bind, nats-server logs nothing under NoLog, and ReadyForConnections waits out the 10 s readyTimeout.

The fix gives the subtest ClusterPort: natsserver.RANDOM_PORT, the option the newPubsub helper already sets for every other subtest. It is a one-line, test-only change.

Testing

  • Red on the merge base: with 127.0.0.1:6222 held by a plain listener, TestPubsub/CloseIdempotent fails after 10.01 s with the CI message.
  • Green on this branch: with the port held, go test ./coderd/nats/... passes.
  • go test ./coderd/nats/... -count=3 and make pre-commit pass.
  • Remote dogfood UAT ran on the tested SHA 451c4ec and passed. It repeated red and green with 127.0.0.1:6222 and 0.0.0.0:6222 held, ran -count=5 with no port held, and showed that an overlay whose second Close returns an error makes the subtest fail, so it still checks idempotent Close.

Polish and the test audit made no changes, so both stayed inside the implementation diff (coderd/nats/pubsub_test.go).

Draft #30759 carries the same one-line edit as a drive-by, so whichever lands second merges cleanly.

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

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum, an AI agent, requested this review for @ibetitsmike.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 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-20T17:45:00.200598Z 451c4ec Draft marked ready
ℹ️ 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. 🚀

Reviewed commit: 451c4ecd16

ℹ️ 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
ibetitsmike marked this pull request as ready for review October 20, 2026 17:43
@ibetitsmike
ibetitsmike enabled auto-merge (squash) October 20, 2026 17:47
@ibetitsmike
ibetitsmike merged commit 90a8d51 into main Oct 20, 2026
57 of 58 checks passed
@ibetitsmike
ibetitsmike deleted the mike/nats-test-random-cluster-port branch October 20, 2026 17:50
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 20, 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.

2 participants