Fix race condition in URL snapshot watch tests#12804
Closed
Conversation
…e running Co-authored-by: radical <[email protected]>
Copilot
AI
changed the title
[WIP] Fix failing test for multiple URLs in snapshot
Fix race condition in URL snapshot watch tests
Nov 7, 2025
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12804Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12804" |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds explicit waits for resources to reach the Running state in two test methods to address potential race conditions in URL snapshot assertions.
- Adds
WaitForResourceAsynccalls to ensure resources reach Running state before URL snapshot verification - Applies the fix to
EndpointUrlsAreInitiallyInactiveandMultipleUrlsForSingleEndpointAreIncludedInUrlSnapshottests
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description
Two tests in
WithUrlsTestswere timing out intermittently due to a race between starting the app and watching for URL notifications. The watch task could complete iteration setup after URLs were already published, causing it to never observe the snapshots.Fixed by adding
WaitForResourceAsyncto ensure the resource reachesRunningstate before checking watch results. This guarantees URLs are published and available in the notification stream before the test proceeds.Changed tests:
MultipleUrlsForSingleEndpointAreIncludedInUrlSnapshotEndpointUrlsAreInitiallyInactivePattern applied:
This matches the synchronization pattern already used in other tests in the same file (
ExpectedNumberOfUrlsForReplicatedResource,UrlsAreInExpectedStateForResourcesGivenTheirLifecycle,UrlsAreMarkedAsInternalDependingOnDisplayLocation).Fixes #12775
Checklist
<remarks />and<code />elements on your triple slash comments?doc-ideatemplatebreaking-changetemplatediagnostictemplateOriginal prompt
This section details on the original issue you should resolve
<issue_title>Failing test: Aspire.Hosting.Tests.WithUrlsTests.MultipleUrlsForSingleEndpointAreIncludedInUrlSnapshot</issue_title>
<issue_description>## Build Information
Build: https://github.com/dotnet/aspire/actions/runs/18912256311
Build error leg or test failing: Aspire.Hosting.Tests.WithUrlsTests.MultipleUrlsForSingleEndpointAreIncludedInUrlSnapshot
Pull request:
Error Message
Fill the error message using step by step known issues guidance.
{ "ErrorMessage": "", "ErrorPattern": "", "BuildRetry": false, "ExcludeConsoleLog": false }Error Details
Stack Trace