Skip to content

Commit 6933e7c

Browse files
authored
Harden AssertRecycle (#40878)
1 parent 33cbbc4 commit 6933e7c

File tree

1 file changed

+11
-10
lines changed
  • src/Servers/IIS/IIS/test/Common.FunctionalTests/Infrastructure

1 file changed

+11
-10
lines changed

src/Servers/IIS/IIS/test/Common.FunctionalTests/Infrastructure/Helpers.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System;
5-
using System.Collections.Generic;
64
using System.Diagnostics;
7-
using System.IO;
8-
using System.Linq;
5+
using System.Net;
96
using System.Net.Http;
10-
using System.Threading.Tasks;
117
using System.Xml.Linq;
128
using Microsoft.AspNetCore.Server.IntegrationTesting;
139
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
1410
using Microsoft.Extensions.Logging;
1511
using Newtonsoft.Json;
16-
using Xunit;
1712

1813
namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests;
1914

@@ -29,11 +24,17 @@ public static string GetInProcessTestSitesName()
2924

3025
public static async Task AssertStarts(this IISDeploymentResult deploymentResult, string path = "/HelloWorld")
3126
{
32-
var response = await deploymentResult.HttpClient.GetAsync(path);
33-
27+
// Sometimes the site is not ready, so retry until its actually started and ready
28+
var response = await deploymentResult.HttpClient.RetryRequestAsync(path, r => r.IsSuccessStatusCode);
3429
var responseText = await response.Content.ReadAsStringAsync();
35-
36-
Assert.Equal("Hello World", responseText);
30+
if (response.IsSuccessStatusCode)
31+
{
32+
Assert.Equal("Hello World", responseText);
33+
}
34+
else
35+
{
36+
throw new Exception($"Server not started successfully, recieved non success status code, responseText: {responseText}");
37+
}
3738
}
3839

3940
public static async Task StressLoad(HttpClient httpClient, string path, Action<HttpResponseMessage> action)

0 commit comments

Comments
 (0)