diff --git a/test/E2ETests/SmokeTests.cs b/test/E2ETests/SmokeTests.cs index 525df120f5..b444848875 100644 --- a/test/E2ETests/SmokeTests.cs +++ b/test/E2ETests/SmokeTests.cs @@ -66,11 +66,31 @@ namespace E2ETests httpClientHandler = new HttpClientHandler(); httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(applicationBaseUrl) }; + HttpResponseMessage response = null; + string responseContent = null; + var initializationCompleteTime = DateTime.MinValue; + //Request to base address and check if various parts of the body are rendered & measure the cold startup time. - var response = httpClient.GetAsync(string.Empty).Result; - var responseContent = response.Content.ReadAsStringAsync().Result; - var initializationCompleteTime = DateTime.Now; - Console.WriteLine("[Time]: Approximate time taken for application initialization : '{0}' seconds", (initializationCompleteTime - testStartTime).TotalSeconds); + for (int retryCount = 0; retryCount < 3; retryCount++) + { + try + { + response = httpClient.GetAsync(string.Empty).Result; + responseContent = response.Content.ReadAsStringAsync().Result; + initializationCompleteTime = DateTime.Now; + Console.WriteLine("[Time]: Approximate time taken for application initialization : '{0}' seconds", (initializationCompleteTime - testStartTime).TotalSeconds); + break; //Went through successfully + } + catch (AggregateException exception) + { + if (exception.InnerException is HttpRequestException) + { + Console.WriteLine("Failed to complete the request with error: {0}", exception.ToString()); + Console.WriteLine("Retrying request.."); + } + } + } + VerifyHomePage(response, responseContent); //Verify the static file middleware can serve static content