Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 7, 2025

Description

Fixes #9834 (flaky test with 9 failures over 30 days - timeout waiting for DCP connection)

Refactored ExecuteCommandAsync_HasReplicas_Canceled_CalledPerReplica and ExecuteCommandAsync_HasReplicas_MixedFailureAndCanceled_OnlyFailuresInErrorMessage to eliminate DCP infrastructure dependency:

  • Replaced AddProject<Projects.ServiceA> with AddResource(new CustomResource(...))
  • Added DcpInstancesAnnotation to simulate replicas
  • Removed WaitForResourceHealthyAsync() call that depended on DCP startup

Pattern matches existing ExecuteCommandAsync_ResourceNameMultipleMatches_Success test. Tests same command execution logic with multiple replicas without requiring orchestrator infrastructure. Execution time reduced from 30+ seconds (with frequent 180s timeouts) to consistent 10-11 seconds.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?
Original prompt

This section details on the original issue you should resolve

<issue_title>Failing test: Aspire.Hosting.Tests.ResourceCommandServiceTests.ExecuteCommandAsync_HasReplicas_Canceled_CalledPerReplica</issue_title>
<issue_description>## Build Information
Build: https://github.com/dotnet/aspire/actions/runs/18861898502
Build error leg or test failing: Aspire.Hosting.Tests.ResourceCommandServiceTests.ExecuteCommandAsync_HasReplicas_Canceled_CalledPerReplica
Pull request:

Error Message

Fill the error message using step by step known issues guidance.

{
  "ErrorMessage": "",
  "ErrorPattern": "",
  "BuildRetry": false,
  "ExcludeConsoleLog": false
}

Error Details

System.TimeoutException : The operation at /home/runner/work/aspire/aspire/tests/Aspire.Hosting.Tests/ResourceCommandServiceTests.cs:235 timed out after reaching the limit of 180000ms.
Stack Trace
at Microsoft.AspNetCore.InternalTesting.AsyncTestHelpers.TimeoutAfter[T](Task`1 task, TimeSpan timeout, String filePath, Int32 lineNumber) in /home/runner/work/aspire/aspire/tests/Shared/AsyncTestHelpers.cs:line 143
   at Aspire.Hosting.Tests.ResourceCommandServiceTests.ExecuteCommandAsync_HasReplicas_Canceled_CalledPerReplica() in /home/runner/work/aspire/aspire/tests/Aspire.Hosting.Tests/ResourceCommandServiceTests.cs:line 235
--- End of stack trace from previous location ---

Last 10 failures:

Run date Build Type Test Name OS
nov 06 6 am dev/adamint/extensible-debug-support@eb17f87 ExecuteCommandAsync_HasReplicas_Canceled_CalledPerReplica windows
nov 06 6 am dev/adamint/extensible-debug-support@eb17f87 ExecuteCommandAsync_HasReplicas_Canceled_CalledPerReplica linux
nov 06 6 am dev/adamint/extensible-debug-support@eb17f87 ExecuteCommandAsync_HasReplicas_Canceled_CalledPerReplica macos
oct 29 9 pm main@cbab0e7 ExecuteCommandAsync_HasReplicas_Canceled_CalledPerReplica linux
oct 29 4 am dev/adamint/support-python-modules@70f55f3 ExecuteCommandAsync_HasReplicas_Canceled_CalledPerReplica linux
oct 28 11 pm pr#12455 ExecuteCommandAsync_HasReplicas_Canceled_CalledPerReplica linux
oct 28 4 pm main@b98fbc8 ExecuteCommandAsync_HasReplicas_Canceled_CalledPerReplica linux
oct 28 3 am pr#12361 ExecuteCommandAsync_HasReplicas_Canceled_CalledPerReplica macos
oct 28 2 am main@b8f56e7 ExecuteCommandAsync_HasReplicas_Canceled_CalledPerReplica linux

Summary

Last 24 hrs Last 7 days Last 30 days Most Affected OS Failure Rate
0 3 (0 PRs, 3 rolling) 9 (3 PRs, 6 rolling) linux (67%) 0.0%

-- Updated on 11/7/2025 3:12:30 PM UTC

</issue_description>

<agent_instructions>Investigate the flaky test failures. Aim to make the test robust instead of just adding more timeouts. Also, look at similar tests and consider helper code that could be added to make these tests robust.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Make ExecuteCommandAsync_HasReplicas_Canceled_CalledPerReplica and
ExecuteCommandAsync_HasReplicas_MixedFailureAndCanceled_OnlyFailuresInErrorMessage
more robust by:
- Using AddResource(new CustomResource(...)) with DcpInstancesAnnotation instead of AddProject
- Removing WaitForResourceHealthyAsync which depends on DCP connection
- Following the pattern from ExecuteCommandAsync_ResourceNameMultipleMatches_Success

This eliminates the dependency on DCP infrastructure starting correctly, making the tests
more stable and faster.

Co-authored-by: radical <[email protected]>
Copilot AI changed the title [WIP] Fix failing test for resource command execution Fix flaky test ExecuteCommandAsync_HasReplicas_Canceled_CalledPerReplica by removing DCP dependency Nov 7, 2025
Copilot AI requested a review from radical November 7, 2025 16:21
@github-actions
Copy link
Contributor

github-actions bot commented Nov 8, 2025

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12806

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12806"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants