Repository navigation
Fix test servers staying alive until their test class ends - #10482
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved issues were identified that would block approval.
Review effort: Lite
Findings: None
What changed in this PR
Fixes test-server memory retention by disposing servers after each test instead of at class teardown.
Changes:
- Adds
DisposeServers()and clears tracked instances. - Makes
ServerTestBasedispose servers asynchronously per test. - Updates OPA teardown to invoke base cleanup.
| File | Description |
|---|---|
| src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/TestServerFactory.cs | Updated as part of this pull request. |
| src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/ServerTestBase.cs | Updated as part of this pull request. |
| src/HotChocolate/AspNetCore/test/AspNetCore.Authorization.Opa.Tests/AuthorizationTests.cs | Updated as part of this pull request. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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
TestServerFactoryis a class fixture that kept everyTestServerit created until the test class finished.GraphQLOverHttpSpecTestsalone creates about 315 servers, each building seven schemas at startup, so theHotChocolate.AspNetCore.Testsprocess grows to about 16 GB, the full memory of a GitHub-hosted runner.GraphQLOverWebSocket.WebSocketProtocolTests.Send_Subscribe_SyntaxErrortook 42.8 seconds against its 15-second budget in this run, and theGraphQLOverHttpSpecTests.EventStream_*keep-alive failures run 3 to 13 seconds over their usual 30.ServerTestBasenow disposes and releases the servers a test created when that test finishes, through a newTestServerFactory.DisposeServers(). Constructors are unchanged. The OpaAuthorizationTestsoverrides the newDisposeAsync, since xUnit calls onlyDisposeAsyncon a test class that has one.Test plan
HotChocolate.AspNetCore.Testson net11.0 with--coverage, pinned to 4 cores and capped at 12 GB of memory: before the change the test host threwOutOfMemoryExceptionafter 563 of 819 tests, after it all 819 complete with a peak resident memory of 509 MB (15.9 GB uncapped before the change).ServerTestBasewith code style enforced, and ran their tests on net11.0: AspNetCore.Authorization, Transport.Sockets.Client, Transport.Http, Diagnostics, Utilities.Introspection, Data.Sorting.InMemory, and the StrawberryShake transport and code generation tests pass.AspNetCore.Authorization.Opa.Testsstarts OPA in a container and is covered by CI.