Skip to content

Commit b5e371a

Browse files
Copilotdavidfowl
authored andcommitted
Fix flaky test ExecuteAsync_WhenStepFails_PipelineLoggerIsCleanedUp (#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>
1 parent 38e610a commit b5e371a

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

tests/Aspire.Hosting.Tests/Pipelines/DistributedApplicationPipelineTests.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,11 +1526,8 @@ public async Task ExecuteAsync_WhenStepFails_PipelineLoggerIsCleanedUp()
15261526
var stepActivities = activities.Where(a => a.Type == PublishingActivityTypes.Step).GroupBy(a => a.Data.Id).ToList();
15271527
var logActivities = activities.Where(a => a.Type == PublishingActivityTypes.Log).ToList();
15281528

1529-
Assert.Equal(2, stepActivities.Count); // Updated to account for "deploy" step
1530-
1531-
// Find the failing-step activity
1532-
var failingStepActivity = stepActivities.FirstOrDefault(g => g.Any(a => a.Data.StatusText == "failing-step"));
1533-
Assert.NotNull(failingStepActivity);
1529+
// Verify the failing step activity (other steps may or may not complete depending on timing)
1530+
var failingStepActivity = stepActivities.Single(g => g.Any(a => a.Data.StatusText == "failing-step"));
15341531
Assert.Collection(failingStepActivity,
15351532
step =>
15361533
{

0 commit comments

Comments
 (0)