Fix MAUI build queue timeout test flakiness - #20064
Fix MAUI build queue timeout test flakiness#20064James Newton-King (JamesNK) wants to merge 2 commits into
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 20064Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 20064" |
Tests selector1 / 99 PR test projects · 2 PR jobs · 0 advisory-only targets, from 7 changed files. Selected PR test projects (1 / 99)
Selected PR jobs (2)
Advisory workflow impact (0)none How these were chosen — grouped by what changed🔧 🧪 🧪 🧪 🧪 🧪 🧪 Job reasons
Selection computed for commit |
There was a problem hiding this comment.
🔵 Needs a closer look
The timeout watchdog can be mistaken for the expected build failure in one test.
Pull request overview
This PR makes MAUI build queue timeout tests deterministic and adds bounded async waits for CI diagnostics.
Changes:
- Injects
TimeProviderwhile retaining system time in production. - Uses
FakeTimeProviderfor timeout scenarios. - Applies shared
DefaultTimeouthelpers across MAUI tests. - Adds required testing support.
File summaries
| File | Summary |
|---|---|
tests/Aspire.Hosting.Maui.Tests/MauiWithArgsTests.cs |
Bounds argument-evaluation awaits. |
tests/Aspire.Hosting.Maui.Tests/MauiPlatformExtensionsTests.cs |
Bounds asynchronous test operations. |
tests/Aspire.Hosting.Maui.Tests/MauiOtlpTemplateTests.cs |
Bounds environment evaluation. |
tests/Aspire.Hosting.Maui.Tests/MauiiOSValidationTests.cs |
Bounds validation event awaits. |
tests/Aspire.Hosting.Maui.Tests/MauiBuildQueueTests.cs |
Makes timeout scenarios deterministic and adds bounded waits. |
tests/Aspire.Hosting.Maui.Tests/Aspire.Hosting.Maui.Tests.csproj |
Adds testing package and shared timeout support. |
src/Aspire.Hosting.Maui/Lifecycle/MauiBuildQueueEventSubscriber.cs |
Adds injectable launch-handoff timeout scheduling. |
Review details
Suppressed comments (1)
tests/Aspire.Hosting.Maui.Tests/MauiBuildQueueTests.cs:1103
DefaultTimeout()throwsTimeoutExceptionwhen the publish task does not complete, but it is insideAssert.ThrowsAnyAsync<Exception>, so the test can accept its own watchdog exception as the expected build failure instead of proving thatBuildTimeoutproduced the failure. Keep the timeout guard outside the broad exception assertion (first verify the task completed within the budget, then assert its exception), or assert the permitted production exception types while distinguishing the watchdog timeout.
CancellationToken.None)).DefaultTimeout();
- Files reviewed: 7/7 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Description
The MAUI build queue launch-handoff tests used short wall-clock delays to exercise timeout behavior. Under heavy Windows CI contention, those timers could be delayed long enough for tests to exceed their outer timeout and fail intermittently.
This change makes the launch-handoff timeout use an injectable
TimeProviderwhile preservingTimeProvider.Systemin production. The timeout tests now advance aFakeTimeProviderdeterministically instead of depending on real 50 ms timers.The MAUI test project also uses the shared
DefaultTimeouthelper for async operations that are expected to complete, preventing failures from hanging indefinitely and providing CI-aware timeout diagnostics. Intentional semaphore waits, cancellation waits, and timeout assertions retain their original semantics.Validation:
Fixes #18592
Checklist
<remarks />and<code />elements on your triple slash comments?