Skip to content

Fix MAUI build queue timeout test flakiness - #20064

Open
James Newton-King (JamesNK) wants to merge 2 commits into
mainfrom
fix-maui-build-queue-timeout-flake
Open

Fix MAUI build queue timeout test flakiness#20064
James Newton-King (JamesNK) wants to merge 2 commits into
mainfrom
fix-maui-build-queue-timeout-flake

Conversation

@JamesNK

Copy link
Copy Markdown
Member

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 TimeProvider while preserving TimeProvider.System in production. The timeout tests now advance a FakeTimeProvider deterministically instead of depending on real 50 ms timers.

The MAUI test project also uses the shared DefaultTimeout helper 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:

dotnet test --project tests/Aspire.Hosting.Maui.Tests/Aspire.Hosting.Maui.Tests.csproj --no-restore --no-launch-profile -- --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"
Passed: 204, Failed: 0, Skipped: 0

Fixes #18592

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

@github-actions

Copy link
Copy Markdown
Contributor

🚀 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/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 20064

Or

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

@aspire-repo-bot
aspire-repo-bot Bot requested a balanced review from Copilot September 11, 2026 08:45
@github-actions github-actions Bot added the area-integrations Issues pertaining to Aspire Integrations packages label Sep 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

1 / 99 PR test projects · 2 PR jobs · 0 advisory-only targets, from 7 changed files.

Selected PR test projects (1 / 99)

Aspire.Hosting.Maui.Tests

Selected PR jobs (2)

extension-e2e, typescript-api-compat

Advisory workflow impact (0)

none


How these were chosen — grouped by what changed

🔧 src/Aspire.Hosting.Maui/Lifecycle/MauiBuildQueueEventSubscriber.cs (changed source)
1 directly: Aspire.Hosting.Maui.Tests

🧪 tests/Aspire.Hosting.Maui.Tests/Aspire.Hosting.Maui.Tests.csproj (changed test)
1 directly: Aspire.Hosting.Maui.Tests

🧪 tests/Aspire.Hosting.Maui.Tests/MauiBuildQueueTests.cs (changed test)
1 directly: Aspire.Hosting.Maui.Tests

🧪 tests/Aspire.Hosting.Maui.Tests/MauiOtlpTemplateTests.cs (changed test)
1 directly: Aspire.Hosting.Maui.Tests

🧪 tests/Aspire.Hosting.Maui.Tests/MauiPlatformExtensionsTests.cs (changed test)
1 directly: Aspire.Hosting.Maui.Tests

🧪 tests/Aspire.Hosting.Maui.Tests/MauiWithArgsTests.cs (changed test)
1 directly: Aspire.Hosting.Maui.Tests

🧪 tests/Aspire.Hosting.Maui.Tests/MauiiOSValidationTests.cs (changed test)
1 directly: Aspire.Hosting.Maui.Tests

Job reasons

Job Triggered by
extension-e2e src/Aspire.Hosting.Maui/Lifecycle/MauiBuildQueueEventSubscriber.cs
• affected project Aspire.Hosting.Maui
typescript-api-compat affected project Aspire.Hosting.Maui

Selection computed for commit 517eedf.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 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 TimeProvider while retaining system time in production.
  • Uses FakeTimeProvider for timeout scenarios.
  • Applies shared DefaultTimeout helpers 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() throws TimeoutException when the publish task does not complete, but it is inside Assert.ThrowsAnyAsync<Exception>, so the test can accept its own watchdog exception as the expected build failure instead of proving that BuildTimeout produced 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.

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

Labels

area-integrations Issues pertaining to Aspire Integrations packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI Failure] Flaky: MauiBuildQueueTests.ReleaseSemaphoreAfterLaunchAsync_SkipsReplayStateAndReleasesOnStableState times out intermittently

2 participants