Remoting tests: 500 on discovery document, flaky under suite #4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Status
Flaky, pre-existing on
mainandfix/blog-detail. Two tests insrc/Yavsc.Org.Tests/Mandatory/Remoting.csfail when run as part of the full suite, but pass in isolation.Observed
dotnet test src/Yavsc.Org.Tests/Yavsc.Org.Tests.csprojfails 2 tests:The test class is decorated
[Collection("Yavsc Server")]and usesWebServerFixture(the collection-scoped fixture, notTestWebApplicationFactory). It hits the shared HTTPS host bound to a dynamic port (Addresses[0]), so the URL is correct.The two tests pass in isolation:
This points to a shared-state dependency on a test that runs before
Remotingin the full suite. Likely candidates:WebServerFixtureinitialises aUserManager<ApplicationUser>and seeds a test user inBuildApp(or inEnsureUser). If a previous test has run aSaveChangesthat detached/disabled the user, the password token request fails.IClientStoreis backed by the same in-memory database; if a previous test mutated theTestClientId/TestClientSecret, the discovery endpoint is fine but the token request is not — yet the test reports the discovery request failed, which is upstream of the token request.WebServerFixtureis initialised lazily on first construction (xUnit collection semantics), so theAddressesarray is captured once and shared across every test. If a test restarts the host (e.g. withDispose), the nextRemotingtest reads a stale port.Reproduction
Result: 6 failed, 35 passed (the 4
ClientControllerCollectionTestsfailures are the bug documented in the sibling issue; the 2Remotingfailures are this bug).Result: 1 passed (no flake in isolation).
What we need
Remotingin alphabetical order. xUnit v3 does not guarantee an order by default, so this requires a run with[Trait("priority", ...)]or running with--logger "console;verbosity=detailed"and reading the test discovery order.WebServerFixturestate (in particular_sharedTestingUserPassword,_sharedTestClientSecret).Remotingeither (a) tolerant of an already-initialised fixture (re-read the secrets from the liveConfigurationrather than the captured copies) or (b) run as the first test in the collection by ordering it last alphabetically and prefixing with0_or by adding[CollectionOrder(1)](xUnit v3 hasITestCollectionOrderer).Recommendation
Start with reading the test execution order and the
_sharedXxxfields ofWebServerFixtureafter the first non-Remotingtest runs. The 500 on discovery is the symptom of IdentityServer8 returning 500 — look at the server log output captured in the test result.htmlfile (undersrc/Yavsc.Org.Tests/TestResults/Yavsc.Org.tests.html) for the actual stack trace.