fix(api): deterministic seed for collaborator notification test (flaky on main)#943
Merged
Merged
Conversation
TestTrackCollaboratorNotificationsGenerated was flaky: the notification trigger's "new pending invite" branch fires only when created_at = updated_at (mirroring the ETL, which writes them equal on insert). seedCollaborators relied on the seed baseRow defaults, which call time.Now() twice — those round-trip equal through the timestamp column only when both calls land in the same microsecond, so the test passed or failed per CI run by luck. Pin a single timestamp for both columns in the seed so the invite notification always fires. Passes 5x in a row. Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.
Fixes the flaky
TestTrackCollaboratorNotificationsGeneratedfailing onmain.Root cause
The notification trigger's "new pending invite" branch fires only when
created_at = updated_at(this is how it tells a fresh ETL insert from a reconcile re-write — the ETL writes them equal on insert).seedCollaboratorsdidn't set those columns, so it inherited the seedbaseRowdefaults, which calltime.Now()twice:After the
timestampcolumn truncates to microseconds, those two calls are equal only if both landed in the same microsecond — a per-CI-run coin flip (the baseRow is a package var, initialized once). My local/isolated runs won the toss; CI lost it, so the trigger didn't fire and the test saw 0 notifications. (I'd earlier misattributed this to the unrelatedTestSearchElasticsearch panic — apologies.)Fix
Pin a single
nowfor bothcreated_atandupdated_atin the seed, so the invite branch always fires. Deterministic — passes 5× in a row locally, plus the full collaborator suite.Note
The shared
track_collaboratorsbaseRow indatabase/seed.gostill has the two-time.Now()default (latent, same asgrants); not touched here to keep the fix scoped, since the only seeder that depends on the equality is now explicit.🤖 Generated with Claude Code