Skip to content

Commit 3012478

Browse files
committed
Fix local failure in GET_GracefulServerShutdown_AbortRequestsAfterHostTimeout
1 parent 4b8269f commit 3012478

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/Servers/Kestrel/test/Interop.FunctionalTests/Http3/Http3RequestTests.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,7 +2021,8 @@ public async Task GET_GracefulServerShutdown_AbortRequestsAfterHostTimeout(HttpP
20212021
listenOptions.Protocols = protocol;
20222022
listenOptions.UseHttps(TestResources.GetTestCertificate());
20232023
});
2024-
});
2024+
},
2025+
shutdownTimeout: TimeSpan.FromSeconds(2));
20252026

20262027
using (var host = builder.Build())
20272028
using (var client = HttpHelpers.CreateClient())
@@ -2061,17 +2062,21 @@ await WaitForLogAsync(logs =>
20612062
}, "Check for initial GOAWAY frame sent on server initiated shutdown.");
20622063
}
20632064

2065+
Logger.LogInformation("Getting read task");
20642066
var readTask = await readAsyncTask.Task.DefaultTimeout();
20652067

20662068
// Assert
2069+
Logger.LogInformation("Waiting for error from read task");
20672070
var ex = await Assert.ThrowsAnyAsync<Exception>(() => readTask).DefaultTimeout();
2068-
while (ex.InnerException != null)
2071+
2072+
var rootException = ex;
2073+
while (rootException.InnerException != null)
20692074
{
2070-
ex = ex.InnerException;
2075+
rootException = rootException.InnerException;
20712076
}
20722077

2073-
Assert.IsType<ConnectionAbortedException>(ex);
2074-
Assert.Equal("The connection was aborted because the server is shutting down and request processing didn't complete within the time specified by HostOptions.ShutdownTimeout.", ex.Message);
2078+
Assert.IsType<ConnectionAbortedException>(rootException);
2079+
Assert.Equal("The connection was aborted because the server is shutting down and request processing didn't complete within the time specified by HostOptions.ShutdownTimeout.", rootException.Message);
20752080

20762081
await requestAbortedTcs.Task.DefaultTimeout();
20772082

@@ -2191,8 +2196,8 @@ public async Task ServerReset_InvalidErrorCode()
21912196
Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
21922197
}
21932198

2194-
private IHostBuilder CreateHostBuilder(RequestDelegate requestDelegate, HttpProtocols? protocol = null, Action<KestrelServerOptions> configureKestrel = null)
2199+
private IHostBuilder CreateHostBuilder(RequestDelegate requestDelegate, HttpProtocols? protocol = null, Action<KestrelServerOptions> configureKestrel = null, TimeSpan? shutdownTimeout = null)
21952200
{
2196-
return HttpHelpers.CreateHostBuilder(AddTestLogging, requestDelegate, protocol, configureKestrel);
2201+
return HttpHelpers.CreateHostBuilder(AddTestLogging, requestDelegate, protocol, configureKestrel, shutdownTimeout: shutdownTimeout);
21972202
}
21982203
}

src/Servers/Kestrel/test/Interop.FunctionalTests/HttpHelpers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static HttpMessageInvoker CreateClient(TimeSpan? idleTimeout = null, Time
6363
return new HttpMessageInvoker(handler);
6464
}
6565

66-
public static IHostBuilder CreateHostBuilder(Action<IServiceCollection> configureServices, RequestDelegate requestDelegate, HttpProtocols? protocol = null, Action<KestrelServerOptions> configureKestrel = null, bool? plaintext = null)
66+
public static IHostBuilder CreateHostBuilder(Action<IServiceCollection> configureServices, RequestDelegate requestDelegate, HttpProtocols? protocol = null, Action<KestrelServerOptions> configureKestrel = null, bool? plaintext = null, TimeSpan? shutdownTimeout = null)
6767
{
6868
return new HostBuilder()
6969
.ConfigureWebHost(webHostBuilder =>
@@ -102,7 +102,7 @@ public static IHostBuilder CreateHostBuilder(Action<IServiceCollection> configur
102102
}
103103
else
104104
{
105-
o.ShutdownTimeout = TimeSpan.FromSeconds(5);
105+
o.ShutdownTimeout = shutdownTimeout ?? TimeSpan.FromSeconds(5);
106106
}
107107
});
108108
}

0 commit comments

Comments
 (0)