From b208a7dbaeeb269e6d1e121f46a29cb6b0f8004f Mon Sep 17 00:00:00 2001 From: Daniel Mitterdorfer Date: Tue, 26 Jul 2016 16:04:51 +0200 Subject: [PATCH] Add socket timeout in MockTcpTransport With this commit we set an explicit socket timeout in MockTcpTransport to avoid hanging tests in case of disconnections. --- .../elasticsearch/transport/AbstractSimpleTransportTestCase.java | 1 - .../main/java/org/elasticsearch/transport/MockTcpTransport.java | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/test/framework/src/main/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java b/test/framework/src/main/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java index 58cc45a75a1..e7f659751b5 100644 --- a/test/framework/src/main/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java @@ -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 sendingErrors = ConcurrentCollections.newConcurrentSet(); Set responseErrors = ConcurrentCollections.newConcurrentSet(); diff --git a/test/framework/src/main/java/org/elasticsearch/transport/MockTcpTransport.java b/test/framework/src/main/java/org/elasticsearch/transport/MockTcpTransport.java index 44a2bbd2166..8a0828794da 100644 --- a/test/framework/src/main/java/org/elasticsearch/transport/MockTcpTransport.java +++ b/test/framework/src/main/java/org/elasticsearch/transport/MockTcpTransport.java @@ -210,6 +210,7 @@ public class MockTcpTransport extends TcpTransport 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());