test(media-library): restore imaging_kind CHECK width after db/30 in-place migration facts - #845
Merged
Merged
Conversation
…place migration facts
Root cause: NOT db/42 missing from DatabaseFixture — db/01-library.sh's fresh-init
mirror already carries the widened ('ad'-inclusive) media_imaging_kind_check, so the
fixture matches production. The real bug is test pollution: Gh149_ImagingKindAuthoredRows
.ScenarioInPlaceMigration drops library.media.imaging_kind and re-adds it via db/30 (the
original gh-#149 migration, whose CHECK predates 'ad'). DatabaseFixture is ONE Postgres
shared across the whole integration run, so this permanently narrows the CHECK for every
test that runs after it in the same collection — including ReadyMusicCountTests (T561),
whichever ran first depending on xUnit's (unordered) sequencing within the collection.
Reproduced locally by filtering Gh149+ReadyMusicCountTests together.
Fix: re-run db/42 (idempotent) right after db/30 in the two tests that drop the column,
restoring the shared schema to the fresh-init width before the next test can see it.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Root cause
Failing nightly run: 35973669093 (integration job) —
GenWave.MediaLibrary.Tests.ReadyMusicCountTests.GetReadyMusicCount_CountsReadyRowsWithNoImagingKindOnlyhit
23514: new row for relation "media" violates check constraint "media_imaging_kind_check".The dispatch hypothesis was that
DatabaseFixturedoesn't applydb/42-ads-migration.sh, so'ad'is rejected. Verified false:db/01-library.sh's own fresh-init mirror already carriesthe widened,
'ad'-inclusivemedia_imaging_kind_check— the fixture already matchesproduction on a fresh container.
The actual root cause is test pollution.
Gh149_ImagingKindAuthoredRows.ScenarioInPlaceMigrationhas two tests (
MigratingAPreGh149DatabaseAddsTheColumnWithNoBackfill,TheMigratedColumnAcceptsAuthoredInsertsImmediately) that droplibrary.media.imaging_kindandre-add it by running
db/30-imaging-kind-migration.sh— the original gh-#149 migration, whoseCHECK predates
'ad'(onlyliner/station_id/jingle/promo).DatabaseFixtureis onePostgres container shared across the entire integration run (
DatabaseCollection's own doccomment: "Shares one disposable database across all integration test classes"), so this
permanently narrows the CHECK constraint for every test that runs afterward in the same
collection, not just itself.
ReadyMusicCountTests(added in T561/ed6e570) is the first test inthe suite to insert an authored
'ad'-kind row, so it's the one that surfaces the long-standingisolation bug — and only when xUnit happens to schedule Gh149's migration tests first (unordered
within a collection), which is why the nightly is flaky-red rather than always-red.
Reproduced locally:
dotnet test tests/GenWave.MediaLibrary.Tests --filter "FullyQualifiedName~Gh149|FullyQualifiedName~ReadyMusicCountTests"fails with the exact same exception;
ReadyMusicCountTestsalone passes.Fix
Gh149_ImagingKindAuthoredRows.cs: after runningdb/30's narrow migration in the two teststhat drop the column, re-run
db/42-ads-migration.sh(idempotent; its station-schema half is ano-op here since db/06 already created those tables) to restore the shared schema to the
fresh-init CHECK width every other integration test in the collection assumes.
Verification
dotnet build GenWave.sln— 0 warnings, 0 errorsdotnet test tests/GenWave.MediaLibrary.Tests(full suite incl. Integration) — 1361 passed, 4 skipped, 0 failed