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:
parent
7ed64af639
commit
b208a7dbae
|
@ -488,7 +488,6 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
|
||||||
assertThat(latch.await(5, TimeUnit.SECONDS), equalTo(true));
|
assertThat(latch.await(5, TimeUnit.SECONDS), equalTo(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestLogging("transport:DEBUG")
|
|
||||||
public void testConcurrentSendRespondAndDisconnect() throws BrokenBarrierException, InterruptedException {
|
public void testConcurrentSendRespondAndDisconnect() throws BrokenBarrierException, InterruptedException {
|
||||||
Set<Exception> sendingErrors = ConcurrentCollections.newConcurrentSet();
|
Set<Exception> sendingErrors = ConcurrentCollections.newConcurrentSet();
|
||||||
Set<Exception> responseErrors = ConcurrentCollections.newConcurrentSet();
|
Set<Exception> responseErrors = ConcurrentCollections.newConcurrentSet();
|
||||||
|
|
|
@ -210,6 +210,7 @@ public class MockTcpTransport extends TcpTransport<MockTcpTransport.MockChannel>
|
||||||
|
|
||||||
private void configureSocket(Socket socket) throws SocketException {
|
private void configureSocket(Socket socket) throws SocketException {
|
||||||
socket.setTcpNoDelay(TCP_NO_DELAY.get(settings));
|
socket.setTcpNoDelay(TCP_NO_DELAY.get(settings));
|
||||||
|
socket.setSoTimeout(15000);
|
||||||
ByteSizeValue tcpSendBufferSize = TCP_SEND_BUFFER_SIZE.get(settings);
|
ByteSizeValue tcpSendBufferSize = TCP_SEND_BUFFER_SIZE.get(settings);
|
||||||
if (tcpSendBufferSize.bytes() > 0) {
|
if (tcpSendBufferSize.bytes() > 0) {
|
||||||
socket.setSendBufferSize(tcpSendBufferSize.bytesAsInt());
|
socket.setSendBufferSize(tcpSendBufferSize.bytesAsInt());
|
||||||
|
|
Loading…
Reference in New Issue