Skip to content

Commit

Permalink
faster resilience tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rashtao committed Mar 4, 2024
1 parent 6c0820f commit cbc2baf
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import ch.qos.logback.classic.Level;
import com.arangodb.*;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import resilience.ClusterTest;
Expand All @@ -20,7 +21,9 @@ class ConnectionClusterTest extends ClusterTest {

@ParameterizedTest
@MethodSource("protocolProvider")
@Disabled
void nameResolutionFail(Protocol protocol) {
// FIXME: make this test faster and re-enable
ArangoDB arangoDB = new ArangoDB.Builder()
.host("wrongHost", 8529)
.protocol(protocol)
Expand All @@ -40,7 +43,9 @@ void nameResolutionFail(Protocol protocol) {

@ParameterizedTest
@MethodSource("protocolProvider")
@Disabled
void nameResolutionFailAsync(Protocol protocol) {
// FIXME: make this test faster and re-enable
ArangoDBAsync arangoDB = new ArangoDB.Builder()
.host("wrongHost", 8529)
.protocol(protocol)
Expand All @@ -61,7 +66,9 @@ void nameResolutionFailAsync(Protocol protocol) {

@ParameterizedTest
@MethodSource("protocolProvider")
@Disabled
void nameResolutionFailover(Protocol protocol) {
// FIXME: make this test faster and re-enable
ArangoDB arangoDB = new ArangoDB.Builder()
.password("test")
.host("wrongHost", 8529)
Expand All @@ -80,7 +87,9 @@ void nameResolutionFailover(Protocol protocol) {

@ParameterizedTest
@MethodSource("protocolProvider")
@Disabled
void nameResolutionFailoverAsync(Protocol protocol) throws ExecutionException, InterruptedException {
// FIXME: make this test faster and re-enable
ArangoDBAsync arangoDB = new ArangoDB.Builder()
.password("test")
.host("wrongHost", 8529)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
class RetriableCursorTest extends SingleServerTest {

static Stream<ArangoDB> arangoProvider() {
return builderProvider().map(it -> it.timeout(1_000).build());
return builderProvider().map(it -> it.timeout(500).build());
}

static Stream<ArangoDBAsync> asyncArangoProvider() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void unreachableHostAsync(ArangoDBAsync arangoDB) throws ExecutionException, Int
@MethodSource("protocolProvider")
void connectionTimeout(Protocol protocol) throws IOException, InterruptedException {
ArangoDB arangoDB = dbBuilder()
.timeout(1_000)
.timeout(500)
.protocol(protocol)
.build();

Expand Down Expand Up @@ -134,7 +134,7 @@ void connectionTimeout(Protocol protocol) throws IOException, InterruptedExcepti
@MethodSource("protocolProvider")
void connectionTimeoutAsync(Protocol protocol) throws IOException, InterruptedException, ExecutionException {
ArangoDBAsync arangoDB = dbBuilder()
.timeout(1_000)
.timeout(500)
.protocol(protocol)
.build()
.async();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void shutdown(Protocol protocol) throws InterruptedException {

arangoDB.getVersion();
arangoDB.shutdown();
Thread.sleep(1_000);
Thread.sleep(500);
Throwable thrown = catchThrowable(arangoDB::getVersion);
assertThat(thrown).isInstanceOf(ArangoDBException.class);
assertThat(thrown.getMessage()).contains("closed");
Expand All @@ -49,7 +49,7 @@ void shutdownAsync(Protocol protocol) throws InterruptedException, ExecutionExce

arangoDB.getVersion().get();
arangoDB.shutdown();
Thread.sleep(1_000);
Thread.sleep(500);
Throwable thrown = catchThrowable(() -> arangoDB.getVersion().get()).getCause();
assertThat(thrown).isInstanceOf(ArangoDBException.class);
assertThat(thrown.getMessage()).contains("closed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void shutdown(Protocol protocol) throws InterruptedException {

arangoDB.getVersion();
arangoDB.shutdown();
Thread.sleep(1_000);
Thread.sleep(500);
Throwable thrown = catchThrowable(arangoDB::getVersion);
assertThat(thrown).isInstanceOf(ArangoDBException.class);
assertThat(thrown.getMessage()).contains("closed");
Expand All @@ -49,7 +49,7 @@ void shutdownAsync(Protocol protocol) throws InterruptedException, ExecutionExce

arangoDB.getVersion().get();
arangoDB.shutdown();
Thread.sleep(1_000);
Thread.sleep(500);
Throwable thrown = catchThrowable(() -> arangoDB.getVersion().get()).getCause();
assertThat(thrown).isInstanceOf(ArangoDBException.class);
assertThat(thrown.getMessage()).contains("closed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TimeoutClusterTest extends ClusterTest {
@MethodSource("protocolProvider")
void requestTimeout(Protocol protocol) throws InterruptedException {
ArangoDB arangoDB = dbBuilder()
.timeout(1_000)
.timeout(500)
.protocol(protocol)
.build();

Expand All @@ -41,7 +41,7 @@ void requestTimeout(Protocol protocol) throws InterruptedException {
col.truncate();

Throwable thrown = catchThrowable(() -> arangoDB.db()
.query("INSERT {value:sleep(2)} INTO @@col RETURN NEW",
.query("INSERT {value:sleep(1)} INTO @@col RETURN NEW",
Map.class,
Collections.singletonMap("@col", colName))
);
Expand All @@ -53,7 +53,7 @@ void requestTimeout(Protocol protocol) throws InterruptedException {

arangoDB.getVersion();

Thread.sleep(2_000);
Thread.sleep(1_000);
assertThat(col.count().getCount()).isEqualTo(1);

arangoDB.shutdown();
Expand All @@ -71,7 +71,7 @@ void requestTimeout(Protocol protocol) throws InterruptedException {
@MethodSource("protocolProvider")
void requestTimeoutAsync(Protocol protocol) throws InterruptedException, ExecutionException {
ArangoDBAsync arangoDB = dbBuilder()
.timeout(1_000)
.timeout(500)
.protocol(protocol)
.build()
.async();
Expand All @@ -83,7 +83,7 @@ void requestTimeoutAsync(Protocol protocol) throws InterruptedException, Executi
col.truncate().get();

Throwable thrown = catchThrowable(() -> arangoDB.db()
.query("INSERT {value:sleep(2)} INTO @@col RETURN NEW",
.query("INSERT {value:sleep(1)} INTO @@col RETURN NEW",
Map.class,
Collections.singletonMap("@col", colName)).get()
).getCause();
Expand All @@ -95,7 +95,7 @@ void requestTimeoutAsync(Protocol protocol) throws InterruptedException, Executi

arangoDB.getVersion().get();

Thread.sleep(2_000);
Thread.sleep(1_000);
assertThat(col.count().get().getCount()).isEqualTo(1);

arangoDB.shutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TimeoutTest extends SingleServerTest {
@MethodSource("protocolProvider")
void requestTimeout(Protocol protocol) throws InterruptedException {
ArangoDB arangoDB = dbBuilder()
.timeout(1_000)
.timeout(500)
.protocol(protocol)
.build();

Expand All @@ -42,7 +42,7 @@ void requestTimeout(Protocol protocol) throws InterruptedException {
col.truncate();

Throwable thrown = catchThrowable(() -> arangoDB.db()
.query("INSERT {value:sleep(2)} INTO @@col RETURN NEW",
.query("INSERT {value:sleep(1)} INTO @@col RETURN NEW",
Map.class,
Collections.singletonMap("@col", colName))
);
Expand All @@ -54,7 +54,7 @@ void requestTimeout(Protocol protocol) throws InterruptedException {

arangoDB.getVersion();

Thread.sleep(2_000);
Thread.sleep(1_000);
assertThat(col.count().getCount()).isEqualTo(1);

arangoDB.shutdown();
Expand All @@ -72,7 +72,7 @@ void requestTimeout(Protocol protocol) throws InterruptedException {
@MethodSource("protocolProvider")
void requestTimeoutAsync(Protocol protocol) throws InterruptedException, ExecutionException {
ArangoDBAsync arangoDB = dbBuilder()
.timeout(1_000)
.timeout(500)
.protocol(protocol)
.build()
.async();
Expand All @@ -84,7 +84,7 @@ void requestTimeoutAsync(Protocol protocol) throws InterruptedException, Executi
col.truncate().get();

Throwable thrown = catchThrowable(() -> arangoDB.db()
.query("INSERT {value:sleep(2)} INTO @@col RETURN NEW",
.query("INSERT {value:sleep(1)} INTO @@col RETURN NEW",
Map.class,
Collections.singletonMap("@col", colName)).get()
).getCause();
Expand All @@ -96,7 +96,7 @@ void requestTimeoutAsync(Protocol protocol) throws InterruptedException, Executi

arangoDB.getVersion().get();

Thread.sleep(2_000);
Thread.sleep(1_000);
assertThat(col.count().get().getCount()).isEqualTo(1);

arangoDB.shutdown();
Expand Down

0 comments on commit cbc2baf

Please sign in to comment.