Skip to content

Commit

Permalink
Add timeouts to SendAsync_CorrectVersionSelected_LoopbackServer (#56546)
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaZupan authored Jul 29, 2021
1 parent 02e6152 commit d85c77a
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,8 @@ await HttpAgnosticLoopbackServer.CreateClientAndServerAsync(
handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
}
using HttpClient client = CreateHttpClient(handler);
client.Timeout = TimeSpan.FromSeconds(30);

if (expectedResult is Type type)
{
Exception exception = await Assert.ThrowsAnyAsync<Exception>(() => client.SendAsync(request));
Expand All @@ -1186,10 +1188,10 @@ await HttpAgnosticLoopbackServer.CreateClientAndServerAsync(
{
try
{
HttpRequestData requestData = await server.AcceptConnectionSendResponseAndCloseAsync();
HttpRequestData requestData = await server.HandleRequestAsync().WaitAsync(TimeSpan.FromSeconds(30));
Assert.Equal(expectedResult, requestData.Version);
}
catch (Exception ex) when (expectedResult is Type)
catch (Exception ex) when (ex is not TaskCanceledException && expectedResult is Type)
{
_output.WriteLine("Server exception: " + ex.ToString());
}
Expand Down

0 comments on commit d85c77a

Please sign in to comment.