Repository navigation
Make ADC rejected-create cancellation test deterministic - #21591
David Fowler (davidfowl) merged 2 commits into
Conversation
The test cancelled with a 10ms wall-clock timeout, which could fire while the first HTTP request was still in flight. The client then correctly reported the cancellation as ambiguous (ResponseMayHaveBeenLost=true) and the assertion failed. Cancel when the client logs its 403 retry warning instead, so cancellation always lands in the retry delay after the definite rejection. Fixes #21589 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 -- 21591Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21591" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
The test duplicates a private ILogger implementation instead of reusing the shared TestLogger and TestSink.MessageLogged callback, which preserves cancellation timing and follows the shared-test-dependency guidelines.
1 open issue
What changed in this PR
This test-only change addresses #21589 by making cancellation deterministic in the Azure Dev Compute rejected-create test. Production behavior is unchanged.
Changes:
- Replaces the 10 ms cancellation timer with cancellation triggered by the 403-retry warning.
- Adds an assertion that exactly one request occurred, while preserving the rejection-classification assertions.
| File | Description |
|---|---|
| tests/Aspire.Hosting.Azure.Tests/AzureSandboxesTests.cs | Adds warning-triggered cancellation and verifies a single rejected request. |
Review effort: Balanced
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Tests selector2 / 100 PR test projects · 0 PR jobs, from 1 changed file. Selected PR test projects (2 / 100)
Selected PR jobs (0)none How these were chosen — grouped by what changed🧪 Job reasonsnone Selection computed for commit |
|
✅ No documentation update needed. docs_optional → test_only. No signals triggered (signal_count == 0). The only changed file, |

Description
Fixes the intermittent
Aspire.Hosting.Azure.Tests.AzureSandboxesTests.AzureDevComputeClientKeepsCancellationAfterRejectedCreateDefinitefailure (Assert.False() Failure … Actual: Trueat AzureSandboxesTests.cs:1605).Root cause: the test is meant to check that cancelling during the 403 retry delay is reported as a definite rejection (
ResponseMayHaveBeenLost == false). It cancelled with a wall-clockCancellationTokenSource(TimeSpan.FromMilliseconds(10)). When that timer fired while the firstHttpClient.SendAsyncwas still in flight (cold or slow runner),SendCoreAsynccorrectly classified the cancellation as ambiguous (ResponseMayHaveBeenLost = true), and the assertion failed. The product code is correct; the test raced a timer against the first round-trip.Fix (test-only): cancel the token from the shared
TestSink.MessageLoggedcallback (throughTestLogger) when the client logs its 403-retry warning. That warning is emitted after the rejection is received and immediately beforeTask.Delay(retryDelay, token), so cancellation always lands in the retry delay. The fix adds no sleeps or retries, and the original assertions are unchanged. It also addsAssert.Equal(1, requestCount)to prove cancellation happened after exactly one definitive rejection.Frequency: window 2026-10-29T11:16Z – 2026-10-31T10:38Z, 361
ci.ymlruns. Latest attempts ofHosting.Azure (ubuntu-latest): 170 success, 13 failure, 17 cancelled.mainpushes: runs 41085859817 and 41004872500.AzureFunctionsTests.AddAzureFunctionsProject_WorksWithMultipleProjects, 2 × PR snapshot mismatches, 1 × PR build error). Failures hidden behind successful reruns are not counted.Repro evidence: I compiled the real
AzureDevComputeClient.csinto a standalone harness, one fresh process per run.ResponseMayHaveBeenLost=True,TaskCanceledException, 1 request (the CI signature)CI on db5ec96: green.
Hosting.Azure (ubuntu-latest)andHosting.Azure (windows-latest), the jobs that run this test, passed on the first attempt, with no reruns.Fixes #21589
Checklist
🤖 Posted by AspireAgent (AI Agent)