Browse Source

Add socket timeout in MockTcpTransport

With this commit we set an explicit socket timeout in
MockTcpTransport to avoid hanging tests in case of disconnections.
Daniel Mitterdorfer 9 years ago
parent
commit
b208a7dbae

+ 0 - 1
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<Exception> sendingErrors = ConcurrentCollections.newConcurrentSet();
         Set<Exception> responseErrors = ConcurrentCollections.newConcurrentSet();

+ 1 - 0
test/framework/src/main/java/org/elasticsearch/transport/MockTcpTransport.java

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