Fix flaky test by ignoring indeterminant response

This commit is contained in:
John Luo 2018-09-07 18:18:02 -07:00
parent 5ba327faa1
commit e5b2b680e0
2 changed files with 10 additions and 4 deletions

View File

@ -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);

View File

@ -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)