-
Notifications
You must be signed in to change notification settings - Fork 727
Fix flaky test ExecuteAsync_WhenStepFails_PipelineLoggerIsCleanedUp #12341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Use CancellationToken.None when creating step activities to prevent race condition where a failing step could cancel the token before other concurrent steps finish creating their activities. Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
|
@copilot This does not fix the issue, it undoes the behavior, we want fail fast behavior by default. The test should verify. a single failure as it is hard to verify multiple failures. |
Reverted the CancellationToken.None change to preserve fail-fast behavior as requested by @davidfowl. Updated the test to focus on verifying the single failing step rather than asserting an exact count of step activities, making it more resilient to timing variations while maintaining fail-fast behavior. Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Reverted the pipeline change and updated the test to verify only the failing step instead of asserting an exact count. This preserves fail-fast behavior while making the test resilient to timing variations. Changes in commit 8415720. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a flaky test that was failing intermittently due to a race condition in concurrent step execution. The test now focuses on verifying the failing step's behavior rather than asserting exact counts that vary based on timing.
Key Changes:
- Removed assertion on exact count of step activities to avoid timing-dependent failures
- Changed from
FirstOrDefault+NotNullcheck toSingleto verify exactly one failing step exists - Added explanatory comment about timing variability of concurrent steps
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12341Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12341" |
…12341) * Initial plan * Fix race condition in pipeline step activity reporting Use CancellationToken.None when creating step activities to prevent race condition where a failing step could cancel the token before other concurrent steps finish creating their activities. Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com> * Revert pipeline change and fix test to only verify failing step Reverted the CancellationToken.None change to preserve fail-fast behavior as requested by @davidfowl. Updated the test to focus on verifying the single failing step rather than asserting an exact count of step activities, making it more resilient to timing variations while maintaining fail-fast behavior. Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Problem
The test
ExecuteAsync_WhenStepFails_PipelineLoggerIsCleanedUpwas failing intermittently with an assertion error:The test expected 2 step activity groups (one for the default "deploy" step and one for the "failing-step") but the actual count varied due to timing of concurrent step execution.
Root Cause
The test had a race condition in its assertions:
Task.Run()linkedCtscancellation token to stop remaining work (fail-fast behavior)Solution
Updated the test to focus on verifying the failing step's behavior rather than asserting an exact count of step activities:
This preserves the fail-fast behavior while making the test resilient to timing variations. The test now focuses on what matters: verifying that the failing step is properly reported with error state and that the logger is cleaned up after failure.
Testing
DistributedApplicationPipelineTestspassFixes intermittent test failure in CI/CD pipelines.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.