Repository navigation
test: the consumer smoke test, as a script and a lane behind the CI gate - #136
Merged
Merged
Conversation
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]>
…s table stay Co-Authored-By: Claude Fable 5.2 <[email protected]>
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.
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 (orSCHEMAKIT_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 copiesglobal.jsonin. Restores go through a privateNUGET_PACKAGESand anuget.configwith 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, anddotnet-efat 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 withDeclarePostgresand a lambda condition (x => x.CancelledOn == null), wired withUseNpgsql(cs, o => o.UseSchemaKit())inside a host.SMOKE_REGISTRATIONswitches it betweenAddDbContext,AddDbContextPoolandAddDbContextFactory.Split/: a context inData, and anIDesignTimeDbContextFactorywith the migrations inData.Migrations.Legacy/: the fixture's three 5.6.0 files, copied as they are intoMigrations/, with the same constraints declared with SchemaKit (the model ofMovedModels.Declared).Judge/references Npgsql and nothing else, so the code that judges a path shares nothing with the path. It reads every exclusion constraint frompg_constraintandbtree_gistfrompg_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.csholds the registration and the three removals..github/workflows/dotnet.yml: asmokejob with PostgreSQL 16 (the script packs) and 18 (packages packed beforehand, asrelease.ymlpacks them). It has the same image digest and version check as the integration lane, uploads the logs when it fails, and is in theCIgate'sneeds.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)
migrations addbtree_gistand the constraintmigrations add, nothing changedmigrations removehas-pending-model-changesdatabase update, then to0, then up againmigrations script, applied to an empty databasemigrations script --idempotent, applied twicemigrations bundle, runDatabase.Migrate(),Database.EnsureCreated()AddDbContextPool→Migrate(),AddDbContextFactory→EnsureCreated()has-pending-model-changesthrough the pool and the factorydbcontext optimizeShop.CompiledModels.ShopContextModelcontext.Model's typeMigrate(),EnsureCreated(), pool, factory,database updatehas-pending-model-changes,migrations addData.Migrations: add, add again, remove,database updateData.Migrations; empty; gone; catalog + 23P01has-pending-model-changeson 5.x's snapshotmigrations addCodoMetis:Pg.Exclusion:*and noCustomExclusion:Constraintsmigrations removemigrations addafter the removemigrations addAddColumn, DownDropColumn, nothing elsedatabase update(5.x's migration and the two after it)database update Moved(the Down of the column),migrations remove,has-pending-model-changesThe removals
Rows inside every run assert two refusals by their message and run one control:
SMOKE_BREAKapplies 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(noUseSchemaKit())2.
SMOKE_BREAK=kernel-only(UseNpgsql(cs).UseSchemaKit(), the kernel's method on the outer builder)3.
SMOKE_BREAK=user-differ(the consumer's ownIDesignTimeServicesregisters EF Core'sMigrationsModelDiffer)Here
dotnet efreports 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_databaseholds nosksmoke_*), and~/.nuget/packagesholds nocodometis.efcore.schemakit*.What a path showed that the repository's tests do not hold
migrations removeafter 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, soCustomExclusion:Constraintscomes back, now withProductVersion11. The nextmigrations addis 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.UseSchemaKit()alone,EnsureCreated()creates the database before it refuses, which leaves an empty database behind. WithoutUseSchemaKit()it refuses before creating anything. This is EF Core's order (the database first, then the diff), and the refusal is still loud.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
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.release.ymldoes not run the smoke test ondist/yet. It callsdotnet.yml, whose lane tests a fresh pack of the same commit. 5.x also runs it on the release's owndist/; that needs a PostgreSQL service inverifyand is left for a follow-up.migrations add, which fails with a clear message before the database is asked. Every other result is the database's.SMOKE_BREAKis a switch inside the test. It exists to show that the test fails without each registration. It is not run in CI.Wiring.csdisables EF1001 to register EF Core's internalMigrationsModelDiffer. The control has to do that, as a consumer who registers it would.🤖 Generated with Claude Code