Skip to content

Fix MAUI build queue timeout test flakiness - #20064

Merged
James Newton-King (JamesNK) merged 2 commits into
mainfrom
fix-maui-build-queue-timeout-flake
Sep 12, 2026
Merged

James Newton-King (JamesNK) merged 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.

@JamesNK
James Newton-King (JamesNK) merged commit 3617fe1 into main Sep 12, 2026
85 checks passed
@JamesNK
James Newton-King (JamesNK) deleted the fix-maui-build-queue-timeout-flake branch September 12, 2026 23:06
@github-actions github-actions Bot added this to the 13.6 milestone Sep 12, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

✅ No documentation update needed.

Step 5 branch taken: docs_required -> false positive, no concrete change to document (per the Step 10 exception: recommendation was docs_required, but on inspection the triggered signal does not correspond to an actual Aspire user-facing feature).

Triggered signals (1): pr_body_has_cli_flag_mention - matched the string --project inside the dotnet test --project tests/Aspire.Hosting.Maui.Tests/... validation command pasted into the PR body under Validation. This is a test invocation example, not a new or changed Aspire CLI flag, option, or public API.

Verification of the actual change:

  • src/Aspire.Hosting.Maui/Lifecycle/MauiBuildQueueEventSubscriber.cs: the class is declared internal class MauiBuildQueueEventSubscriber, and the modified/added members (internal TimeProvider LaunchHandoffTimeProvider, existing internal TimeSpan BuildTimeout/LaunchHandoffTimeout) are all internal. No public API was added, changed, or removed.
  • All other 6 changed files are under tests/Aspire.Hosting.Maui.Tests/ (test project file + test classes), matching pure test-only changes.
  • The PR description states this is purely about making timeout tests deterministic via an injectable TimeProvider and using a shared DefaultTimeout test helper - no behavior change is visible to Aspire users; the app model, dashboard UI, and public surface are unaffected.

Since there is no public API, CLI surface, configuration, dashboard behavior, or other user-facing change to describe, no documentation update is warranted on microsoft/aspire.dev. No create_pull_request was emitted.

@github-actions github-actions Bot locked and limited conversation to collaborators Oct 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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

3 participants