Skip to content

test: the consumer smoke test, as a script and a lane behind the CI gate - #136

Merged
CaffeinatedCoder merged 2 commits into
mainfrom
test/consumer-smoke-test
Nov 14, 2026
Merged

CaffeinatedCoder merged 2 commits into
mainfrom
test/consumer-smoke-test

Conversation

@CaffeinatedCoder

@CaffeinatedCoder CaffeinatedCoder commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Closes #34

Problem

Nothing ran the packages as a consumer gets them. The unit tests build the differ in process and the live tests apply operations the differ already produced; spike B drove the real dotnet ef, but against a stand-in kit. A lost registration or a path that drops the declaration (a pooled context, a compiled model, a factory with a migrations assembly of its own, a project coming from 5.x) would scaffold and apply cleanly, and the database would not enforce the constraint.

Change

  • test/ConsumerSmokeTest/run.sh. It packs both packages, or with a folder argument (or SCHEMAKIT_PACKAGES) tests packages that were packed before; those are the two invocation modes of the 5.x script. It copies the consumers to a temporary folder outside the repository and copies global.json in. Restores go through a private NUGET_PACKAGES and a nuget.config with source mapping: CodoMetis.* from the feed, everything else from nuget.org. The pack runs before the private cache is set, so both modes restore the consumer into an empty cache. Versions come from the packed nuspecs: EF Core from the kernel's dependency, Npgsql EF from the PostgreSQL package's, and dotnet-ef at EF Core's version as a local tool. It fails fast, prints the failing path's name and log, and drops every database it created on exit.
  • App/ is the consumer: one entity, one exclusion constraint declared with DeclarePostgres and a lambda condition (x => x.CancelledOn == null), wired with UseNpgsql(cs, o => o.UseSchemaKit()) inside a host. SMOKE_REGISTRATION switches it between AddDbContext, AddDbContextPool and AddDbContextFactory.
  • Split/: a context in Data, and an IDesignTimeDbContextFactory with the migrations in Data.Migrations.
  • Legacy/: the fixture's three 5.6.0 files, copied as they are into Migrations/, with the same constraints declared with SchemaKit (the model of MovedModels.Declared).
  • Judge/ references Npgsql and nothing else, so the code that judges a path shares nothing with the path. It reads every exclusion constraint from pg_constraint and btree_gist from pg_extension. Then it inserts a first booking, an overlapping one that must be refused with 23P01, and an overlapping cancelled one that must be accepted. It also applies generated scripts to an empty database.
  • Shared/Wiring.cs holds the registration and the three removals.
  • .github/workflows/dotnet.yml: a smoke job with PostgreSQL 16 (the script packs) and 18 (packages packed beforehand, as release.yml packs them). It has the same image digest and version check as the integration lane, uploads the logs when it fails, and is in the CI gate's needs.
  • CLAUDE.md: the folder in the table and the command.

Locally a run takes about 50 s on either server, the pack included (Apple silicon, warm SDK). On GitHub's runners the script takes 108 s (PostgreSQL 16, packing) and 94 s (18, packed beforehand), and each job takes 2m9s / 2m22s with setup. Both are shorter than the Spikes lane (3m11s). The duration is written to the job summary.

Tests

The paths (both servers, both modes: 46 rows, every one ok)

