Skip to content

Commit

Permalink
[tests] Add backup ssl sites in case of 429 response. (dotnet#7909)
Browse files Browse the repository at this point in the history
Our SSL test can fail quite often with a HTTP-429 Too Many Requests
error.  This makes the CI very unstable as we are constantly having
to wait and retry the tests.

Improve this by putting that logic into the test itself.  If we get
an HTTP-429 we should try some other SSL site.
  • Loading branch information
dellis1972 authored Mar 22, 2023
1 parent 9d6e735 commit 112c832
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/Mono.Android-Tests/System.Net/ProxyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ProxyTest {
[Test]
public void QuoteInvalidQuoteUrlsShouldWork ()
{
string url = "http://example.com/?query&foo|bar";
string url = "https://bing.com/?query&foo|bar";
var request = (HttpWebRequest) WebRequest.Create (url);
request.Method = "GET";
var response = (HttpWebResponse) request.GetResponse ();
Expand Down
21 changes: 17 additions & 4 deletions tests/Mono.Android-Tests/System.Net/SslTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,24 @@ public void HttpsShouldWork ()
void DoHttpsShouldWork ()
{
// string url = "https://bugzilla.novell.com/show_bug.cgi?id=634817";
string url = "https://encrypted.google.com/";
string[] urls = new string[] {
"https://dotnet.microsoft.com/",
"https://www.bing.com/",
"https://httpbin.org/get",
};
// string url = "http://slashdot.org";
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
request.Method = "GET";
var response = (HttpWebResponse) request.GetResponse ();
HttpWebResponse response = null;
foreach (var url in urls) {
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
request.Method = "GET";
response = (HttpWebResponse) request.GetResponse ();
if (response.StatusCode == HttpStatusCode.TooManyRequests) {
// try the next url.
continue;
}
break;
}
Assert.IsNotNull (response);
int len = 0;
using (var _r = new StreamReader (response.GetResponseStream ())) {
char[] buf = new char [4096];
Expand Down

0 comments on commit 112c832

Please sign in to comment.