test: deflake the registration reaper and harden the Testcontainers fixtures - #233
Merged
Merged
Conversation
… the test's The reaper ages a candidate by its stream's `created` stamp, which Marten leaves to Postgres (`now()`), while the cutoff comes from the process clock. With `olderThanDays: 0` the test compared the two at zero margin, so a Docker VM clock a second ahead of Windows made it miss the ghost in streaks. Backdate the ghost's stream in `mt_streams` by ten days, run the reaper with the real seven-day window, and add a just-created ghost that must survive it, so the test now also proves the age window is enforced. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Booting a host per test opens fresh connections through Docker Desktop's published-port proxy while other containers may be starting or stopping. A TCP connect that stalls past Npgsql's 15 s default surfaced once in ten full ColdStart runs as "Timeout during connection attempt" during ApplyAllConfiguredChangesToDatabaseAsync and failed an unrelated test. Realm databases derive their connection strings from the fixture's, so the setting reaches every database the suites touch. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Summary
Two tests in
Modgud.Api.Testswere passing and failing without any relevant code change.RegistrationPipelineTests.Reaper_erases_only_legacy_ghosts_and_only_when_not_dry_run— root cause fixedThe reaper ages a candidate by its stream's
createdstamp, which Marten leaves to the Postgres defaultnow(), while the cutoff isDateTimeOffset.UtcNow. WitholderThanDays: 0the test compared the Docker VM clock against the host clock at zero margin, so a VM clock a second ahead of Windows made it miss the ghost in streaks.mt_streamsby ten days (Marten offers no API for that stamp).RealmManifestApplierTests.Update_merges_in_place_keeping_ids_and_upserts_new_entities— not reproducedGreen in 10 consecutive full ColdStart runs. Isolated DB per test, non-parallel collection, inline projections only, ~10/500 connections, no relevant process-wide statics. The one ColdStart failure observed in those runs was a different test failing at isolated-host boot with a raw TCP connect timeout to the Testcontainers port at Npgsql's 15 s default, while other test containers were starting and stopping. The fixtures now set a 60 s connect timeout; realm databases derive their connection strings from the fixture's, so it reaches them too.
Verification
🤖 Generated with Claude Code