Skip to content

Commit f9f421b

Browse files
authored
[Mono.Android-Tests] Ignore "BadGateway" test failures. (#9687)
Context: #2279 Building on #2279, the network tests in our "Packaging Tests" very frequently fail with `BadGateway`, indicating a server side problem. Our "fix" has been to rerun the tests until they pass. This wastes a considerable amount of developer and CI resources. Instead, let's detect this case and ignore the test so that it isn't reported as "failed".
1 parent fec3b79 commit f9f421b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidClientHandlerTests.cs

+14-3
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ public void Redirect_Without_Protocol_Works()
258258
RunIgnoringNetworkIssues (() => tr.Wait (), out connectionFailed);
259259
if (connectionFailed)
260260
return;
261-
262-
tr.Result.EnsureSuccessStatusCode ();
261+
262+
EnsureSuccessStatusCode (tr.Result);
263263
Assert.AreEqual (redirectedURI, tr.Result.RequestMessage.RequestUri, "Invalid redirected URI");
264264
}
265265
}
@@ -281,10 +281,21 @@ public void Redirect_POST_With_Content_Works ()
281281
if (connectionFailed)
282282
return;
283283

284-
response.EnsureSuccessStatusCode ();
284+
EnsureSuccessStatusCode (response);
285285
Assert.AreEqual (redirectedURI, response.RequestMessage.RequestUri, "Invalid redirected URI");
286286
}
287287
}
288+
289+
void EnsureSuccessStatusCode (HttpResponseMessage response)
290+
{
291+
// If we hit a 502 (which is quite common on CI) just ignore the test
292+
if (response.StatusCode == HttpStatusCode.BadGateway) {
293+
Assert.Ignore ($"Ignoring network failure: {response.StatusCode}");
294+
return;
295+
}
296+
297+
response.EnsureSuccessStatusCode ();
298+
}
288299
}
289300

290301
[TestFixture]

0 commit comments

Comments
 (0)