Skip to content

Commit

Permalink
Fix timing issues with Http2_PingKeepAlive test. (#40788)
Browse files Browse the repository at this point in the history
  • Loading branch information
ManickaP committed Aug 14, 2020
1 parent 056f728 commit 6cc7cff
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,7 @@ await Http2LoopbackServer.CreateClientAndServerAsync(
}
// Let connection live until server finishes.
await serverFinished.Task.TimeoutAfter(pingTimeout * 2);
await Task.WhenAny(serverFinished.Task, Task.Delay(pingTimeout * 3));
},
async server =>
{
Expand Down Expand Up @@ -1534,7 +1534,10 @@ await Http2LoopbackServer.CreateClientAndServerAsync(
{
ping = await connection.ReadPingAsync(pingTimeout);
}
await Task.Delay(pongDelay);
if (pongDelay > TimeSpan.Zero)
{
await Task.Delay(pongDelay);
}
await connection.SendPingAckAsync(ping.Data);
}
Expand All @@ -1555,6 +1558,16 @@ await Http2LoopbackServer.CreateClientAndServerAsync(
}
else
{
// If the pings were recently coming, just give the connection time to clear up streams
// and still accept one stray ping.
if (expectStreamPing)
{
try
{
await connection.ReadPingAsync(pingTimeout);
}
catch (OperationCanceledException) { } // if it failed once, it will fail again
}
await Assert.ThrowsAsync<OperationCanceledException>(() => connection.ReadPingAsync(pingTimeout));
}
serverFinished.SetResult();
Expand Down

0 comments on commit 6cc7cff

Please sign in to comment.