Skip to content

[tests] Fix flaky SecureTransportTest.Tls12 by ignoring network timeouts in CI#25302

Open
rolfbjarne wants to merge 2 commits intomainfrom
dev/rolf/25241-fix-flaky-tls12-test
Open

[tests] Fix flaky SecureTransportTest.Tls12 by ignoring network timeouts in CI#25302
rolfbjarne wants to merge 2 commits intomainfrom
dev/rolf/25241-fix-flaky-tls12-test

Conversation

@rolfbjarne
Copy link
Copy Markdown
Member

@rolfbjarne rolfbjarne commented May 4, 2026

Wrap the Tls12 test body in a try/catch that calls TestRuntime.IgnoreInCIIfBadNetwork to mark the test as ignored (rather than failed) when transient network issues occur in CI.

Also extend IgnoreInCIIfTimedOut to handle SocketException timeouts, not just WebException timeouts, so that the SocketException thrown by TcpClient is properly recognized.

Fixes #25241

…uts in CI

Wrap the Tls12 test body in a try/catch that calls
TestRuntime.IgnoreInCIIfBadNetwork to mark the test as ignored (rather
than failed) when transient network issues occur in CI.

Also extend IgnoreInCIIfTimedOut to handle SocketException timeouts, not
just WebException timeouts, so that the SocketException thrown by
TcpClient is properly recognized.

Fixes #25241

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 4, 2026 07:51
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

This PR aims to reduce flakiness in the SecureTransport external-network test suite by treating transient CI network timeouts as ignorable test noise instead of hard failures. It updates the SecureTransport TLS 1.2 test and the shared test runtime helper that classifies transient network errors across the repository.

Changes:

  • Wrapped SecureTransportTest.Tls12 in a try/catch so CI can ignore recognized transient network failures instead of failing the test.
  • Extended TestRuntime.IgnoreInCIIfTimedOut (Exception ex) to recognize SocketException timeouts in addition to the existing WebException timeout handling.
  • Kept the existing TLS 1.2 handshake/request assertions intact while routing failures through the shared CI network-flake helper.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
tests/monotouch-test/Security/SecureTransportTest.cs Adds CI-specific bad-network handling around the external TLS 1.2 test.
tests/common/TestRuntime.cs Extends shared timeout classification so socket connect timeouts can be ignored in CI.

Comment on lines +143 to +148
var result = ssl.Handshake ();
while (result == SslStatus.WouldBlock || result == (SslStatus) (-108)) {
// we need to ask again - but if we're too fast we'll get -108 (errSecAllocate)
Thread.Sleep (100);
// during the above call SessionState is Handshake
Assert.That (ssl.SessionState, Is.EqualTo (SslSessionState.Handshake), "Handshake/in progress");
Comment on lines 164 to +166
result = ssl.Read (data, out processed);
Assert.That (result, Is.EqualTo (SslStatus.Success), "Read");

string s = Encoding.UTF8.GetString (data, 0, (int) processed);
// The result apparently depends on where you are: I get a 302, the bots get a 200.
// Also sometimes it fails with 502 Bad Gateway on the bots
Assert.That (s, Does.StartWith ("HTTP/1.0 302 Found").Or.StartWith ("HTTP/1.0 200 OK").Or.StartWith ("HTTP/1.0 502 Bad Gateway"), "response");
while (result == SslStatus.WouldBlock)
result = ssl.Read (data, out processed);
Comment on lines +144 to +145
while (result == SslStatus.WouldBlock || result == (SslStatus) (-108)) {
// we need to ask again - but if we're too fast we'll get -108 (errSecAllocate)
- Add 30-second deadlines to both the handshake and read retry loops to
  prevent indefinite hangs in CI.
- Replace magic number -108 with the existing errSecAllocate constant.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

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

✅ [PR Build #9a8e2ad] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 9a8e2ad48b8a8561c72a70dd01fefc8a9020ea54 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

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

✅ [PR Build #9a8e2ad] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 9a8e2ad48b8a8561c72a70dd01fefc8a9020ea54 [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: 9a8e2ad48b8a8561c72a70dd01fefc8a9020ea54 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

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

✅ [PR Build #9a8e2ad] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 9a8e2ad48b8a8561c72a70dd01fefc8a9020ea54 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

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

🔥 [CI Build #9a8e2ad] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

2 tests crashed, 1 tests failed, 160 tests passed.

Failures

❌ monotouch tests (iOS)

1 tests failed, 12 tests passed.

Failed tests

  • monotouch-test/iOS - simulator/Release (trimmable static registrar, NativeAOT, ARM64): Crashed

Html Report (VSDrops) Download

❌ windows tests

🔥 Failed catastrophically on VSTS: test results - windows (no summary found).

Html Report (VSDrops) Download

❌ Tests on macOS Monterey (12) tests

🔥 Failed catastrophically on VSTS: test results - mac_monterey (no summary found).

Html Report (VSDrops) Download

Successes

✅ 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 (MacCatalyst): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 13 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 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 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: 9a8e2ad48b8a8561c72a70dd01fefc8a9020ea54 [PR build]

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.Security.SecureTransportTest.Tls12

4 participants