Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,6 @@ jobs:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/resilience.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Resilience Tests

on:
workflow_dispatch:
push:
tags: [ v** ]

jobs:
test:
timeout-minutes: 20
runs-on: ubuntu-latest

strategy:
fail-fast: false

steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: 19
distribution: 'adopt'
cache: maven
- name: Start Database
run: ./docker/start_db.sh
- name: Info
run: mvn -version
- name: Start Toxiproxy
working-directory: resilience-tests
run: ./bin/toxiproxy-server-linux-amd64
- name: Test
run: mvn --no-transfer-progress -am -pl resilience-tests test
21 changes: 21 additions & 0 deletions driver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,27 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>enforce</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<dependencyConvergence/>
<requireMavenVersion>
<version>3.6</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
27 changes: 1 addition & 26 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<inceptionYear>2016</inceptionYear>
<modules>
<module>driver</module>
<module>resilience-tests</module>
</modules>
<packaging>pom</packaging>

Expand Down Expand Up @@ -38,32 +39,6 @@
</developer>
</developers>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>enforce</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<dependencyConvergence/>
<requireMavenVersion>
<version>3.6</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<organization>
<name>ArangoDB GmbH</name>
<url>https://www.arangodb.com</url>
Expand Down
15 changes: 15 additions & 0 deletions resilience-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# arangodb-java-driver-resiliency-tests

## run

Start (single server) ArangoDB:
```shell
./docker/start_db.sh
```

Start [toxiproxy-server](https://github.com/Shopify/toxiproxy) at `127.0.0.1:8474`.

Run the tests:
```shell
mvn test -am -pl resilience-tests
```
Binary file added resilience-tests/bin/toxiproxy-server-linux-amd64
Binary file not shown.
111 changes: 111 additions & 0 deletions resilience-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>arangodb-java-driver-parent</artifactId>
<groupId>com.arangodb</groupId>
<version>7.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>resilience-tests</artifactId>

<properties>
<maven.compiler.target>19</maven.compiler.target>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.release>19</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-netty</artifactId>
<version>5.13.2</version>
</dependency>
<dependency>
<groupId>com.arangodb</groupId>
<artifactId>arangodb-java-driver</artifactId>
<version>${version}</version>
</dependency>
<dependency>
<groupId>com.arangodb</groupId>
<artifactId>jackson-dataformat-velocypack</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>eu.rekawek.toxiproxy</groupId>
<artifactId>toxiproxy-java</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.11</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.23.1</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.2.0</version>
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-bom</artifactId>
<version>4.1.84.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
<version>2.13.4</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.9.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
</plugins>
</build>

</project>
75 changes: 75 additions & 0 deletions resilience-tests/src/test/java/resilience/ActiveFailoverTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package resilience;

import ch.qos.logback.classic.Level;
import com.arangodb.ArangoDB;
import com.arangodb.async.ArangoDBAsync;
import resilience.utils.MemoryAppender;
import eu.rekawek.toxiproxy.Proxy;
import eu.rekawek.toxiproxy.ToxiproxyClient;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;

import java.io.IOException;
import java.util.List;

@Tag("activeFailover")
public abstract class ActiveFailoverTest {

protected static final String HOST = "127.0.0.1";
protected static final String PASSWORD = "test";
protected static final MemoryAppender logs = new MemoryAppender(Level.WARN);
private static final List<Endpoint> endpoints = List.of(
new Endpoint("activeFailover1", HOST, 18529, "172.28.0.1:8529"),
new Endpoint("activeFailover2", HOST, 18539, "172.28.0.1:8539"),
new Endpoint("activeFailover3", HOST, 18549, "172.28.0.1:8549")
);

@BeforeAll
static void beforeAll() throws IOException {
ToxiproxyClient client = new ToxiproxyClient(HOST, 8474);
for (Endpoint ph : endpoints) {
Proxy p = client.getProxyOrNull(ph.getName());
if (p != null) {
p.delete();
}
ph.setProxy(client.createProxy(ph.getName(), ph.getHost() + ":" + ph.getPort(), ph.getUpstream()));
}
}

@AfterAll
static void afterAll() throws IOException {
for (Endpoint ph : endpoints) {
ph.getProxy().delete();
}
}

@BeforeEach
void beforeEach() throws IOException {
for (Endpoint ph : endpoints) {
ph.getProxy().enable();
}
}

protected static List<Endpoint> getEndpoints() {
return endpoints;
}

protected static ArangoDB.Builder dbBuilder() {
ArangoDB.Builder builder = new ArangoDB.Builder().password(PASSWORD);
for (Endpoint ph : endpoints) {
builder.host(ph.getHost(), ph.getPort());
}
return builder;
}

protected static ArangoDBAsync.Builder dbBuilderAsync() {
ArangoDBAsync.Builder builder = new ArangoDBAsync.Builder().password(PASSWORD);
for (Endpoint ph : endpoints) {
builder.host(ph.getHost(), ph.getPort());
}
return builder;
}

}
75 changes: 75 additions & 0 deletions resilience-tests/src/test/java/resilience/ClusterTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package resilience;

import ch.qos.logback.classic.Level;
import com.arangodb.ArangoDB;
import com.arangodb.async.ArangoDBAsync;
import resilience.utils.MemoryAppender;
import eu.rekawek.toxiproxy.Proxy;
import eu.rekawek.toxiproxy.ToxiproxyClient;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;

import java.io.IOException;
import java.util.List;

@Tag("cluster")
public abstract class ClusterTest {

protected static final String HOST = "127.0.0.1";
protected static final String PASSWORD = "test";
protected static final MemoryAppender logs = new MemoryAppender(Level.WARN);
private static final List<Endpoint> endpoints = List.of(
new Endpoint("cluster1", HOST, 18529, "172.28.0.1:8529"),
new Endpoint("cluster2", HOST, 18539, "172.28.0.1:8539"),
new Endpoint("cluster3", HOST, 18549, "172.28.0.1:8549")
);

@BeforeAll
static void beforeAll() throws IOException {
ToxiproxyClient client = new ToxiproxyClient(HOST, 8474);
for (Endpoint ph : endpoints) {
Proxy p = client.getProxyOrNull(ph.getName());
if (p != null) {
p.delete();
}
ph.setProxy(client.createProxy(ph.getName(), ph.getHost() + ":" + ph.getPort(), ph.getUpstream()));
}
}

@AfterAll
static void afterAll() throws IOException {
for (Endpoint ph : endpoints) {
ph.getProxy().delete();
}
}

@BeforeEach
void beforeEach() throws IOException {
for (Endpoint ph : endpoints) {
ph.getProxy().enable();
}
}

protected static List<Endpoint> getEndpoints() {
return endpoints;
}

protected static ArangoDB.Builder dbBuilder() {
ArangoDB.Builder builder = new ArangoDB.Builder().password(PASSWORD);
for (Endpoint ph : endpoints) {
builder.host(ph.getHost(), ph.getPort());
}
return builder;
}

protected static ArangoDBAsync.Builder dbBuilderAsync() {
ArangoDBAsync.Builder builder = new ArangoDBAsync.Builder().password(PASSWORD);
for (Endpoint ph : endpoints) {
builder.host(ph.getHost(), ph.getPort());
}
return builder;
}

}
Loading