Repository navigation
Add explicit-start shutdown regression coverage (startup-token cancellation and process exit) - #21397
David Fowler (davidfowl) wants to merge 2 commits into
Conversation
Observe startup completion and give shutdown its own standard cancellation budget. Exercise both natural and expired completed-startup budgets and verify the host and running service stop. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21397Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21397" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the test-only changes separating startup and shutdown cancellation budgets.
No open issues 🎉
What changed in this PR
This PR addresses shutdown cancellation in the explicit-start hosting test by separating startup and shutdown budgets, without changing production code or timeout values. It targets the teardown failures reported in #21026 and #21328, not the separate resource-startup failure.
Changes:
- Observes the actual startup task before initiating shutdown.
- Covers both normal completion and explicit cancellation of the completed startup token.
- Gives shutdown a fresh cancellation budget and verifies host shutdown and ServiceB root-process exit.
| File | Description |
|---|---|
tests/Aspire.Hosting.Tests/DistributedApplicationTests.cs |
Separates lifecycle cancellation budgets and adds cancellation-case coverage and shutdown assertions. |
Review effort: Balanced
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
# Conflicts: # tests/Aspire.Hosting.Tests/DistributedApplicationTests.cs
Tests selector6 / 100 PR test projects · 0 PR jobs, from 1 changed file. Selected PR test projects (6 / 100)
Selected PR jobs (0)none How these were chosen — grouped by what changed🧪 Job reasonsnone Selection computed for commit |
There was a problem hiding this comment.
🟡 Changes recommended
The title and description claim a cancellation-budget separation that already exists, misrepresenting this PR’s actual contribution of regression coverage and startup-completion observation.
1 open issue
Review effort: Balanced
|
Merged On the new head, 🤖 Posted by AspireAgent (AI Agent) |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |

Description
Original description (pre-merge): give
BeforeResourceStartedEvent_NotFiredForExplicitStartOnInitialCreationseparate startup and shutdown cancellation budgets. A slow startup previously consumed most of the same 30-second CI token subsequently passed toStopAsync, causing cleanup cancellation even when shutdown itself completed within the standard bound.Related: #21026, #21328. These issues are intentionally left open for continued observation.
The test now observes its actual startup task, creates the shutdown token only when entering shutdown, and runs both natural and explicitly cancelled completed-startup cases. All existing resource/event assertions, waits, ports, and timeout values are preserved. Both cases verify actual host shutdown and ServiceB root-process exit. No product, shared fixture, workflow, dependency, or policy changes are included.
Native before/after evidence
StopAsyncafter approximately 21 seconds of startup consumed the shared 30-second budget.The clean repaired source at
d28c36fe8091ae1308fbf5691e36b71c3b51b0e2is byte-identical to the test source executed at validation head7c6ad6b7d8d99b06eea1224f853ea45f4ad5f822. Only the separate validation branch contains workflow selection/TRX-capture configuration.Qualification gap: 90 executions were planned. Runner 1's build succeeded, but its check reports “The hosted runner lost communication with the server.” It retained neither logs nor TRX; its 30 planned outcomes are unknown, not passes or demonstrated test failures. That qualification workflow remains failed; subsequent normal PR CI does not fill those missing outcomes. Local native execution was unavailable after the prescribed restore failed with NU1900/NU1905 resolving configured NuGet audit metadata; the supported hosted Windows path was used without policy overrides.
Normal PR CI status (2026-10-29 18:28 UTC)
Normal CI executed both repaired theory rows and both adjacent event facts successfully on Windows and Ubuntu. Hosting-1 completed 28 passed / 0 failed / 0 skipped on Windows and 63 passed / 0 failed / 0 skipped on Ubuntu.
Attempt 1 failed in the unchanged Ubuntu
AzureFunctionsTests.AddAzureFunctionsProject_WorksWithMultipleProjectsat its line-201 parameterlesshost.StopAsync()(TaskCanceledException, 32.300-second test; suite 2,109 passed / 1 failed / 5 skipped). That separate test does not use this PR's repaired method or startup token; its root cause remains unproven.The repository's automatic CI rerun started attempt 2 without a source change. Its Azure suite passed 2,110 / 0 failed / 5 skipped, including that method in 28.566 seconds. The macOS ARM64 build also succeeded. Latest applicable CI is now green on
d28c36fe8091ae1308fbf5691e36b71c3b51b0e2(46 successful checks, 29 skipped); skipped checks are not passing test executions. The first Azure failure and the separate qualification gap above remain part of the evidence. Copilot review identified no active issues. This is ready for human review, not approved for merge.Scope and limits
This is not a revival of #20406's broad shared-fixture/shutdown-timeout/DCP-log-forwarding changes. That PR was closed after an out-of-order DCP API-server update bug was identified. Here the actual selected host path separately demonstrates that passing an already-cancelled completed-startup token to shutdown causes cancellation; giving shutdown its own unchanged budget completes host shutdown and root exit.
The distinct original line-353 resource-startup failure associated with Docker/WSLc discovery stalls is not fixed or claimed fixed. Root-process exit does not prove that every descendant process exited.
Created using the repository's fix-flaky-test skill, with existing before/after native evidence and deterministic cancellation coverage rather than arbitrary delays or larger timeouts.
Checklist
<remarks />and<code />elements on your triple slash comments?🤖 Posted by AspireAgent (AI Agent)