Skip to content

test: deflake the registration reaper and harden the Testcontainers fixtures - #233

Merged
windischb merged 2 commits into
developfrom
test/deflake-reaper-and-manifest-update
Sep 13, 2026
Merged

windischb merged 2 commits into
developfrom
test/deflake-reaper-and-manifest-update

Conversation

@windischb

Copy link
Copy Markdown
Contributor

Summary

Two tests in Modgud.Api.Tests were passing and failing without any relevant code change.

RegistrationPipelineTests.Reaper_erases_only_legacy_ghosts_and_only_when_not_dry_run — root cause fixed

The reaper ages a candidate by its stream's created stamp, which Marten leaves to the Postgres default now(), while the cutoff is DateTimeOffset.UtcNow. With olderThanDays: 0 the 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.

  • Backdate the ghost's stream in mt_streams by ten days (Marten offers no API for that stamp).
  • Run the reaper with the real seven-day window.
  • Add a just-created ghost with the same signature that must survive, so the test now also proves the age window is enforced.

RealmManifestApplierTests.Update_merges_in_place_keeping_ids_and_upserts_new_entities — not reproduced

Green 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

  • Reaper test: 10/10 standalone, full class 3/3 on the fixed branch.
  • Full ColdStart namespace: 5 + 2 passes on this branch (the one failure was the connect timeout above, before the timeout change).

🤖 Generated with Claude Code

windischb and others added 2 commits September 13, 2026 13:00
… 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>
@windischb
windischb merged commit 904ce40 into develop Sep 13, 2026
8 checks passed
@windischb
windischb deleted the test/deflake-reaper-and-manifest-update branch September 13, 2026 13:09
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