Skip to content

Commit 57b5321

Browse files
authored
Fix flaky keepalive ping test (#24804)
* Fix flaky keepalive ping test * Clean up stream
1 parent ef1f48a commit 57b5321

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2TimeoutTests.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ await ExpectAsync(Http2FrameType.PING,
147147
}
148148

149149
[Fact]
150+
[QuarantinedTest]
150151
public async Task PING_NoKeepAliveTimeout_DoesNotResetKeepAliveTimeout()
151152
{
152153
var mockSystemClock = _serviceContext.MockSystemClock;
@@ -156,13 +157,14 @@ public async Task PING_NoKeepAliveTimeout_DoesNotResetKeepAliveTimeout()
156157

157158
CreateConnection();
158159

159-
await InitializeConnectionAsync(_noopApplication);
160+
await InitializeConnectionAsync(_echoApplication);
160161

161162
// Connection starts and sets keep alive timeout
162163
_mockTimeoutControl.Verify(c => c.SetTimeout(It.IsAny<long>(), TimeoutReason.KeepAlive), Times.Once);
163164
_mockTimeoutControl.Verify(c => c.ResetTimeout(It.IsAny<long>(), TimeoutReason.KeepAlive), Times.Never);
164165
_mockTimeoutControl.Verify(c => c.CancelTimeout(), Times.Never);
165166

167+
// Stream will stay open because it is waiting for request body to end
166168
await StartStreamAsync(1, _browserRequestHeaders, endStream: false);
167169

168170
// Starting a stream cancels the keep alive timeout
@@ -176,6 +178,17 @@ await ExpectAsync(Http2FrameType.PING,
176178

177179
// Server doesn't reset keep alive timeout because it isn't running
178180
_mockTimeoutControl.Verify(c => c.ResetTimeout(It.IsAny<long>(), TimeoutReason.KeepAlive), Times.Never);
181+
182+
// End stream
183+
await SendDataAsync(1, _helloWorldBytes, endStream: true);
184+
await ExpectAsync(Http2FrameType.HEADERS,
185+
withLength: 32,
186+
withFlags: (byte)Http2HeadersFrameFlags.END_HEADERS,
187+
withStreamId: 1);
188+
await ExpectAsync(Http2FrameType.DATA,
189+
withLength: _helloWorldBytes.Length,
190+
withFlags: (byte)Http2DataFrameFlags.NONE,
191+
withStreamId: 1);
179192
}
180193

181194
[Fact]

0 commit comments

Comments
 (0)