Fixed tests that were trying to connecting to 0.0.0.1.

On new Linux kernels, at least, trying to connect to 0.0.0.1
hangs, while before it was failing immediately.
The tests have now a short connect timeout to avoid to hang.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2019-11-07 22:24:08 +01:00
parent cc289980cf
commit b119a8f59f
1 changed files with 8 additions and 4 deletions

View File

@ -988,7 +988,9 @@ public class HttpClientStreamTest extends AbstractTest<TransportScenario>
public void testUploadWithOutputStreamFailureToConnect(Transport transport) throws Exception
{
init(transport);
scenario.start(new EmptyServerHandler());
long connectTimeout = 1000;
scenario.start(new EmptyServerHandler(), httpClient -> httpClient.setConnectTimeout(connectTimeout));
final byte[] data = new byte[512];
final CountDownLatch latch = new CountDownLatch(1);
@ -1013,7 +1015,7 @@ public class HttpClientStreamTest extends AbstractTest<TransportScenario>
}
});
assertTrue(latch.await(5, TimeUnit.SECONDS));
assertTrue(latch.await(2 * connectTimeout, TimeUnit.SECONDS));
}
@ParameterizedTest
@ -1070,7 +1072,9 @@ public class HttpClientStreamTest extends AbstractTest<TransportScenario>
public void testUploadWithConnectFailureClosesStream(Transport transport) throws Exception
{
init(transport);
scenario.start(new EmptyServerHandler());
long connectTimeout = 1000;
scenario.start(new EmptyServerHandler(), httpClient -> httpClient.setConnectTimeout(connectTimeout));
final CountDownLatch closeLatch = new CountDownLatch(1);
InputStream stream = new ByteArrayInputStream("test".getBytes(StandardCharsets.UTF_8))
@ -1097,7 +1101,7 @@ public class HttpClientStreamTest extends AbstractTest<TransportScenario>
completeLatch.countDown();
});
assertTrue(completeLatch.await(5, TimeUnit.SECONDS));
assertTrue(completeLatch.await(2 * connectTimeout, TimeUnit.SECONDS));
assertTrue(closeLatch.await(5, TimeUnit.SECONDS));
}