Skip to content
代码片段 群组 项目
提交 e5b2b680 编辑于 作者: John Luo's avatar John Luo
浏览文件

Fix flaky test by ignoring indeterminant response

上级 5ba327fa
No related branches found
No related tags found
无相关合并请求
......@@ -678,7 +678,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
connection.Socket.Shutdown(SocketShutdown.Send);
await connection.ReceiveEnd();
await connection.ReceiveEnd(ignoreResponse: true);
var badReqEx = await exTcs.Task.TimeoutAfter(TestConstants.DefaultTimeout);
Assert.Equal(RequestRejectionReason.UnexpectedEndOfRequestContent, badReqEx.Reason);
......
......@@ -149,14 +149,20 @@ namespace Microsoft.AspNetCore.Testing
Assert.Equal(expected, new string(actual, 0, offset));
}
public async Task ReceiveEnd(params string[] lines)
public Task ReceiveEnd(params string[] lines)
=> ReceiveEnd(false, lines);
public async Task ReceiveEnd(bool ignoreResponse, params string[] lines)
{
await Receive(lines).ConfigureAwait(false);
_socket.Shutdown(SocketShutdown.Send);
var ch = new char[128];
var count = await _reader.ReadAsync(ch, 0, 128).TimeoutAfter(Timeout).ConfigureAwait(false);
var text = new string(ch, 0, count);
Assert.Equal("", text);
if (!ignoreResponse)
{
var text = new string(ch, 0, count);
Assert.Equal("", text);
}
}
public async Task ReceiveForcedEnd(params string[] lines)
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册