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

Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 7, 2025

Description

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.

Also refactored ExecuteCommandAsync_HasReplicas_Success_CalledPerReplica and ExecuteCommandAsync_HasReplicas_Failure_CalledPerReplica using the same pattern. These two tests retain their [QuarantinedTest] attributes and will remain quarantined until they prove consistent stability in the quarantined-tests workflow.

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.

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"

Copilot AI and others added 3 commits January 6, 2026 13:16
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]>
@JamesNK JamesNK force-pushed the copilot/fix-failing-resource-command-test branch from 0464828 to 225b12b Compare January 6, 2026 05:27
@JamesNK JamesNK marked this pull request as ready for review January 6, 2026 05:32
@JamesNK JamesNK requested a review from mitchdenny as a code owner January 6, 2026 05:32
Copilot AI review requested due to automatic review settings January 6, 2026 05:32
@JamesNK JamesNK changed the title Fix flaky test ExecuteCommandAsync_HasReplicas_Canceled_CalledPerReplica by removing DCP dependency Fix flaky ExecuteCommandAsync tests by removing DCP dependency Jan 6, 2026
@JamesNK JamesNK added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Jan 6, 2026
@JamesNK
Copy link
Member

JamesNK commented Jan 6, 2026

@radical Good to merge?

Copy link
Contributor

Copilot AI left a 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 (ExecuteCommandAsync_HasReplicas_Canceled_CalledPerReplica) that was timing out due to DCP infrastructure dependency. The fix refactors four test methods to use CustomResource with DcpInstancesAnnotation instead of AddProject<Projects.ServiceA>().WithReplicas(), eliminating the need to wait for DCP connection and resource health checks. This reduces execution time from 30+ seconds with frequent 180s timeouts to consistent 10-11 seconds.

Key Changes

  • Replaced DCP-dependent project resources with CustomResource and manual DcpInstancesAnnotation configuration
  • Removed WaitForResourceHealthyAsync() calls that were causing timeout failures
  • Removed unused using Aspire.TestUtilities; import
  • Removed QuarantinedTest attributes from two previously flaky tests
  • Designer.cs file has auto-generated alphabetical reordering (no functional changes)

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

File Description
tests/Aspire.Hosting.Tests/ResourceCommandServiceTests.cs Refactored 4 test methods to eliminate DCP dependency by using CustomResource with DcpInstancesAnnotation instead of AddProject with WithReplicas; removed QuarantinedTest attributes; added explicit assertions for resolved resource names
src/Aspire.Cli/Resources/McpCommandStrings.Designer.cs Auto-generated alphabetical reordering of properties (no functional changes)
Files not reviewed (1)
  • src/Aspire.Cli/Resources/McpCommandStrings.Designer.cs: Language not supported

}

[Fact]
[QuarantinedTest("https://github.com/dotnet/aspire/issues/9832")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Add this back. This will be removed once the test is consistently passing on the quarantined-tests workflow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Added back the QuarantinedTest attributes for both ExecuteCommandAsync_HasReplicas_Success_CalledPerReplica (#9832) and ExecuteCommandAsync_HasReplicas_Failure_CalledPerReplica (#9834), along with the missing using Aspire.TestUtilities; import. (c8ad23b)

}

[Fact]
[QuarantinedTest("https://github.com/dotnet/aspire/issues/9834")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot and add back this one too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already added in c8ad23b - the [QuarantinedTest("https://github.com/dotnet/aspire/issues/9834")] attribute is now on line 155 for ExecuteCommandAsync_HasReplicas_Failure_CalledPerReplica.

Add back QuarantinedTest attributes to ExecuteCommandAsync_HasReplicas_Success_CalledPerReplica
and ExecuteCommandAsync_HasReplicas_Failure_CalledPerReplica. These tests need to prove
they're consistently passing in the quarantined-tests workflow before the attribute can be
permanently removed.

Also restored the missing 'using Aspire.TestUtilities;' import.

Co-authored-by: radical <[email protected]>
@JamesNK JamesNK merged commit 770f92d into main Jan 6, 2026
563 of 566 checks passed
@JamesNK JamesNK deleted the copilot/fix-failing-resource-command-test branch January 6, 2026 06:32
@dotnet-policy-service dotnet-policy-service bot added this to the 13.2 milestone Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failing test: Aspire.Hosting.Tests.ResourceCommandServiceTests.ExecuteCommandAsync_HasReplicas_Canceled_CalledPerReplica

3 participants