Skip to content

test(media-library): restore imaging_kind CHECK width after db/30 in-place migration facts - #845

Merged
genwave-radio merged 1 commit into
mainfrom
fix/nightly-ready-music-count
Sep 24, 2026
Merged

genwave-radio merged 1 commit into
mainfrom
fix/nightly-ready-music-count

Conversation

@genwave-radio

Copy link
Copy Markdown
Collaborator

Root cause

Failing nightly run: 35973669093 (integration job) —
GenWave.MediaLibrary.Tests.ReadyMusicCountTests.GetReadyMusicCount_CountsReadyRowsWithNoImagingKindOnly
hit 23514: new row for relation "media" violates check constraint "media_imaging_kind_check".

The dispatch hypothesis was that DatabaseFixture doesn't apply db/42-ads-migration.sh, so
'ad' is rejected. Verified false: db/01-library.sh's own fresh-init mirror already carries
the widened, 'ad'-inclusive media_imaging_kind_check — the fixture already matches
production on a fresh container.

The actual root cause is test pollution. Gh149_ImagingKindAuthoredRows.ScenarioInPlaceMigration
has two tests (MigratingAPreGh149DatabaseAddsTheColumnWithNoBackfill,
TheMigratedColumnAcceptsAuthoredInsertsImmediately) that drop library.media.imaging_kind and
re-add it by running db/30-imaging-kind-migration.sh — the original gh-#149 migration, whose
CHECK predates 'ad' (only liner/station_id/jingle/promo). DatabaseFixture is one
Postgres container shared across the entire integration run (DatabaseCollection's own doc
comment: "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 in
the suite to insert an authored 'ad'-kind row, so it's the one that surfaces the long-standing
isolation 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; ReadyMusicCountTests alone passes.

Fix

Gh149_ImagingKindAuthoredRows.cs: after running db/30's narrow migration in the two tests
that drop the column, re-run db/42-ads-migration.sh (idempotent; its station-schema half is a
no-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 errors
  • dotnet test tests/GenWave.MediaLibrary.Tests (full suite incl. Integration) — 1361 passed, 4 skipped, 0 failed

…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.
@genwave-radio
genwave-radio merged commit 5c23b46 into main Sep 24, 2026
11 checks passed
@genwave-radio
genwave-radio deleted the fix/nightly-ready-music-count branch September 24, 2026 13:53
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant