Skip to content

Handle transient ConnectException globally in on-device HTTP tests - #11057

Merged
jonathanpeppers merged 3 commits into
mainfrom
copilot/fix-flaky-connection-test
Mar 31, 2026
Merged

Handle transient ConnectException globally in on-device HTTP tests#11057
jonathanpeppers merged 3 commits into
mainfrom
copilot/fix-flaky-connection-test

Conversation

Copilot AI commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a flaky test failure in AndroidMessageHandlerSendsClientCertificate caused by transient network connectivity issues when connecting to corefx-net-tls.azurewebsites.net.

Problem

The test Xamarin.Android.NetTests.AndroidMessageHandlerTests.AndroidMessageHandlerSendsClientCertificate(False) fails intermittently with:

System.AggregateException : AggregateException_ctor_DefaultMessage (Connection failure)
----> System.Net.Http.HttpRequestException : Connection failure
----> Java.Net.ConnectException : Failed to connect to corefx-net-tls.azurewebsites.net/104.40.28.133:443

This is a transient network error unrelated to the functionality being tested.

Fix

Added Java.Net.ConnectException handling to the global IgnoreIfConnectionFailed(HttpRequestException) method in HttpClientHandlerTestBase, following the same pattern as the existing IOException check added in commit 1047b55. This ensures all on-device HTTP tests that use the shared helper methods (RunIgnoringNetworkIssues, ConnectIgnoreFailure, IgnoreIfConnectionFailed) automatically benefit from the new check. No per-test changes are needed.

…Certificate test

Agent-Logs-Url: https://github.com/dotnet/android/sessions/1a564216-e64a-43b1-8ce0-919d7bae7020

Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
…iled helper

Agent-Logs-Url: https://github.com/dotnet/android/sessions/b5e86868-a3b2-488b-ab9c-1f1f9f832db4

Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot AI changed the title Handle transient ConnectException in AndroidMessageHandlerSendsClientCertificate test Handle transient ConnectException globally in on-device HTTP tests Mar 30, 2026
Copilot AI requested a review from jonathanpeppers March 30, 2026 21:16
… global fix

Agent-Logs-Url: https://github.com/dotnet/android/sessions/1146d37f-4036-4a89-91ba-6ca76a3adb27

Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
@simonrozsival simonrozsival added copilot `copilot-cli` or other AIs were used to author this trimmable-type-map and removed copilot `copilot-cli` or other AIs were used to author this trimmable-type-map labels Mar 31, 2026
@jonathanpeppers
jonathanpeppers marked this pull request as ready for review March 31, 2026 13:35
Copilot AI review requested due to automatic review settings March 31, 2026 13:35

@jonathanpeppers jonathanpeppers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No tests failed here:

Image

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.

Pull request overview

This PR reduces flakiness in on-device HTTP tests by treating Java.Net.ConnectException as a transient network failure and ignoring affected test runs via the shared HttpClientHandlerTestBase helpers.

Changes:

  • Extend HttpClientHandlerTestBase.IgnoreIfConnectionFailed (HttpRequestException, ...) to ignore Java.Net.ConnectException as a transient connection failure.

@jonathanpeppers
jonathanpeppers merged commit b1be05b into main Mar 31, 2026
5 of 10 checks passed
@jonathanpeppers
jonathanpeppers deleted the copilot/fix-flaky-connection-test branch March 31, 2026 13:37
@github-actions github-actions Bot locked and limited conversation to collaborators May 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants