Repository navigation
test(notifications): wait for the dispatch event, not the fake transport - #1587
Merged
Merged
Conversation
TestDispatchReachesEveryInstalledPublisher failed on master at 851eaee with "sent = 0, want 1". It reproduces on unmodified origin/master, about 2 times in 3,000 runs of the test alone. The test waited until both fake transports held the message, then read Status().Sent. deliver counts a dispatch as sent only after the last transport has returned and a log line has been written, so a goroutine that reads in that window sees 0. The service is right: it cannot count a send before the sends are done. The test waited on the wrong signal. TestNothingToSendIsNotAFailure had the same flaw. Both tests now wait for the notifications.dispatched event, which deliver emits after it moves the counter, and then read Status(). They also check that each transport got exactly one message; the old wait accepted one or more. With a 50 ms sleep between the last Publish and bumpSent (not committed), both old tests fail on every run with the CI message, and both new tests pass, with and without -race. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
TestDispatchReachesEveryInstalledPublisherfailed on master at851eaee0(#1582) withsent = 0, want 1. It passed ataf22b488and on #1582's own CI.Cause
Not #1582. The test is timing-sensitive and fails by chance.
notificationsimports, apart from one_test.gofile instate. The failure reproduces on unmodifiedorigin/master: 2 failures in 3,000 runs of the test alone, and 1 in 300 in each of the plain and-raceruns together with its neighbour.Status().Sent.deliverbumps that counter only after the last transport has returned and a log line is written. A goroutine that reads in that gap sees 0.TestNothingToSendIsNotAFailurehas the same flaw and the same fix.Proof: with a 50 ms sleep between the last
PublishandbumpSent(not in this PR), both old tests fail on every run with the CI message. Both new tests pass with that sleep, with and without-race.Change
Tests only, in
service_push_test.go.notifications.dispatched.deliveremits it after it moves the counter, soStatus()is final once it arrives.Status().No change to
service.go. K5 (push notifications) builds on this package and can rely on the tests.No changeset: no shipped code changes. Labelled
no-changeset, as #1097, #1107 and #1119 were.Test evidence
Run in a worktree from
origin/master:TestDispatchReachesEveryInstalledPublisherand 400 runs ofTestNothingToSendIsNotAFailure, plain and-race: 0 failures.-count=20, plain and-race: pass.go test -race -count=5 ./internal/notifications: pass.go vetandgofmtclean.make verify: pass ("verify: vet + test + build clean", exit 0).🤖 Generated with Claude Code