Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix timing issues with Http2_PingKeepAlive test. #40788

Merged
merged 1 commit into from
Aug 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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