Skip to content

Commit

Permalink
[Mono.Android-Tests] Ignore "BadGateway" test failures. (#9687)
Browse files Browse the repository at this point in the history
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".
  • Loading branch information
jpobst authored Jan 16, 2025
1 parent fec3b79 commit f9f421b
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
Expand All @@ -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]
Expand Down

0 comments on commit f9f421b

Please sign in to comment.