-
Notifications
You must be signed in to change notification settings - Fork 96
/
Copy pathTtlTest.java
68 lines (54 loc) · 1.92 KB
/
TtlTest.java
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package resilience.ttl;
import com.arangodb.ArangoDB;
import com.arangodb.ArangoDBAsync;
import com.arangodb.Protocol;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import resilience.SingleServerTest;
import java.time.Duration;
import java.util.concurrent.ExecutionException;
import java.util.stream.Stream;
import static org.awaitility.Awaitility.await;
/**
* @author Michele Rastelli
*/
class TtlTest extends SingleServerTest {
static Stream<Arguments> args() {
return Stream.of(
Arguments.of(Protocol.HTTP_JSON, "UNREGISTERED"),
Arguments.of(Protocol.HTTP2_JSON, "OUTBOUND GO_AWAY")
);
}
@ParameterizedTest
@MethodSource("args")
void connectionTtl(Protocol p, String expectedLog) {
ArangoDB arangoDB = dbBuilder()
.connectionTtl(1_000L)
.maxConnections(1)
.protocol(p)
.build();
arangoDB.getVersion();
await()
.timeout(Duration.ofSeconds(3))
.until(() -> logs.getLogs().anyMatch(it -> it.getFormattedMessage().contains(expectedLog)));
arangoDB.getVersion();
arangoDB.shutdown();
}
@ParameterizedTest
@MethodSource("args")
void connectionTtlAsync(Protocol p, String expectedLog) throws ExecutionException, InterruptedException {
ArangoDBAsync arangoDB = dbBuilder()
.connectionTtl(1_000L)
.maxConnections(1)
.protocol(p)
.build()
.async();
arangoDB.getVersion().get();
await()
.timeout(Duration.ofSeconds(3))
.until(() -> logs.getLogs().anyMatch(it -> it.getFormattedMessage().contains(expectedLog)));
arangoDB.getVersion().get();
arangoDB.shutdown();
}
}