Give the test-host scope one owner: only the newest live test host runs its restartable services, the reset covers every live host, and duplicate connection string keys fail fast - #430
Merged
Conversation
…ns its restartable services, the reset covers every live host, and duplicate connection string keys fail fast
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.
Summary
The test-host scope now has one owner. Before,
BaseWebApplicationFactoryheld the whole scope lifecycle with no in-process test surface, and the reset paused only the host the caller passed in. A test that registers a mock runs on a derived host while the class's shared host stays alive on the same per-class databases and virtual hosts, so the shared host's outbox relay kept running during that test and during the database reset (contrary totesting.md). Since the previous PR made the message consumers restartable, the same gap also meant two hosts consuming the same queues.TestHostScope(new, internal,Vulthil.xUnit) owns:WithWebHostBuilderhost) joins the host when it starts and leaves when it stops;IRestartableHostedServices. When a host starts, the scope pauses the restartable services of the other live hosts; when the newest host stops, the host before it resumes. A double stop of the same host (WebApplicationFactorystops a disposed host twice) is a no-op.BaseWebApplicationFactory.ResetAsync(internal) no longer takes a host argument.InitializeAsyncthrow, naming the key and the containers (keys compare case-insensitively, like configuration keys). Before, one connection string silently overwrote the other, and which one won was not defined. The check runs on the scope views, which are what reach the host, before they provision any database or virtual host.BaseWebApplicationFactoryis a thin adapter over the scope. Its public and protected members do not change. The internalITestHostMigratorandTestMigrationHostedServiceare gone.TestHostResetstops and starts services from several hosts, and the scope uses it for pauses and resumes too, with the same per-step timeouts and the same aggregated failure reporting.testing.md): the per-test host pauses the shared host; the reset covers every live host; a scope lives for one test class, so a message one test leaves in a queue reaches the next test; duplicate keys fail.Behavior change (2.0 line): a test suite whose consumed containers share a connection string key now fails at fixture initialization instead of running against one of them. No public API change, so no compatibility suppressions.
Verification
dotnet build Vulthil.SharedKernel.slnx: 0 warnings, 0 errors.Vulthil.xUnit.Testshas 12 new in-processTestHostScopeTests(container filter and one scope id, run-once, connection strings, duplicate keys incl. case and an excluded container, start order, pause and resume, an older host stopping first, reset of the running host with the newest host's services, no live host, a failed pause, disposal), and the 8TestHostResetTestsrun on the new signature.Vulthil.IntegrationTests(Docker): 70/70 on net10.0 and net9.0, including the newLiveTestHostPauseTests: the shared host's probe stops when the test's host starts, stays stopped through the reset, and starts again after the test host stops.RestartableProbenow tags each event with its host, andFixtureResetRoutingTestsasserts that every event belongs to the one host the test built.MessagingIntegrationTests: 13/13 on net10.0.dotnet packpackage validation against 1.2.0 passes forVulthil.xUnit.Backport to v1.0: no