Add socket timeout in MockTcpTransport

With this commit we set an explicit socket timeout in
MockTcpTransport to avoid hanging tests in case of disconnections.
This commit is contained in:
Daniel Mitterdorfer 2016-07-26 16:04:51 +02:00
parent 7ed64af639
commit b208a7dbae
2 changed files with 1 additions and 1 deletions

View File

@ -488,7 +488,6 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
assertThat(latch.await(5, TimeUnit.SECONDS), equalTo(true));
}
@TestLogging("transport:DEBUG")
public void testConcurrentSendRespondAndDisconnect() throws BrokenBarrierException, InterruptedException {
Set<Exception> sendingErrors = ConcurrentCollections.newConcurrentSet();
Set<Exception> responseErrors = ConcurrentCollections.newConcurrentSet();

View File

@ -210,6 +210,7 @@ public class MockTcpTransport extends TcpTransport<MockTcpTransport.MockChannel>
private void configureSocket(Socket socket) throws SocketException {
socket.setTcpNoDelay(TCP_NO_DELAY.get(settings));
socket.setSoTimeout(15000);
ByteSizeValue tcpSendBufferSize = TCP_SEND_BUFFER_SIZE.get(settings);
if (tcpSendBufferSize.bytes() > 0) {
socket.setSendBufferSize(tcpSendBufferSize.bytesAsInt());