From 652c529f8f0baa2c4504c377bf0d17a1c7ca69cf Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Mon, 30 Jul 2018 14:52:04 -0700 Subject: [PATCH] Fix ServerShutsDownWhenMainExits test (#1120) --- .../InProcess/ShutdownTests.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/IISExpress.FunctionalTests/InProcess/ShutdownTests.cs b/test/IISExpress.FunctionalTests/InProcess/ShutdownTests.cs index b1ab071c5d..45c9e080aa 100644 --- a/test/IISExpress.FunctionalTests/InProcess/ShutdownTests.cs +++ b/test/IISExpress.FunctionalTests/InProcess/ShutdownTests.cs @@ -1,6 +1,9 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; +using System.IO; +using System.Net.Http; using System.Threading.Tasks; using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities; using Microsoft.AspNetCore.Server.IntegrationTesting; @@ -22,8 +25,14 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests { var parameters = Helpers.GetBaseDeploymentParameters(publish: true); var result = await DeployAsync(parameters); - - var response = await result.RetryingHttpClient.GetAsync("/Shutdown"); + try + { + await result.HttpClient.GetAsync("/Shutdown"); + } + catch (HttpRequestException ex) when (ex.InnerException is IOException) + { + // Server might close a connection before request completes + } Assert.True(result.HostShutdownToken.WaitHandle.WaitOne(TimeoutExtensions.DefaultTimeout)); }