Repository navigation
Share one web host across the page feedback endpoint tests - #4694
Merged
Merged
Conversation
Each of the 10 page feedback endpoint tests started its own `WebApplicationFactory`, about 0.75 s per host, which was 8.5 of the 9 seconds the project's tests take when run one at a time. The only thing that differed between them was the `IPageFeedbackService` fake each one installed. The class now builds one host whose `IPageFeedbackService` registration resolves a `SwappableService`, and every test installs its fake before it sends its request. The tests share the current fake, so the class is marked `[NotInParallel]`; other classes still run in parallel with it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Mpdreamz
disabled auto-merge
November 4, 2026 18:29
reakaleek
approved these changes
Nov 4, 2026
Contributor
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4694/ |
Member
Author
|
Merged by heed (squash) because every merge rule held:
|
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.
The page feedback endpoint tests start one web host for the whole class instead of one per test.
Elastic.Documentation.Api.Testsuses about a quarter of the CPU it did.Affects: Internals only
Prompt summary: Find out which individual tests in the slow test projects do far more work than they need, and share setup between them. These ten tests were nearly all of this project's test time.
Why
Each of the 10
PageFeedbackEndpointTeststests (7 methods, one with 4[Arguments]rows) built its ownApiWebApplicationFactory: a full ASP.NET host, about 0.75 s each. Run one at a time they were 8.5 of the 9.0 seconds the project's 134 tests take. The only difference between them is theIPageFeedbackServicefake each one installs.What
One host per class, a swappable service
New
SwappableService<TService>holds the implementation for the current test. The class builds oneApiWebApplicationFactorylazily, registersIPageFeedbackServicethroughReplace<IPageFeedbackService>(_ => FeedbackService.Current), and each test installs its own fake before sending its request. The registration is scoped, so every request resolves whichever fake is current. The host is disposed in an[After(Class)]hook.Serialised within the class
The tests share the current fake, so the class is
[NotInParallel(nameof(PageFeedbackEndpointTests))]. Other test classes still run in parallel with it.Out of scope:
EuidEnrichmentTestsalso starts a host, but it has a single test and reads that host's own exported telemetry, so sharing would not save anything and would mix telemetry between tests.Results
Elastic.Documentation.Api.Tests, release build, 4 simulated cores, 3 runs each:The CI effect is not measured yet. On Windows CI this project took 45 s with 4 projects running at once.
Verify
dotnet test tests/Elastic.Documentation.Api.TestsAll 134 tests pass. Because the tests now share state, I ran the suite 10 times at each of 1, 4 and 18 cores: no failures. Two mutations fail tests: not swapping the fake (24 failures over 6 runs), and removing
[NotInParallel](22 failures over 6 runs), so the serialisation is required.🤖 Generated with Claude Code