fix(events): neutralize MaintenanceModeMiddleware in test factory#214
Merged
Conversation
The feat(maintenance) commit wired FileSystemMaintenanceStateProvider into the request pipeline unconditionally. WebApplicationFactory resolves its content root from the SimpleModule.Host project directory (template/SimpleModule.Host/), so a leftover .maintenance sentinel file there — created by `sm down` during development or testing — activates maintenance mode for the entire test host and makes every non-health request return 503. This caused PublishedEvent_Survives_The_Durable_Pipeline_End_To_End to fail with "Expected response.IsSuccessStatusCode to be True, but found False" because the PUT /api/settings request received a 503 instead of 204 NoContent. Fix: replace IMaintenanceStateProvider with NullMaintenanceStateProvider in SimpleModuleWebApplicationFactory.ConfigureWebHost so the maintenance middleware always passes through during tests, regardless of local filesystem state.
Deploying simplemodule-website with
|
| Latest commit: |
eaae2c7
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://34752fcf.simplemodule-website.pages.dev |
| Branch Preview URL: | https://fix-event-durability-e2e-fla.simplemodule-website.pages.dev |
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.
What was broken
PublishedEvent_Survives_The_Durable_Pipeline_End_To_Endwas failing with:The root cause: the
feat(maintenance)commit (#201) wiredFileSystemMaintenanceStateProviderinto the request pipeline unconditionally.WebApplicationFactory<Program>resolves its content root totemplate/SimpleModule.Host/(where it findsappsettings.json). When a developer runssm downlocally and leaves the.maintenancesentinel file in that directory, the maintenance middleware returns 503 Service Unavailable for every non-health request — including thePUT /api/settingsthis test makes.What fixed it
SimpleModuleWebApplicationFactory.ConfigureWebHostnow replacesIMaintenanceStateProviderwithNullMaintenanceStateProvider, which always returnsnull(app is live). The maintenance middleware passes through unconditionally in tests, regardless of whether a.maintenancefile exists on the developer's machine or a CI runner that previously ransm down.This follows the same pattern used for seed services and DB context replacements in the factory.
How verified
template/SimpleModule.Host/.maintenance→ test fails with 503..maintenancepresent..maintenance, ran full Core.Tests suite: 210 / 210 pass.