summaryrefslogtreecommitdiffstats
path: root/vespa-feed-client/src/test
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2024-05-13 12:21:20 +0200
committerjonmv <venstad@gmail.com>2024-05-13 12:21:20 +0200
commitc6d8d30bd76f426cd8b2fd45c125c6da57c768f1 (patch)
tree3fa36fd75cf812ef9291ea821bb5ae72d3add106 /vespa-feed-client/src/test
parentf951681e3e1076606da092437a32c92454533e14 (diff)
Improve feed throttler and tests
Diffstat (limited to 'vespa-feed-client/src/test')
-rw-r--r--vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/DynamicThrottlerTest.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/DynamicThrottlerTest.java b/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/DynamicThrottlerTest.java
new file mode 100644
index 00000000000..7e07fc6e116
--- /dev/null
+++ b/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/DynamicThrottlerTest.java
@@ -0,0 +1,30 @@
+package ai.vespa.feed.client.impl;
+
+import org.junit.jupiter.api.Test;
+
+import java.net.URI;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * @author jonmv
+ */
+class DynamicThrottlerTest {
+
+ @Test
+ void testThrottler() {
+ DynamicThrottler throttler = new DynamicThrottler(new FeedClientBuilderImpl(List.of(URI.create("http://localhost:8080"))));
+ assertEquals(16, throttler.targetInflight());
+
+ for (int i = 0; i < 30; i++) {
+ throttler.sent(1, null);
+ throttler.success();
+ }
+ assertEquals(18, throttler.targetInflight());
+
+ throttler.throttled(34);
+ assertEquals(17, throttler.targetInflight());
+ }
+
+}