Improve cdn test reliability (#6044)
This commit is contained in:
parent
686ce02cc8
commit
efe9b95b14
|
|
@ -7,6 +7,7 @@ using System.IO;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using Xunit.Abstractions;
|
using Xunit.Abstractions;
|
||||||
|
|
@ -38,7 +39,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
||||||
Assert.NotEmpty(scriptTags);
|
Assert.NotEmpty(scriptTags);
|
||||||
|
|
||||||
var shasum = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
var shasum = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||||
using (var client = new HttpClient())
|
using (var client = new HttpClient(new RetryHandler(new HttpClientHandler() { })))
|
||||||
{
|
{
|
||||||
foreach (var script in scriptTags)
|
foreach (var script in scriptTags)
|
||||||
{
|
{
|
||||||
|
|
@ -62,6 +63,25 @@ namespace Microsoft.AspNetCore.Identity.Test
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class RetryHandler : DelegatingHandler
|
||||||
|
{
|
||||||
|
public RetryHandler(HttpMessageHandler innerHandler) : base(innerHandler) { }
|
||||||
|
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
HttpResponseMessage result = null;
|
||||||
|
for (var i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
result = await base.SendAsync(request, cancellationToken);
|
||||||
|
if (result.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
await Task.Delay(1000);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private struct ScriptTag
|
private struct ScriptTag
|
||||||
{
|
{
|
||||||
public string Src;
|
public string Src;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue