Skip to content

Commit 8f245db

Browse files
authored
[DE-417] resilience tests (#467)
* resilience tests * skip request timeout tests for HTTP/2 * CI integration
1 parent 5b15914 commit 8f245db

File tree

19 files changed

+918
-32
lines changed

19 files changed

+918
-32
lines changed

.github/workflows/maven.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,6 @@ jobs:
255255
path: ~/.sonar/cache
256256
key: ${{ runner.os }}-sonar
257257
restore-keys: ${{ runner.os }}-sonar
258-
- name: Cache Maven packages
259-
uses: actions/cache@v1
260-
with:
261-
path: ~/.m2
262-
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
263-
restore-keys: ${{ runner.os }}-m2
264258
- name: Build and analyze
265259
env:
266260
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any

.github/workflows/resilience.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Resilience Tests
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags: [ v** ]
7+
8+
jobs:
9+
test:
10+
timeout-minutes: 20
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
fail-fast: false
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Set up JDK
19+
uses: actions/setup-java@v2
20+
with:
21+
java-version: 19
22+
distribution: 'adopt'
23+
cache: maven
24+
- name: Start Database
25+
run: ./docker/start_db.sh
26+
- name: Info
27+
run: mvn -version
28+
- name: Start Toxiproxy
29+
working-directory: resilience-tests
30+
run: ./bin/toxiproxy-server-linux-amd64
31+
- name: Test
32+
run: mvn --no-transfer-progress -am -pl resilience-tests test

driver/pom.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,27 @@
267267
</dependency>
268268
</dependencies>
269269
</plugin>
270+
<plugin>
271+
<groupId>org.apache.maven.plugins</groupId>
272+
<artifactId>maven-enforcer-plugin</artifactId>
273+
<version>3.1.0</version>
274+
<executions>
275+
<execution>
276+
<id>enforce</id>
277+
<goals>
278+
<goal>enforce</goal>
279+
</goals>
280+
<configuration>
281+
<rules>
282+
<dependencyConvergence/>
283+
<requireMavenVersion>
284+
<version>3.6</version>
285+
</requireMavenVersion>
286+
</rules>
287+
</configuration>
288+
</execution>
289+
</executions>
290+
</plugin>
270291
</plugins>
271292
</build>
272293

pom.xml

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<inceptionYear>2016</inceptionYear>
1010
<modules>
1111
<module>driver</module>
12+
<module>resilience-tests</module>
1213
</modules>
1314
<packaging>pom</packaging>
1415

@@ -38,32 +39,6 @@
3839
</developer>
3940
</developers>
4041

41-
<build>
42-
<plugins>
43-
<plugin>
44-
<groupId>org.apache.maven.plugins</groupId>
45-
<artifactId>maven-enforcer-plugin</artifactId>
46-
<version>3.1.0</version>
47-
<executions>
48-
<execution>
49-
<id>enforce</id>
50-
<goals>
51-
<goal>enforce</goal>
52-
</goals>
53-
<configuration>
54-
<rules>
55-
<dependencyConvergence/>
56-
<requireMavenVersion>
57-
<version>3.6</version>
58-
</requireMavenVersion>
59-
</rules>
60-
</configuration>
61-
</execution>
62-
</executions>
63-
</plugin>
64-
</plugins>
65-
</build>
66-
6742
<organization>
6843
<name>ArangoDB GmbH</name>
6944
<url>https://www.arangodb.com</url>

resilience-tests/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# arangodb-java-driver-resiliency-tests
2+
3+
## run
4+
5+
Start (single server) ArangoDB:
6+
```shell
7+
./docker/start_db.sh
8+
```
9+
10+
Start [toxiproxy-server](https://github.com/Shopify/toxiproxy) at `127.0.0.1:8474`.
11+
12+
Run the tests:
13+
```shell
14+
mvn test -am -pl resilience-tests
15+
```
8.41 MB
Binary file not shown.

resilience-tests/pom.xml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>arangodb-java-driver-parent</artifactId>
7+
<groupId>com.arangodb</groupId>
8+
<version>7.0.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>resilience-tests</artifactId>
13+
14+
<properties>
15+
<maven.compiler.target>19</maven.compiler.target>
16+
<maven.compiler.source>19</maven.compiler.source>
17+
<maven.compiler.release>19</maven.compiler.release>
18+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19+
</properties>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>org.mock-server</groupId>
24+
<artifactId>mockserver-netty</artifactId>
25+
<version>5.13.2</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>com.arangodb</groupId>
29+
<artifactId>arangodb-java-driver</artifactId>
30+
<version>${version}</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>com.arangodb</groupId>
34+
<artifactId>jackson-dataformat-velocypack</artifactId>
35+
<version>3.0.1</version>
36+
</dependency>
37+
<dependency>
38+
<groupId>eu.rekawek.toxiproxy</groupId>
39+
<artifactId>toxiproxy-java</artifactId>
40+
<version>2.1.7</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>ch.qos.logback</groupId>
44+
<artifactId>logback-classic</artifactId>
45+
<version>1.2.11</version>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.assertj</groupId>
49+
<artifactId>assertj-core</artifactId>
50+
<version>3.23.1</version>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.junit.platform</groupId>
54+
<artifactId>junit-platform-launcher</artifactId>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.junit.jupiter</groupId>
58+
<artifactId>junit-jupiter-api</artifactId>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.junit.jupiter</groupId>
62+
<artifactId>junit-jupiter-engine</artifactId>
63+
</dependency>
64+
<dependency>
65+
<groupId>org.junit.jupiter</groupId>
66+
<artifactId>junit-jupiter-params</artifactId>
67+
</dependency>
68+
<dependency>
69+
<groupId>org.awaitility</groupId>
70+
<artifactId>awaitility</artifactId>
71+
<version>4.2.0</version>
72+
</dependency>
73+
</dependencies>
74+
75+
<dependencyManagement>
76+
<dependencies>
77+
<dependency>
78+
<groupId>io.netty</groupId>
79+
<artifactId>netty-bom</artifactId>
80+
<version>4.1.84.Final</version>
81+
<scope>import</scope>
82+
<type>pom</type>
83+
</dependency>
84+
<dependency>
85+
<groupId>com.fasterxml.jackson</groupId>
86+
<artifactId>jackson-bom</artifactId>
87+
<version>2.13.4</version>
88+
<scope>import</scope>
89+
<type>pom</type>
90+
</dependency>
91+
<dependency>
92+
<groupId>org.junit</groupId>
93+
<artifactId>junit-bom</artifactId>
94+
<version>5.9.1</version>
95+
<type>pom</type>
96+
<scope>import</scope>
97+
</dependency>
98+
</dependencies>
99+
</dependencyManagement>
100+
101+
<build>
102+
<plugins>
103+
<plugin>
104+
<groupId>org.apache.maven.plugins</groupId>
105+
<artifactId>maven-surefire-plugin</artifactId>
106+
<version>3.0.0-M5</version>
107+
</plugin>
108+
</plugins>
109+
</build>
110+
111+
</project>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package resilience;
2+
3+
import ch.qos.logback.classic.Level;
4+
import com.arangodb.ArangoDB;
5+
import com.arangodb.async.ArangoDBAsync;
6+
import resilience.utils.MemoryAppender;
7+
import eu.rekawek.toxiproxy.Proxy;
8+
import eu.rekawek.toxiproxy.ToxiproxyClient;
9+
import org.junit.jupiter.api.AfterAll;
10+
import org.junit.jupiter.api.BeforeAll;
11+
import org.junit.jupiter.api.BeforeEach;
12+
import org.junit.jupiter.api.Tag;
13+
14+
import java.io.IOException;
15+
import java.util.List;
16+
17+
@Tag("activeFailover")
18+
public abstract class ActiveFailoverTest {
19+
20+
protected static final String HOST = "127.0.0.1";
21+
protected static final String PASSWORD = "test";
22+
protected static final MemoryAppender logs = new MemoryAppender(Level.WARN);
23+
private static final List<Endpoint> endpoints = List.of(
24+
new Endpoint("activeFailover1", HOST, 18529, "172.28.0.1:8529"),
25+
new Endpoint("activeFailover2", HOST, 18539, "172.28.0.1:8539"),
26+
new Endpoint("activeFailover3", HOST, 18549, "172.28.0.1:8549")
27+
);
28+
29+
@BeforeAll
30+
static void beforeAll() throws IOException {
31+
ToxiproxyClient client = new ToxiproxyClient(HOST, 8474);
32+
for (Endpoint ph : endpoints) {
33+
Proxy p = client.getProxyOrNull(ph.getName());
34+
if (p != null) {
35+
p.delete();
36+
}
37+
ph.setProxy(client.createProxy(ph.getName(), ph.getHost() + ":" + ph.getPort(), ph.getUpstream()));
38+
}
39+
}
40+
41+
@AfterAll
42+
static void afterAll() throws IOException {
43+
for (Endpoint ph : endpoints) {
44+
ph.getProxy().delete();
45+
}
46+
}
47+
48+
@BeforeEach
49+
void beforeEach() throws IOException {
50+
for (Endpoint ph : endpoints) {
51+
ph.getProxy().enable();
52+
}
53+
}
54+
55+
protected static List<Endpoint> getEndpoints() {
56+
return endpoints;
57+
}
58+
59+
protected static ArangoDB.Builder dbBuilder() {
60+
ArangoDB.Builder builder = new ArangoDB.Builder().password(PASSWORD);
61+
for (Endpoint ph : endpoints) {
62+
builder.host(ph.getHost(), ph.getPort());
63+
}
64+
return builder;
65+
}
66+
67+
protected static ArangoDBAsync.Builder dbBuilderAsync() {
68+
ArangoDBAsync.Builder builder = new ArangoDBAsync.Builder().password(PASSWORD);
69+
for (Endpoint ph : endpoints) {
70+
builder.host(ph.getHost(), ph.getPort());
71+
}
72+
return builder;
73+
}
74+
75+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package resilience;
2+
3+
import ch.qos.logback.classic.Level;
4+
import com.arangodb.ArangoDB;
5+
import com.arangodb.async.ArangoDBAsync;
6+
import resilience.utils.MemoryAppender;
7+
import eu.rekawek.toxiproxy.Proxy;
8+
import eu.rekawek.toxiproxy.ToxiproxyClient;
9+
import org.junit.jupiter.api.AfterAll;
10+
import org.junit.jupiter.api.BeforeAll;
11+
import org.junit.jupiter.api.BeforeEach;
12+
import org.junit.jupiter.api.Tag;
13+
14+
import java.io.IOException;
15+
import java.util.List;
16+
17+
@Tag("cluster")
18+
public abstract class ClusterTest {
19+
20+
protected static final String HOST = "127.0.0.1";
21+
protected static final String PASSWORD = "test";
22+
protected static final MemoryAppender logs = new MemoryAppender(Level.WARN);
23+
private static final List<Endpoint> endpoints = List.of(
24+
new Endpoint("cluster1", HOST, 18529, "172.28.0.1:8529"),
25+
new Endpoint("cluster2", HOST, 18539, "172.28.0.1:8539"),
26+
new Endpoint("cluster3", HOST, 18549, "172.28.0.1:8549")
27+
);
28+
29+
@BeforeAll
30+
static void beforeAll() throws IOException {
31+
ToxiproxyClient client = new ToxiproxyClient(HOST, 8474);
32+
for (Endpoint ph : endpoints) {
33+
Proxy p = client.getProxyOrNull(ph.getName());
34+
if (p != null) {
35+
p.delete();
36+
}
37+
ph.setProxy(client.createProxy(ph.getName(), ph.getHost() + ":" + ph.getPort(), ph.getUpstream()));
38+
}
39+
}
40+
41+
@AfterAll
42+
static void afterAll() throws IOException {
43+
for (Endpoint ph : endpoints) {
44+
ph.getProxy().delete();
45+
}
46+
}
47+
48+
@BeforeEach
49+
void beforeEach() throws IOException {
50+
for (Endpoint ph : endpoints) {
51+
ph.getProxy().enable();
52+
}
53+
}
54+
55+
protected static List<Endpoint> getEndpoints() {
56+
return endpoints;
57+
}
58+
59+
protected static ArangoDB.Builder dbBuilder() {
60+
ArangoDB.Builder builder = new ArangoDB.Builder().password(PASSWORD);
61+
for (Endpoint ph : endpoints) {
62+
builder.host(ph.getHost(), ph.getPort());
63+
}
64+
return builder;
65+
}
66+
67+
protected static ArangoDBAsync.Builder dbBuilderAsync() {
68+
ArangoDBAsync.Builder builder = new ArangoDBAsync.Builder().password(PASSWORD);
69+
for (Endpoint ph : endpoints) {
70+
builder.host(ph.getHost(), ph.getPort());
71+
}
72+
return builder;
73+
}
74+
75+
}

0 commit comments

Comments
 (0)