Path Judged by Result
restore the private cache holds the feed's 11.0.0-preview.1 ok
migrations add the migration has the table, btree_gist and the constraint ok
migrations add, nothing changed an empty Up and Down ok
migrations remove the file is gone, the snapshot is byte-equal to before ok
has-pending-model-changes no changes; with the condition removed it reports the change ok
database update, then to 0, then up again catalog + 23P01 / the table and constraint gone / catalog + 23P01 ok
migrations script, applied to an empty database catalog + 23P01 ok
migrations script --idempotent, applied twice catalog + 23P01 ok
migrations bundle, run catalog + 23P01 ok
Database.Migrate(), Database.EnsureCreated() catalog + 23P01 ok
AddDbContextPool → Migrate(), AddDbContextFactory → EnsureCreated() catalog + 23P01 ok
has-pending-model-changes through the pool and the factory no changes ok
dbcontext optimize the generated model holds the stamp and the declaration ok
the context runs on Shop.CompiledModels.ShopContextModel context.Model's type ok
compiled model: Migrate(), EnsureCreated(), pool, factory, database update catalog + 23P01 ok
compiled model: has-pending-model-changes, migrations add no changes, empty ok
design-time factory, migrations in Data.Migrations: add, add again, remove, database update the constraint is in Data.Migrations; empty; gone; catalog + 23P01 ok
5.x: has-pending-model-changes on 5.x's snapshot no changes ok
5.x: migrations add empty; the snapshot now holds CodoMetis:Pg.Exclusion:* and no CustomExclusion:Constraints ok
5.x: migrations remove gone; the snapshot holds 5.x's annotations again ok
5.x: migrations add after the remove empty again ok
5.x: a new column, migrations add Up AddColumn, Down DropColumn, nothing else ok
5.x: database update (5.x's migration and the two after it) the five constraints by their catalog text, an overlapping booking refused with 23P01 ok
5.x: database update Moved (the Down of the column), migrations remove, has-pending-model-changes the five constraints stay; gone; no changes ok
judged on PostgreSQL 16.15 (Debian 16.15-1.pgdg13+2), through Npgsql 10.0.3
Every path behaved as expected (50 s).
judged on PostgreSQL 18.6 (Debian 18.6-1.pgdg13+2), through Npgsql 10.0.3
Every path behaved as expected (49 s).

The removals

Rows inside every run assert two refusals by their message and run one control:

  ok    no UseSchemaKit(): migrations add                    refused: …UseSchemaKit() is not on this context's options…
  ok    no UseSchemaKit(): EnsureCreated()                   refused: …UseSchemaKit() is not on this context's options…
  ok    the kernel's UseSchemaKit() alone: migrations add    refused: …no contributor with that owner is registered…
  ok    the kernel's UseSchemaKit() alone: EnsureCreated()   refused: …no contributor with that owner is registered…
  ok    compiled model, no UseSchemaKit(): EnsureCreated()   refused: …UseSchemaKit() is not on this context's options…
  ok    control: the consumer's own differ                   SILENT, as known: the table without the constraint, the overlap accepted

SMOKE_BREAK applies each removal to every path that expects SchemaKit. I ran each one against the packages packed beforehand on PostgreSQL 16, and each makes the run fail at its first such path:

1. SMOKE_BREAK=no-schemakit (no UseSchemaKit())

  FAIL  migrations add
        the migration does not create the constraint
        --- …/logs/010-ef-migrations-add.txt (last 40 lines)
        Unable to create a 'DbContext' of type 'ShopContext'. The exception 'Booking declares a SchemaKit object, but UseSchemaKit() is not on this context's options. Without it the declaration would be left out of migrations and of EnsureCreated() without an error. Add UseSchemaKit() where the context's options are built, including in an IDesignTimeDbContextFactory.' was thrown while attempting to create an instance. …
The consumer smoke test failed at: migrations add (6 s)
exit 1

2. SMOKE_BREAK=kernel-only (UseNpgsql(cs).UseSchemaKit(), the kernel's method on the outer builder)

  FAIL  migrations add
        the migration does not create the constraint
        --- …/logs/010-ef-migrations-add.txt (last 40 lines)
        System.InvalidOperationException: Booking carries a declaration of 'Pg.Exclusion', and no contributor with that owner is registered. The declaration would be left out of every migration without an error. Add the package that declares it to the context's options.
           at CodoMetis.EFCore.SchemaKit.Migrations.Internal.SchemaOperationPlanner.Resolve(IRelationalModel model)
           at …SchemaKitModelDiffer.GetDifferences(IRelationalModel source, IRelationalModel target)
           at Microsoft.EntityFrameworkCore.Migrations.Design.MigrationsScaffolder.ScaffoldMigration(…)
The consumer smoke test failed at: migrations add (7 s)
exit 1

3. SMOKE_BREAK=user-differ (the consumer's own IDesignTimeServices registers EF Core's MigrationsModelDiffer)

  FAIL  migrations add
        the migration does not create the constraint
        --- …/logs/010-ef-migrations-add.txt (last 40 lines)
        Done. To undo this action, use 'ef migrations remove'
The consumer smoke test failed at: migrations add (7 s)
exit 1

Here dotnet ef reports success. Only the content of the migration catches it. The control row in every green run shows that the database check catches it as well: CONSTRAINTS: none, OVERLAP: accepted.

After each failing run the databases were dropped (pg_database holds no sksmoke_*), and ~/.nuget/packages holds no codometis.efcore.schemakit*.

What a path showed that the repository's tests do not hold

  • migrations remove after the first migration of a 5.x project writes 5.x's annotations back into the snapshot. EF Core rebuilds the snapshot from the target model of 5.x's migration, so CustomExclusion:Constraints comes back, now with ProductVersion 11. The next migrations add is empty again, so the legacy reader holds there too. The first migration after the move from 5.x cannot be scaffolded when it changes anything: EF Core diffs Down with the snapshot as the target #98's tests diff the fixture at the differ's entry points; this is the first time the tool itself ran the round trip.
  • Through the tool, 5.x's migration, the empty one and a new column apply on top of each other on a live server, and the five constraints keep their catalog text.
  • With the kernel's UseSchemaKit() alone, EnsureCreated() creates the database before it refuses, which leaves an empty database behind. Without UseSchemaKit() it refuses before creating anything. This is EF Core's order (the database first, then the diff), and the refusal is still loud.
  • The kernel-only refusal tells the consumer to "add the package that declares it", which they already reference. The call that is missing is the provider's UseSchemaKit(). Consumer smoke test: remove each registration in turn #34's comment of 2026-11-14 noted this; the test asserts the current wording only by the stable part, "no contributor with that owner is registered".

Decisions in this PR that are not confirmed

  • One server per run, SCHEMAKIT_TEST_PG, the integration tests' variable, rather than two variables for 16 and 18 in one run. Locally the script is run once per server; CI's matrix does one each.
  • The two modes are split across the two servers (16 packs in the script, 18 tests packages packed beforehand) instead of running all four combinations, to keep the lane at two jobs.
  • release.yml does not run the smoke test on dist/ yet. It calls dotnet.yml, whose lane tests a fresh pack of the same commit. 5.x also runs it on the release's own dist/; that needs a PostgreSQL service in verify and is left for a follow-up.
  • The scaffolded migration's text is read in two places only: whether a migration is empty or holds just the new column, and the first migrations add, which fails with a clear message before the database is asked. Every other result is the database's.
  • SMOKE_BREAK is a switch inside the test. It exists to show that the test fails without each registration. It is not run in CI.
  • Spike B is left as it is. Retiring it is a later step.
  • Wiring.cs disables EF1001 to register EF Core's internal MigrationsModelDiffer. The control has to do that, as a consumer who registers it would.

🤖 Generated with Claude Code

test/ConsumerSmokeTest/run.sh packs both packages (or takes a folder of them), restores them into
consumers outside the repository through a private package cache and source mapping, and drives
every path a consumer has through the real dotnet-ef and runtime on a live PostgreSQL: migrations
add, remove, has-pending-model-changes, database update down to 0 and up, both scripts applied,
the bundle, Migrate(), EnsureCreated(), a pooled context, a context factory, a design-time factory
with its own migrations assembly, the compiled model, and a project that comes from 5.x with the
snapshot and migration 5.6.0 scaffolded. Each path is judged by Judge/, which reads pg_constraint
and inserts an overlapping row that must be refused with 23P01.

Without UseSchemaKit(), and with the kernel's UseSchemaKit() alone, the refusals are asserted by
message; a consumer's own IDesignTimeServices differ is the control, where the same check sees the
constraint missing. SMOKE_BREAK applies each removal to the whole run and makes it fail.

The lane runs on PostgreSQL 16 (packing in the script) and 18 (packages packed beforehand), and
the CI gate needs it.

Closes #34

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 11.0.0 milestone Nov 14, 2026
@CaffeinatedCoder CaffeinatedCoder added tests Adds or changes tests only (harnesses, parity suites); no library code package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) area/release Versioning, changelogs, release wiring labels Nov 14, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 3b821b4 into main Nov 14, 2026
9 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the test/consumer-smoke-test branch November 14, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/release Versioning, changelogs, release wiring package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) tests Adds or changes tests only (harnesses, parity suites); no library code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consumer smoke test: remove each registration in turn

1 participant