diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ee1d5d0f9..d1e8fe0fc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -132,7 +132,7 @@ jobs: db-ext-names: - false java-version: - - 11 + - 21 user-language: - en diff --git a/driver/pom.xml b/driver/pom.xml index f730ed129..6a72445fb 100644 --- a/driver/pom.xml +++ b/driver/pom.xml @@ -186,7 +186,7 @@ org.graalvm.sdk graal-sdk - 22.3.3 + ${graalvm.version} test diff --git a/driver/src/test/java/com/arangodb/ArangoCollectionAsyncTest.java b/driver/src/test/java/com/arangodb/ArangoCollectionAsyncTest.java index 8e765e409..908578dce 100644 --- a/driver/src/test/java/com/arangodb/ArangoCollectionAsyncTest.java +++ b/driver/src/test/java/com/arangodb/ArangoCollectionAsyncTest.java @@ -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(); } diff --git a/driver/src/test/java/graal/BrotliSubstitutions.java b/driver/src/test/java/graal/BrotliSubstitutions.java new file mode 100644 index 000000000..fee8b14a1 --- /dev/null +++ b/driver/src/test/java/graal/BrotliSubstitutions.java @@ -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 { + +} diff --git a/driver/src/test/java/graal/VertxSubstitutions.java b/driver/src/test/java/graal/VertxSubstitutions.java index 043815fbc..472a2e1c8 100644 --- a/driver/src/test/java/graal/VertxSubstitutions.java +++ b/driver/src/test/java/graal/VertxSubstitutions.java @@ -82,7 +82,7 @@ public void close(Promise 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"); } diff --git a/pom.xml b/pom.xml index 6201da70c..f298ca802 100644 --- a/pom.xml +++ b/pom.xml @@ -39,6 +39,7 @@ arangodb-1 https://sonarcloud.io 2.16.0 + 23.1.1 @@ -105,7 +106,7 @@ org.junit junit-bom - 5.10.0 + 5.10.1 pom import @@ -182,7 +183,7 @@ com.tngtech.archunit archunit-junit5 - 1.1.0 + 1.2.1 org.eclipse @@ -192,7 +193,7 @@ io.vertx vertx-stack-depchain - 4.4.2 + 4.5.1 pom import @@ -405,7 +406,7 @@ org.graalvm.buildtools native-maven-plugin - 0.9.27 + 0.9.28 true @@ -432,12 +433,6 @@ - - com.aayushatharva.brotli4j - brotli4j - 1.11.0 - test - javax.annotation javax.annotation-api diff --git a/resilience-tests/src/test/java/resilience/ActiveFailoverTest.java b/resilience-tests/src/test/java/resilience/ActiveFailoverTest.java deleted file mode 100644 index bad70d4c1..000000000 --- a/resilience-tests/src/test/java/resilience/ActiveFailoverTest.java +++ /dev/null @@ -1,66 +0,0 @@ -package resilience; - -import com.arangodb.ArangoDB; -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.Arrays; -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(); - private static final List endpoints = Arrays.asList( - 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 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; - } - -} diff --git a/resilience-tests/src/test/java/resilience/ClusterTest.java b/resilience-tests/src/test/java/resilience/ClusterTest.java index bfe88d6e4..d16f4cbfa 100644 --- a/resilience-tests/src/test/java/resilience/ClusterTest.java +++ b/resilience-tests/src/test/java/resilience/ClusterTest.java @@ -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 getEndpoints() { diff --git a/resilience-tests/src/test/java/resilience/loadbalance/LoadBalanceNoneClusterTest.java b/resilience-tests/src/test/java/resilience/loadbalance/LoadBalanceNoneClusterTest.java index f5a9eccee..5cbd94f06 100644 --- a/resilience-tests/src/test/java/resilience/loadbalance/LoadBalanceNoneClusterTest.java +++ b/resilience-tests/src/test/java/resilience/loadbalance/LoadBalanceNoneClusterTest.java @@ -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; @@ -55,20 +54,20 @@ void loadBalancingAsync(ArangoDBAsync arangoDB) { @ParameterizedTest(name = "{index}") @MethodSource("arangoProvider") - void failover(ArangoDB arangoDB) throws IOException { + void failover(ArangoDB arangoDB) { List 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(); @@ -76,20 +75,20 @@ void failover(ArangoDB arangoDB) throws IOException { @ParameterizedTest(name = "{index}") @MethodSource("asyncArangoProvider") - void failoverAsync(ArangoDBAsync arangoDB) throws IOException { + void failoverAsync(ArangoDBAsync arangoDB) { List 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(); diff --git a/resilience-tests/src/test/java/resilience/loadbalance/LoadBalanceRoundRobinClusterTest.java b/resilience-tests/src/test/java/resilience/loadbalance/LoadBalanceRoundRobinClusterTest.java index 195dfe90f..34d5c55b2 100644 --- a/resilience-tests/src/test/java/resilience/loadbalance/LoadBalanceRoundRobinClusterTest.java +++ b/resilience-tests/src/test/java/resilience/loadbalance/LoadBalanceRoundRobinClusterTest.java @@ -59,22 +59,22 @@ void loadBalancingAsync(ArangoDBAsync arangoDB) { @ParameterizedTest(name = "{index}") @MethodSource("arangoProvider") - void failover(ArangoDB arangoDB) throws IOException { + void failover(ArangoDB arangoDB) { List 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 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()); } diff --git a/resilience-tests/src/test/java/resilience/retry/RetryClusterTest.java b/resilience-tests/src/test/java/resilience/retry/RetryClusterTest.java index ab76f27af..560c504f5 100644 --- a/resilience-tests/src/test/java/resilience/retry/RetryClusterTest.java +++ b/resilience-tests/src/test/java/resilience/retry/RetryClusterTest.java @@ -136,93 +136,6 @@ void unreachableHostFailoverAsync(ArangoDBAsync arangoDB) throws ExecutionExcept arangoDB.shutdown(); } - /** - * on delayed response: - * - ArangoDBException with cause TimeoutException - *

- * 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 - *

- * 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) @@ -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) { @@ -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) { diff --git a/resilience-tests/src/test/java/resilience/retry/RetryTest.java b/resilience-tests/src/test/java/resilience/retry/RetryTest.java index 0fce057c4..84441e5d3 100644 --- a/resilience-tests/src/test/java/resilience/retry/RetryTest.java +++ b/resilience-tests/src/test/java/resilience/retry/RetryTest.java @@ -113,11 +113,6 @@ void unreachableHostAsync(ArangoDBAsync arangoDB) throws ExecutionException, Int @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) @@ -130,7 +125,6 @@ void connectionTimeout(Protocol protocol) throws IOException, InterruptedExcepti Thread.sleep(100); Throwable thrown = catchThrowable(arangoDB::getVersion); - thrown.printStackTrace(); assertThat(thrown) .isInstanceOf(ArangoDBException.class) .extracting(Throwable::getCause) @@ -153,11 +147,6 @@ void connectionTimeout(Protocol protocol) throws IOException, InterruptedExcepti @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) @@ -171,7 +160,6 @@ void connectionTimeoutAsync(Protocol protocol) throws IOException, InterruptedEx Thread.sleep(100); Throwable thrown = catchThrowable(() -> arangoDB.getVersion().get()).getCause(); - thrown.printStackTrace(); assertThat(thrown) .isInstanceOf(ArangoDBException.class) .extracting(Throwable::getCause) @@ -213,7 +201,6 @@ void retryGetOnClosedConnection(Protocol protocol) throws IOException, Interrupt es.schedule(() -> getEndpoint().disable(), 300, TimeUnit.MILLISECONDS); Throwable thrown = catchThrowable(arangoDB::getVersion); - thrown.printStackTrace(); assertThat(thrown).isInstanceOf(ArangoDBException.class); assertThat(thrown.getCause()).isInstanceOf(ArangoDBMultipleException.class); List exceptions = ((ArangoDBMultipleException) thrown.getCause()).getExceptions(); @@ -260,7 +247,6 @@ void retryGetOnClosedConnectionAsync(Protocol protocol) throws IOException, Inte es.schedule(() -> getEndpoint().disable(), 300, TimeUnit.MILLISECONDS); Throwable thrown = catchThrowable(() -> arangoDB.getVersion().get()).getCause(); - thrown.printStackTrace(); assertThat(thrown).isInstanceOf(ArangoDBException.class); assertThat(thrown.getCause()).isInstanceOf(ArangoDBMultipleException.class); List exceptions = ((ArangoDBMultipleException) thrown.getCause()).getExceptions(); @@ -301,7 +287,6 @@ void notRetryPostOnClosedConnection(Protocol protocol) throws IOException, Inter es.schedule(() -> getEndpoint().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) { @@ -339,7 +324,6 @@ void notRetryPostOnClosedConnectionAsync(Protocol protocol) throws IOException, es.schedule(() -> getEndpoint().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) { diff --git a/resilience-tests/src/test/java/resilience/timeout/TimeoutClusterTest.java b/resilience-tests/src/test/java/resilience/timeout/TimeoutClusterTest.java index f5480b607..fc7bf15f7 100644 --- a/resilience-tests/src/test/java/resilience/timeout/TimeoutClusterTest.java +++ b/resilience-tests/src/test/java/resilience/timeout/TimeoutClusterTest.java @@ -31,11 +31,6 @@ class TimeoutClusterTest extends ClusterTest { @ParameterizedTest @EnumSource(Protocol.class) void requestTimeout(Protocol protocol) throws 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) @@ -77,11 +72,6 @@ void requestTimeout(Protocol protocol) throws InterruptedException { @ParameterizedTest @EnumSource(Protocol.class) void requestTimeoutAsync(Protocol protocol) throws 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) diff --git a/resilience-tests/src/test/java/resilience/timeout/TimeoutTest.java b/resilience-tests/src/test/java/resilience/timeout/TimeoutTest.java index a6c562eee..306bf5b5e 100644 --- a/resilience-tests/src/test/java/resilience/timeout/TimeoutTest.java +++ b/resilience-tests/src/test/java/resilience/timeout/TimeoutTest.java @@ -30,11 +30,6 @@ class TimeoutTest extends SingleServerTest { @ParameterizedTest @EnumSource(Protocol.class) void requestTimeout(Protocol protocol) throws 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) @@ -76,11 +71,6 @@ void requestTimeout(Protocol protocol) throws InterruptedException { @ParameterizedTest @EnumSource(Protocol.class) void requestTimeoutAsync(Protocol protocol) throws 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) diff --git a/shaded/src/main/java/graal/VertxSubstitutions.java b/shaded/src/main/java/graal/VertxSubstitutions.java index 5e9eb9ff4..8b2daa98b 100644 --- a/shaded/src/main/java/graal/VertxSubstitutions.java +++ b/shaded/src/main/java/graal/VertxSubstitutions.java @@ -82,7 +82,7 @@ public void close(Promise 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"); }