Skip to content

Share tenant-database provisioning and dedupe the multi-tenancy collection - #5107

Merged
jeremydmiller merged 1 commit into
masterfrom
chore/harness-multitenancy
Aug 1, 2026
Merged

Share tenant-database provisioning and dedupe the multi-tenancy collection#5107
jeremydmiller merged 1 commit into
masterfrom
chore/harness-multitenancy

Conversation

@jeremydmiller

Copy link
Copy Markdown
Member

Phase-2 test-harness standardization, MultiTenancyTests hotspot (follows #5104#5106).

Scope note: unlike the prior migrations, the host/tenancy construction in these files is the test subject (master-table vs static vs per-database strategies), so the hand-built hosts deliberately stay. The standardization win is the shared plumbing:

New Marten.Testing/Harness/TenantDatabases

Provisions per-tenant databases on the test server and hands back connection strings. Replaces ten per-file CreateDatabaseIfNotExists copies. The shared body is the best of the ten — the race-tolerant variant from projection_statuses_per_database (check-then-create isn't atomic across concurrent TFM runs, so the loser of the race swallows DuplicateDatabase/UniqueViolation). DocumentStore_IMartenStorage_implementation keeps a thin wrapper adding its schema drops on top.

multi-tenancy collection dedup

There were nine duplicate [CollectionDefinition("multi-tenancy", DisableParallelization = true)] declarations, each decorating a test class without enrolling it — only projection_statuses_per_database actually joined via [Collection]. One definition now lives in MultiTenancyCollection.cs and the nine classes join the collection properly. Behavior-neutral today (the assembly disables parallelization outright), but the declaration now matches the intent.

Verification

net9.0 local: full MultiTenancyTests suite 159/159, 24s.

🤖 Generated with Claude Code

https://claude.ai/code/session_01U99pVx6kXwiGmaBUGLv7jB

…ction

Phase-2 harness standardization, MultiTenancyTests hotspot (follows
#5104-#5106). Scope note: unlike the prior migrations, the host/tenancy
construction in these files IS the test subject (master-table vs static vs
per-database strategies), so the hand-built hosts stay. The standardization
win here is the shared plumbing:

- New Marten.Testing/Harness/TenantDatabases: provisions per-tenant databases
  on the test server and hands back connection strings. Uses the
  race-tolerant body from projection_statuses_per_database (check-then-create
  is not atomic across concurrent TFM runs; the loser of the race swallows
  DuplicateDatabase/UniqueViolation). Replaces TEN per-file
  CreateDatabaseIfNotExists copies. DocumentStore_IMartenStorage keeps a thin
  wrapper that adds its schema drops on top.

- The "multi-tenancy" xUnit collection had NINE duplicate
  [CollectionDefinition("multi-tenancy", DisableParallelization = true)]
  declarations, each decorating a test class without enrolling it - only
  projection_statuses_per_database actually joined via [Collection]. One
  definition now lives in MultiTenancyCollection.cs and the nine classes
  join the collection properly. Behavior-neutral today (the assembly disables
  parallelization outright) but now expresses the actual intent.

net9.0: MultiTenancyTests 159/159.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U99pVx6kXwiGmaBUGLv7jB
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