Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/aspnetcore.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHao Kung <HaoK@users.noreply.github.com>2022-03-26 02:03:13 +0300
committerHao Kung <HaoK@users.noreply.github.com>2022-03-26 02:03:13 +0300
commit238349affcd371d14b361672f2f700c830f59218 (patch)
treee476bada2f76d178a5eb89fd4ed2db2d7f7e44b8
parent08f69674f2fb1e3b64feb0d6e18a470558abdfe6 (diff)
Harden assert starts insteadhaok/recycle
-rw-r--r--src/Servers/IIS/IIS/test/Common.FunctionalTests/Infrastructure/Helpers.cs35
1 files changed, 12 insertions, 23 deletions
diff --git a/src/Servers/IIS/IIS/test/Common.FunctionalTests/Infrastructure/Helpers.cs b/src/Servers/IIS/IIS/test/Common.FunctionalTests/Infrastructure/Helpers.cs
index b8e9c50aff..fff65832af 100644
--- a/src/Servers/IIS/IIS/test/Common.FunctionalTests/Infrastructure/Helpers.cs
+++ b/src/Servers/IIS/IIS/test/Common.FunctionalTests/Infrastructure/Helpers.cs
@@ -1,20 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System;
-using System.Collections.Generic;
using System.Diagnostics;
-using System.IO;
-using System.Linq;
+using System.Net;
using System.Net.Http;
-using System.Threading.Tasks;
using System.Xml.Linq;
using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
-using Xunit;
-using Xunit.Sdk;
namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests;
@@ -30,11 +24,17 @@ public static class Helpers
public static async Task AssertStarts(this IISDeploymentResult deploymentResult, string path = "/HelloWorld")
{
- var response = await deploymentResult.HttpClient.GetAsync(path);
-
+ // Sometimes the site is not ready, so retry until its actually started and ready
+ var response = await deploymentResult.HttpClient.RetryRequestAsync(path, r => r.IsSuccessStatusCode);
var responseText = await response.Content.ReadAsStringAsync();
-
- Assert.Equal("Hello World", responseText);
+ if (response.IsSuccessStatusCode)
+ {
+ Assert.Equal("Hello World", responseText);
+ }
+ else
+ {
+ throw new Exception($"Server not started successfully, recieved non success status code, responseText: {responseText}");
+ }
}
public static async Task StressLoad(HttpClient httpClient, string path, Action<HttpResponseMessage> action)
@@ -170,18 +170,7 @@ public static class Helpers
deploymentResult.AssertWorkerProcessStop();
if (deploymentResult.DeploymentParameters.ServerType == ServerType.IIS)
{
- verificationAction = verificationAction ?? (async () =>
- {
- // Very rarely the server will be shutting down still, so we will attempt a single retry
- try
- {
- await deploymentResult.AssertStarts();
- }
- catch (EqualException)
- {
- await deploymentResult.AssertStarts();
- }
- });
+ verificationAction = verificationAction ?? (() => deploymentResult.AssertStarts());
await verificationAction();
}
}