1
1
// Licensed to the .NET Foundation under one or more agreements.
2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
4
- using System ;
5
- using System . Collections . Generic ;
6
4
using System . Diagnostics ;
7
- using System . IO ;
8
- using System . Linq ;
5
+ using System . Net ;
9
6
using System . Net . Http ;
10
- using System . Threading . Tasks ;
11
7
using System . Xml . Linq ;
12
8
using Microsoft . AspNetCore . Server . IntegrationTesting ;
13
9
using Microsoft . AspNetCore . Server . IntegrationTesting . IIS ;
14
10
using Microsoft . Extensions . Logging ;
15
11
using Newtonsoft . Json ;
16
- using Xunit ;
17
12
18
13
namespace Microsoft . AspNetCore . Server . IIS . FunctionalTests ;
19
14
@@ -29,11 +24,17 @@ public static string GetInProcessTestSitesName()
29
24
30
25
public static async Task AssertStarts ( this IISDeploymentResult deploymentResult , string path = "/HelloWorld" )
31
26
{
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 ) ;
34
29
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
+ }
37
38
}
38
39
39
40
public static async Task StressLoad ( HttpClient httpClient , string path , Action < HttpResponseMessage > action )
0 commit comments