Skip to content

fix(events): neutralize MaintenanceModeMiddleware in test factory#214

Merged
antosubash merged 1 commit into
mainfrom
fix/event-durability-e2e-flake
May 23, 2026
Merged

fix(events): neutralize MaintenanceModeMiddleware in test factory#214
antosubash merged 1 commit into
mainfrom
fix/event-durability-e2e-flake

Conversation

@antosubash
Copy link
Copy Markdown
Owner

What was broken

PublishedEvent_Survives_The_Durable_Pipeline_End_To_End was failing with:

Expected response.IsSuccessStatusCode to be True, but found False.

The root cause: the feat(maintenance) commit (#201) wired FileSystemMaintenanceStateProvider into the request pipeline unconditionally. WebApplicationFactory<Program> resolves its content root to template/SimpleModule.Host/ (where it finds appsettings.json). When a developer runs sm down locally and leaves the .maintenance sentinel file in that directory, the maintenance middleware returns 503 Service Unavailable for every non-health request — including the PUT /api/settings this test makes.

What fixed it

SimpleModuleWebApplicationFactory.ConfigureWebHost now replaces IMaintenanceStateProvider with NullMaintenanceStateProvider, which always returns null (app is live). The maintenance middleware passes through unconditionally in tests, regardless of whether a .maintenance file exists on the developer's machine or a CI runner that previously ran sm down.

This follows the same pattern used for seed services and DB context replacements in the factory.

How verified

  1. Confirmed the failure: created template/SimpleModule.Host/.maintenance → test fails with 503.
  2. Applied fix, rebuilt: test passes with .maintenance present.
  3. Removed .maintenance, ran full Core.Tests suite: 210 / 210 pass.

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.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying simplemodule-website with  Cloudflare Pages  Cloudflare Pages

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

View logs

@antosubash antosubash merged commit 4498532 into main May 23, 2026
6 checks passed
@antosubash antosubash deleted the fix/event-durability-e2e-flake branch May 23, 2026 22:25
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