blob: cea5d32a55a0e759c43bb9745ddeb41c73728e99 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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 < 65; i++) {
throttler.sent(1, null);
throttler.success();
}
assertEquals(18, throttler.targetInflight());
throttler.throttled(34);
assertEquals(17, throttler.targetInflight());
}
}
|