aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-feed-client/src/test/java
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2021-06-18 16:03:40 +0200
committerJon Marius Venstad <venstad@gmail.com>2021-06-21 09:33:03 +0200
commitdf729adc7deebaae7101b2342fa108c50dac5555 (patch)
treedca50c5776427352a75245cccb15d942ff44d869 /vespa-feed-client/src/test/java
parent43717db157aa47dbeae47d5d4ab8ab6256cf051c (diff)
Make throttler test scenario more tricky, and print stats
Diffstat (limited to 'vespa-feed-client/src/test/java')
-rw-r--r--vespa-feed-client/src/test/java/ai/vespa/feed/client/HttpRequestStrategyTest.java19
1 files changed, 16 insertions, 3 deletions
diff --git a/vespa-feed-client/src/test/java/ai/vespa/feed/client/HttpRequestStrategyTest.java b/vespa-feed-client/src/test/java/ai/vespa/feed/client/HttpRequestStrategyTest.java
index fe62db9e0bb..4ef24713e9a 100644
--- a/vespa-feed-client/src/test/java/ai/vespa/feed/client/HttpRequestStrategyTest.java
+++ b/vespa-feed-client/src/test/java/ai/vespa/feed/client/HttpRequestStrategyTest.java
@@ -13,6 +13,7 @@ import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@@ -36,17 +37,29 @@ class HttpRequestStrategyTest {
HttpRequest request = new HttpRequest("PUT", "/", null, null);
HttpResponse response = HttpResponse.of(200, "{}".getBytes(UTF_8));
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
- Cluster cluster = new BenchmarkingCluster((__, vessel) -> executor.schedule(() -> vessel.complete(response), 100, TimeUnit.MILLISECONDS));
+ Cluster cluster = new BenchmarkingCluster((__, vessel) -> executor.schedule(() -> vessel.complete(response), (int) (Math.random() * 2 * 10), TimeUnit.MILLISECONDS));
HttpRequestStrategy strategy = new HttpRequestStrategy(FeedClientBuilder.create(URI.create("https://dummy.com:123"))
- .setConnectionsPerEndpoint(1 << 12)
- .setMaxStreamPerConnection(1 << 4),
+ .setConnectionsPerEndpoint(1 << 4)
+ .setMaxStreamPerConnection(1 << 20),
cluster);
+ CountDownLatch latch = new CountDownLatch(1);
+ new Thread(() -> {
+ try {
+ while ( ! latch.await(1, TimeUnit.SECONDS)) {
+ System.err.println(cluster.stats().inflight());
+ System.err.println(strategy.throttler.targetInflight());
+ System.err.println();
+ }
+ }
+ catch (InterruptedException ignored) { }
+ }).start();
long startNanos = System.nanoTime();
for (int i = 0; i < documents; i++)
strategy.enqueue(DocumentId.of("ns", "type", Integer.toString(i)), request);
strategy.await();
+ latch.countDown();
executor.shutdown();
cluster.close();
OperationStats stats = cluster.stats();