From 112c8328a61009962aa0321590d7937a0aa69dff Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Wed, 22 Mar 2023 16:04:08 +0000 Subject: [PATCH] [tests] Add backup ssl sites in case of 429 response. (#7909) 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. --- .../System.Net/ProxyTest.cs | 2 +- .../Mono.Android-Tests/System.Net/SslTest.cs | 21 +++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/tests/Mono.Android-Tests/System.Net/ProxyTest.cs b/tests/Mono.Android-Tests/System.Net/ProxyTest.cs index efe746c7cee..a8149eccd3c 100644 --- a/tests/Mono.Android-Tests/System.Net/ProxyTest.cs +++ b/tests/Mono.Android-Tests/System.Net/ProxyTest.cs @@ -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 (); diff --git a/tests/Mono.Android-Tests/System.Net/SslTest.cs b/tests/Mono.Android-Tests/System.Net/SslTest.cs index 37662f646e8..934435d52fb 100644 --- a/tests/Mono.Android-Tests/System.Net/SslTest.cs +++ b/tests/Mono.Android-Tests/System.Net/SslTest.cs @@ -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];