Add HostedStoreContext harness for IHost + AddMarten tests - #5102
Merged
Conversation
Phase 2 of the test-harness standardization program: tests that need a real IHost (daemon coordination, DI-registered projections, ancillary stores) had no shared harness — 37 files across the event sourcing projects inline the same Host.CreateDefaultBuilder + AddMarten + StartAsync block with hard-coded schema literals, and the only prior factoring (DaemonContext's host helpers) is hard-wired to one specific projection. Marten.Testing/Harness/HostedStoreContext owns host lifetime (hosts stopped and disposed newest-first at class teardown) and pre-configures the main store with the test connection string, a per-class schema name, and Npgsql logging disabled. StartHostAsync exposes the daemon mode, the AddMarten fluent expression (for chained calls like ApplyAllDatabaseChangesOnStartup), and an IServiceCollection hook for ancillary AddMartenStore registrations. First six EventSourcingTests files migrated, retiring seven hard-coded schema literals (es_identity, things, system_part, capabilities, descriptor_enrichment, max_seq_usage, bug4441_default, bug4441_outbox, bug4904_externally_managed, ancillary_enrich_*): - determining_the_event_store_identity - propagate_logger_to_projections - generating_event_store_descriptors - Bugs/Bug_4441_force_catch_up_with_outbox - Bugs/Bug_4904_force_catch_up_under_externally_managed - Aggregation/ancillary_store_enrichment_tests Deliberately untouched: Examples/* and Projections/testing_projections.cs (doc snippets where the inline host IS the sample), and Daemon/postgres_listen_notify_wakeup_tests.cs (open work in flight on that file for #4961). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U99pVx6kXwiGmaBUGLv7jB
jeremydmiller
added a commit
that referenced
this pull request
Aug 1, 2026
Continues the phase-2 harness standardization (#5098-#5103): the DaemonTests side of the inline Host.CreateDefaultBuilder + AddMarten pattern moves onto the shared HostedStoreContext harness from #5102, retiring nine hard-coded schema literals (bug2073, bug3059, coordinator, missing_events, subscriptions_start, ioc, bluegreen, feature_4284_net*, eao_*) in favor of per-class schema names, and letting the harness own host lifetime. Migrated: - Bugs/Bug_2073_tenancy_problems - Bugs/Bug_3059_double_application - Composites/Feature_4284_composite_projection_with_services - Internals/pausing_and_resuming_the_daemon - Resiliency/skipping_unknown_event_types_in_continuous_builds (also fixes the NRE in DisposeAsync when a test failed before _processor was assigned) - Subscriptions/subscribe_from_present - Subscriptions/subscriptions_end_to_end: the five host-based tests split out of the OneOffConfigurationsContext class into a new subscription_registrations_through_host: HostedStoreContext class; subscriptions_are_part_of_the_event_store_usage keeps a hand-rolled host because it asserts exactly one IEventStore registration and the harness's main store would add a second - EventSourcingTests/event_append_observation (per-test schema suffixes now derive from SchemaName) - DaemonTests.ManualOnly/Coordination/blue_green_projection_deployments Also fixes a latent ManualOnly breakage: BlueProjection/GreenProjection use conventional Apply methods but were not declared partial, so 4 of the 5 blue/green tests failed on master with "No source-generated dispatcher found". Both are partial now and all 5 pass. Deliberately untouched: Internals/service_registrations (Build()-only Lamar container assertions, no started host), Bug_3080 + MultiTenancy/dynamic_spin_up_of_dynamic_tenants + multi_tenancy_by_database (real multi-database provisioning that does not fit the single-connection harness), Examples/* and Projections/testing_projections.cs (doc snippets), Daemon/postgres_listen_notify_wakeup_tests.cs (#4961 in flight), and the four TenantPartitionedEventsTests multi-node host files (follow-up). net9.0: DaemonTests 260/260, EventSourcingTests event_append_observation 8/8, ManualOnly blue_green 5/5. Claude-Session: https://claude.ai/code/session_01U99pVx6kXwiGmaBUGLv7jB Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
19 tasks
This was referenced Aug 4, 2026
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.
Phase 2 (continued) of the test-harness standardization program (
HANDOFF-test-harness-standardization.md): a shared harness for the ~37 event-sourcing test files that inlineHost.CreateDefaultBuilder+AddMarten+StartAsyncwith hard-coded schema literals.The harness
Marten.Testing/Harness/HostedStoreContext:StartHostAsync(configure, daemonMode?, configureServices?, configureMarten?)— main store pre-wired with the test connection string, a per-class schema name (same convention asOneOffConfigurationsContext), andDisableNpgsqlLogging.daemonModemaps toAddAsyncDaemon;configureMartenreceives the AddMarten fluent expression (ApplyAllDatabaseChangesOnStartupetc.);configureServicescovers ancillaryAddMartenStore<T>registrations.EventSourcingTests.csproj; other projects opt in by adding the Compile link when they migrate.First six migrations (proof of shape)
determining_the_event_store_identity,propagate_logger_to_projections,generating_event_store_descriptors,Bug_4441_force_catch_up_with_outbox,Bug_4904_force_catch_up_under_externally_managed,ancillary_store_enrichment_tests— retiring ~10 hard-coded schema literals. All 9 tests across the six files pass on net9.0.Deliberately untouched:
Examples/*+testing_projections.cs(the inline host is the published doc sample), andDaemon/postgres_listen_notify_wakeup_tests.cs(uncommitted #4961 work in flight on that file). The remaining inline-host files in DaemonTests/TPE are follow-up material; DaemonTests'DaemonContexthost helpers (hard-wired toTripProjectionWithCustomName) can be reimplemented on this base in a later pass.🤖 Generated with Claude Code
https://claude.ai/code/session_01U99pVx6kXwiGmaBUGLv7jB