Skip to content

Fix flaky UrlProtocolTest.RegistrarTest race condition. Fixes #25223#25255

Merged
rolfbjarne merged 2 commits intomainfrom
dev/rolf/fix-urlprotocoltest-flaky
Apr 30, 2026
Merged

Fix flaky UrlProtocolTest.RegistrarTest race condition. Fixes #25223#25255
rolfbjarne merged 2 commits intomainfrom
dev/rolf/fix-urlprotocoltest-flaky

Conversation

@rolfbjarne
Copy link
Copy Markdown
Member

StopLoading is called asynchronously by the URL loading system after the download task completes. The test was asserting State==5 immediately when the task finished, but StopLoading (which increments State from 4 to 5) hadn't fired yet.

Fix by:

  • Using the RunAsync(timeout, task, check_completed) overload that polls until State>=5 instead of returning as soon as the task completes.
  • Resetting State=0 at test start to prevent cross-test interference.

Fixes #25223

StopLoading is called asynchronously by the URL loading system after the
download task completes. The test was asserting State==5 immediately when
the task finished, but StopLoading (which increments State from 4 to 5)
hadn't fired yet.

Fix by:
- Using the RunAsync(timeout, task, check_completed) overload that polls
  until State>=5 instead of returning as soon as the task completes.
- Resetting State=0 at test start to prevent cross-test interference.

Fixes #25223

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 27, 2026 17:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a race in the UrlProtocolTest.RegistrarTest where the test could assert State == 5 before NSUrlProtocol.StopLoading had been invoked, causing intermittent failures on CI (issue #25223).

Changes:

  • Reset CustomUrlProtocol.State at the start of RegistrarTest to avoid cross-test interference.
  • Switch to the TestRuntime.RunAsync(timeout, task, check_completed) overload to wait until CustomUrlProtocol.State >= 5 (i.e., until StopLoading has fired), not just until the download task completes.

@rolfbjarne rolfbjarne enabled auto-merge (squash) April 28, 2026 07:39
…coltest-flaky

# Conflicts:
#	tests/monotouch-test/Foundation/UrlProtocolTest.cs
@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [PR Build #859b6c4] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 859b6c45d20080f5846d77fde7167d685ff90053 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [PR Build #859b6c4] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 859b6c45d20080f5846d77fde7167d685ff90053 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 859b6c45d20080f5846d77fde7167d685ff90053 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [CI Build #859b6c4] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 859b6c45d20080f5846d77fde7167d685ff90053 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

🚀 [CI Build #859b6c4] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 156 tests passed 🎉

Tests counts

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 6 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 12 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 11 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: 859b6c45d20080f5846d77fde7167d685ff90053 [PR build]

@rolfbjarne rolfbjarne merged commit eabae33 into main Apr 30, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI Postmortem] Flaky: MonoTouchFixtures.Foundation.UrlProtocolTest.RegistrarTest

4 participants