Fix flaky test: use resilient HttpClient in YarpFunctionalTests#14920
Merged
Fix flaky test: use resilient HttpClient in YarpFunctionalTests#14920
Conversation
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14920Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14920" |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses flakiness in YarpFunctionalTests.VerifyYarpResourceExtensionsConfig by switching the test’s HTTP client creation to use the test host’s DI-configured IHttpClientFactory (which includes standard resilience/retry behavior), reducing transient 502/connection timing failures when container networking isn’t fully ready.
Changes:
- Replace a manually constructed
HttpClientwithapp.CreateHttpClient(...)inYarpFunctionalTests. - Update the
fix-flaky-testskill documentation to enforce a two-phase CI investigation workflow (reproduce first, then fix/verify), and to improve CI result validation guidance (including zero-test runs).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/Aspire.Hosting.Yarp.Tests/YarpFunctionalTests.cs | Uses DistributedApplication.CreateHttpClient so tests benefit from configured resilience/retries. |
| .github/skills/fix-flaky-test/SKILL.md | Strengthens guidance for reproducible flaky-test investigations and accurate CI result interpretation. |
Contributor
🎬 CLI E2E Test RecordingsThe following terminal recordings are available for commit
📹 Recordings uploaded automatically from CI run #22645403852 |
98ec616 to
d7d398d
Compare
Replace bare 'new HttpClient()' with 'app.CreateHttpClient()' which uses IHttpClientFactory with AddStandardResilienceHandler() already configured by TestDistributedApplicationBuilder. This adds automatic retries for transient failures (502 BadGateway) caused by Docker inter-container networking not being fully established when the test makes its HTTP request. Fixes #9344 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
d7d398d to
6b79e95
Compare
JamesNK
approved these changes
Mar 3, 2026
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.
Flaky Test Fix
Test
Aspire.Hosting.Yarp.Tests.YarpFunctionalTests.VerifyYarpResourceExtensionsConfigRoot Cause
The test created a bare
new HttpClient()with no retry logic. After both YARP and backend containers report healthy, Docker inter-container networking may not be fully established — YARP returns 502 BadGateway because it can't yet reach the backend container.Fix
Replace
new HttpClient()withapp.CreateHttpClient(), which uses the DI container'sIHttpClientFactorywithAddStandardResilienceHandler()already configured byTestDistributedApplicationBuilder, providing automatic retries for transient failures.Verification
Local runs:
Notes
[QuarantinedTest]attribute kept — unquarantining will happen separately after stability is confirmed in quarantine CIThis fix was generated using the fix-flaky-test skill.