From 8dd0cd5bbc800af5ab1e83774336353449e2606f Mon Sep 17 00:00:00 2001 From: Jonathan Pobst Date: Wed, 15 Jan 2025 11:48:03 -1000 Subject: [PATCH] [Mono.Android-Tests] Ignore "BadGateway" test failures. --- .../AndroidClientHandlerTests.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidClientHandlerTests.cs b/tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidClientHandlerTests.cs index a0dda8c2367..73603748541 100644 --- a/tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidClientHandlerTests.cs +++ b/tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidClientHandlerTests.cs @@ -258,8 +258,8 @@ public void Redirect_Without_Protocol_Works() RunIgnoringNetworkIssues (() => tr.Wait (), out connectionFailed); if (connectionFailed) return; - - tr.Result.EnsureSuccessStatusCode (); + + EnsureSuccessStatusCode (tr.Result); Assert.AreEqual (redirectedURI, tr.Result.RequestMessage.RequestUri, "Invalid redirected URI"); } } @@ -281,10 +281,21 @@ public void Redirect_POST_With_Content_Works () if (connectionFailed) return; - response.EnsureSuccessStatusCode (); + EnsureSuccessStatusCode (response); Assert.AreEqual (redirectedURI, response.RequestMessage.RequestUri, "Invalid redirected URI"); } } + + void EnsureSuccessStatusCode (HttpResponseMessage response) + { + // If we hit a 502 (which is quite common on CI) just ignore the test + if (response.StatusCode == HttpStatusCode.BadGateway) { + Assert.Ignore ($"Ignoring network failure: {response.StatusCode}"); + return; + } + + response.EnsureSuccessStatusCode (); + } } [TestFixture]