Skip to content

Upgrade to Vert.x 4.5 #532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 15, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ jobs:
db-ext-names:
- false
java-version:
- 11
- 21
user-language:
- en

Expand Down
2 changes: 1 addition & 1 deletion driver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>graal-sdk</artifactId>
<version>22.3.3</version>
<version>${graalvm.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2987,7 +2987,7 @@ void grantAccessRW(ArangoCollectionAsync collection) throws ExecutionException,
ArangoDBAsync arangoDB = collection.db().arango();
try {
arangoDB.createUser("user1", "1234", null).get();
collection.grantAccess("user1", Permissions.RW);
collection.grantAccess("user1", Permissions.RW).get();
} finally {
arangoDB.deleteUser("user1").get();
}
Expand Down
22 changes: 22 additions & 0 deletions driver/src/test/java/graal/BrotliSubstitutions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package graal;

import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;


@TargetClass(className = "io.netty.handler.codec.compression.Brotli")
final class Target_com_arangodb_shaded_netty_handler_codec_compression_Brotli {
@Substitute
public static boolean isAvailable() {
return false;
}

@Substitute
public static void ensureAvailability() throws Throwable {
throw new UnsupportedOperationException();
}
}

public class BrotliSubstitutions {

}
2 changes: 1 addition & 1 deletion driver/src/test/java/graal/VertxSubstitutions.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void close(Promise<Void> promise) {
}

@Substitute
public MessageImpl createMessage(boolean send, String address, MultiMap headers, Object body, String codecName) {
public MessageImpl createMessage(boolean send, boolean isLocal, String address, MultiMap headers, Object body, String codecName) {
throw new RuntimeException("Not Implemented");
}

Expand Down
15 changes: 5 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<sonar.organization>arangodb-1</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<adb.jackson.version>2.16.0</adb.jackson.version>
<graalvm.version>23.1.1</graalvm.version>
<moduleName/>
<SslTest/>
</properties>
Expand Down Expand Up @@ -105,7 +106,7 @@
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.10.0</version>
<version>5.10.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -182,7 +183,7 @@
<dependency>
<groupId>com.tngtech.archunit</groupId>
<artifactId>archunit-junit5</artifactId>
<version>1.1.0</version>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.eclipse</groupId>
Expand All @@ -192,7 +193,7 @@
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-stack-depchain</artifactId>
<version>4.4.2</version>
<version>4.5.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -405,7 +406,7 @@
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.9.27</version>
<version>0.9.28</version>
<extensions>true</extensions>
<executions>
<execution>
Expand All @@ -432,12 +433,6 @@
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.aayushatharva.brotli4j</groupId>
<artifactId>brotli4j</artifactId>
<version>1.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
Expand Down
66 changes: 0 additions & 66 deletions resilience-tests/src/test/java/resilience/ActiveFailoverTest.java

This file was deleted.

6 changes: 2 additions & 4 deletions resilience-tests/src/test/java/resilience/ClusterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ static void afterAll() throws IOException {
}

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

protected static List<Endpoint> getEndpoints() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.arangodb.entity.LoadBalancingStrategy;
import eu.rekawek.toxiproxy.model.ToxicDirection;
import eu.rekawek.toxiproxy.model.toxic.Latency;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import resilience.ClusterTest;
Expand Down Expand Up @@ -55,41 +54,41 @@ void loadBalancingAsync(ArangoDBAsync arangoDB) {

@ParameterizedTest(name = "{index}")
@MethodSource("arangoProvider")
void failover(ArangoDB arangoDB) throws IOException {
void failover(ArangoDB arangoDB) {
List<Endpoint> endpoints = getEndpoints();

endpoints.get(0).getProxy().disable();
endpoints.get(0).disable();
assertThat(serverIdGET(arangoDB)).isEqualTo(endpoints.get(1).getServerId());
assertThat(serverIdGET(arangoDB)).isEqualTo(endpoints.get(1).getServerId());
enableAllEndpoints();

endpoints.get(1).getProxy().disable();
endpoints.get(1).disable();
assertThat(serverIdGET(arangoDB)).isEqualTo(endpoints.get(2).getServerId());
assertThat(serverIdGET(arangoDB)).isEqualTo(endpoints.get(2).getServerId());
enableAllEndpoints();

endpoints.get(2).getProxy().disable();
endpoints.get(2).disable();
assertThat(serverIdGET(arangoDB)).isEqualTo(endpoints.get(0).getServerId());
assertThat(serverIdGET(arangoDB)).isEqualTo(endpoints.get(0).getServerId());
enableAllEndpoints();
}

@ParameterizedTest(name = "{index}")
@MethodSource("asyncArangoProvider")
void failoverAsync(ArangoDBAsync arangoDB) throws IOException {
void failoverAsync(ArangoDBAsync arangoDB) {
List<Endpoint> endpoints = getEndpoints();

endpoints.get(0).getProxy().disable();
endpoints.get(0).disable();
assertThat(serverIdGET(arangoDB)).isEqualTo(endpoints.get(1).getServerId());
assertThat(serverIdGET(arangoDB)).isEqualTo(endpoints.get(1).getServerId());
enableAllEndpoints();

endpoints.get(1).getProxy().disable();
endpoints.get(1).disable();
assertThat(serverIdGET(arangoDB)).isEqualTo(endpoints.get(2).getServerId());
assertThat(serverIdGET(arangoDB)).isEqualTo(endpoints.get(2).getServerId());
enableAllEndpoints();

endpoints.get(2).getProxy().disable();
endpoints.get(2).disable();
assertThat(serverIdGET(arangoDB)).isEqualTo(endpoints.get(0).getServerId());
assertThat(serverIdGET(arangoDB)).isEqualTo(endpoints.get(0).getServerId());
enableAllEndpoints();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,22 @@ void loadBalancingAsync(ArangoDBAsync arangoDB) {

@ParameterizedTest(name = "{index}")
@MethodSource("arangoProvider")
void failover(ArangoDB arangoDB) throws IOException {
void failover(ArangoDB arangoDB) {
List<Endpoint> endpoints = getEndpoints();
endpoints.get(0).getProxy().disable();
endpoints.get(0).disable();
assertThat(serverIdGET(arangoDB)).isEqualTo(endpoints.get(1).getServerId());
endpoints.get(0).getProxy().enable();
endpoints.get(0).enable();
assertThat(serverIdGET(arangoDB)).isEqualTo(endpoints.get(2).getServerId());
assertThat(serverIdGET(arangoDB)).isEqualTo(endpoints.get(0).getServerId());
}

@ParameterizedTest(name = "{index}")
@MethodSource("asyncArangoProvider")
void failoverAsync(ArangoDBAsync arangoDB) throws IOException {
void failoverAsync(ArangoDBAsync arangoDB) {
List<Endpoint> endpoints = getEndpoints();
endpoints.get(0).getProxy().disable();
endpoints.get(0).disable();
assertThat(serverIdGET(arangoDB)).isEqualTo(endpoints.get(1).getServerId());
endpoints.get(0).getProxy().enable();
endpoints.get(0).enable();
assertThat(serverIdGET(arangoDB)).isEqualTo(endpoints.get(2).getServerId());
assertThat(serverIdGET(arangoDB)).isEqualTo(endpoints.get(0).getServerId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,93 +136,6 @@ void unreachableHostFailoverAsync(ArangoDBAsync arangoDB) throws ExecutionExcept
arangoDB.shutdown();
}

/**
* on delayed response:
* - ArangoDBException with cause TimeoutException
* <p>
* once the delay is removed:
* - the subsequent requests should be successful
*/
@ParameterizedTest
@EnumSource(Protocol.class)
void connectionTimeout(Protocol protocol) throws IOException, InterruptedException {
// https://github.com/vert-x3/vertx-web/issues/2296
// WebClient: HTTP/2 request timeout does not throw TimeoutException
assumeTrue(protocol != Protocol.HTTP2_VPACK);
assumeTrue(protocol != Protocol.HTTP2_JSON);

ArangoDB arangoDB = dbBuilder()
.timeout(1_000)
.protocol(protocol)
.build();

arangoDB.getVersion();

// slow down the driver connection
Latency toxic = getEndpoints().get(0).getProxy().toxics().latency("latency", ToxicDirection.DOWNSTREAM, 10_000);
Thread.sleep(100);

// no failover for TimeoutException
for (int i = 0; i < 2; i++) {
Throwable thrown = catchThrowable(arangoDB::getVersion);
thrown.printStackTrace();
assertThat(thrown)
.isInstanceOf(ArangoDBException.class)
.extracting(Throwable::getCause)
.isInstanceOf(TimeoutException.class);
}

toxic.remove();
Thread.sleep(100);

arangoDB.getVersion();
arangoDB.shutdown();
}

/**
* on delayed response:
* - ArangoDBException with cause TimeoutException
* <p>
* once the delay is removed:
* - the subsequent requests should be successful
*/
@ParameterizedTest
@EnumSource(Protocol.class)
void connectionTimeoutAsync(Protocol protocol) throws IOException, InterruptedException, ExecutionException {
// https://github.com/vert-x3/vertx-web/issues/2296
// WebClient: HTTP/2 request timeout does not throw TimeoutException
assumeTrue(protocol != Protocol.HTTP2_VPACK);
assumeTrue(protocol != Protocol.HTTP2_JSON);

ArangoDBAsync arangoDB = dbBuilder()
.timeout(1_000)
.protocol(protocol)
.build()
.async();

arangoDB.getVersion().get();

// slow down the driver connection
Latency toxic = getEndpoints().get(0).getProxy().toxics().latency("latency", ToxicDirection.DOWNSTREAM, 10_000);
Thread.sleep(100);

// no failover for TimeoutException
for (int i = 0; i < 2; i++) {
Throwable thrown = catchThrowable(() -> arangoDB.getVersion().get()).getCause();
thrown.printStackTrace();
assertThat(thrown)
.isInstanceOf(ArangoDBException.class)
.extracting(Throwable::getCause)
.isInstanceOf(TimeoutException.class);
}

toxic.remove();
Thread.sleep(100);

arangoDB.getVersion().get();
arangoDB.shutdown();
}


@ParameterizedTest
@EnumSource(Protocol.class)
Expand Down Expand Up @@ -306,7 +219,6 @@ void notRetryPostOnClosedConnection(Protocol protocol) throws IOException, Inter
es.schedule(() -> getEndpoints().get(0).disable(), 300, TimeUnit.MILLISECONDS);

Throwable thrown = catchThrowable(() -> arangoDB.db().query("return null", Void.class));
thrown.printStackTrace();
assertThat(thrown).isInstanceOf(ArangoDBException.class);
assertThat(thrown.getCause()).isInstanceOf(IOException.class);
if (protocol != Protocol.VST) {
Expand Down Expand Up @@ -344,7 +256,6 @@ void notRetryPostOnClosedConnectionAsync(Protocol protocol) throws IOException,
es.schedule(() -> getEndpoints().get(0).disable(), 300, TimeUnit.MILLISECONDS);

Throwable thrown = catchThrowable(() -> arangoDB.db().query("return null", Void.class).get()).getCause();
thrown.printStackTrace();
assertThat(thrown).isInstanceOf(ArangoDBException.class);
assertThat(thrown.getCause()).isInstanceOf(IOException.class);
if (protocol != Protocol.VST) {
Expand Down
Loading