Tests: Stop measuring request time in HTTP pipelining tests
This destabilizes tests on virtualized hardware. Functionality testing is sufficient here. Performance tests should to be conducted elsewhere.
This commit is contained in:
parent
443c98477f
commit
f50deecf12
|
@ -74,11 +74,7 @@ public class NettyHttpClient implements Closeable {
|
|||
clientBootstrap = new ClientBootstrap(new NioClientSocketChannelFactory());;
|
||||
}
|
||||
|
||||
public Collection<HttpResponse> sendRequests(SocketAddress remoteAddress, String... uris) throws InterruptedException {
|
||||
return sendRequests(remoteAddress, -1, uris);
|
||||
}
|
||||
|
||||
public synchronized Collection<HttpResponse> sendRequests(SocketAddress remoteAddress, long expectedMaxDuration, String... uris) throws InterruptedException {
|
||||
public synchronized Collection<HttpResponse> sendRequests(SocketAddress remoteAddress, String... uris) throws InterruptedException {
|
||||
final CountDownLatch latch = new CountDownLatch(uris.length);
|
||||
final Collection<HttpResponse> content = Collections.synchronizedList(new ArrayList<HttpResponse>(uris.length));
|
||||
|
||||
|
@ -89,8 +85,6 @@ public class NettyHttpClient implements Closeable {
|
|||
channelFuture = clientBootstrap.connect(remoteAddress);
|
||||
channelFuture.await(1000);
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
for (int i = 0; i < uris.length; i++) {
|
||||
final HttpRequest httpRequest = new DefaultHttpRequest(HTTP_1_1, HttpMethod.GET, uris[i]);
|
||||
httpRequest.headers().add(HOST, "localhost");
|
||||
|
@ -99,18 +93,12 @@ public class NettyHttpClient implements Closeable {
|
|||
}
|
||||
latch.await();
|
||||
|
||||
long duration = System.currentTimeMillis() - startTime;
|
||||
// make sure the request were executed in parallel
|
||||
if (expectedMaxDuration > 0) {
|
||||
assertThat(duration, is(lessThan(expectedMaxDuration)));
|
||||
}
|
||||
} finally {
|
||||
if (channelFuture != null) {
|
||||
channelFuture.getChannel().close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
|
|
|
@ -97,9 +97,8 @@ public class NettyHttpServerPipeliningTest extends ElasticsearchTestCase {
|
|||
InetSocketTransportAddress transportAddress = (InetSocketTransportAddress) httpServerTransport.boundAddress().boundAddress();
|
||||
|
||||
List<String> requests = Arrays.asList("/firstfast", "/slow?sleep=500", "/secondfast", "/slow?sleep=1000", "/thirdfast");
|
||||
long maxdurationInMilliSeconds = 1200;
|
||||
try (NettyHttpClient nettyHttpClient = new NettyHttpClient()) {
|
||||
Collection<HttpResponse> responses = nettyHttpClient.sendRequests(transportAddress.address(), maxdurationInMilliSeconds, requests.toArray(new String[]{}));
|
||||
Collection<HttpResponse> responses = nettyHttpClient.sendRequests(transportAddress.address(), requests.toArray(new String[]{}));
|
||||
Collection<String> responseBodies = returnHttpResponseBodies(responses);
|
||||
assertThat(responseBodies, contains("/firstfast", "/slow?sleep=500", "/secondfast", "/slow?sleep=1000", "/thirdfast"));
|
||||
}
|
||||
|
@ -114,9 +113,8 @@ public class NettyHttpServerPipeliningTest extends ElasticsearchTestCase {
|
|||
InetSocketTransportAddress transportAddress = (InetSocketTransportAddress) httpServerTransport.boundAddress().boundAddress();
|
||||
|
||||
List<String> requests = Arrays.asList("/slow?sleep=1000", "/firstfast", "/secondfast", "/thirdfast", "/slow?sleep=500");
|
||||
long maxdurationInMilliSeconds = 1200;
|
||||
try (NettyHttpClient nettyHttpClient = new NettyHttpClient()) {
|
||||
Collection<HttpResponse> responses = nettyHttpClient.sendRequests(transportAddress.address(), maxdurationInMilliSeconds, requests.toArray(new String[]{}));
|
||||
Collection<HttpResponse> responses = nettyHttpClient.sendRequests(transportAddress.address(), requests.toArray(new String[]{}));
|
||||
List<String> responseBodies = Lists.newArrayList(returnHttpResponseBodies(responses));
|
||||
// we cannot be sure about the order of the fast requests, but the slow ones should have to be last
|
||||
assertThat(responseBodies, hasSize(5));
|
||||
|
|
Loading…
Reference in New Issue