From 15bdd6bc2fa04d3a9051a8f614c59a839cfca10f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20L=C3=A9aut=C3=A9?= Date: Thu, 8 Apr 2021 10:33:37 -0700 Subject: [PATCH] Fix unit tests and GC settings for Java 15 (#11074) * JavaScript script engine support was removed in JDK 15: skip those tests for JDKs without it * Fix flaky HTTP client tests with Java 15 * Switch from CMS to G1GC in integration tests, since CMS is no longer available in JDK 15 --- .../druid/java/util/http/client/JankyServersTest.java | 2 ++ .../setup/JavaScriptWorkerSelectStrategyTest.java | 11 +++++++++++ .../environment-configs/router-custom-check-tls | 2 +- .../environment-configs/router-no-client-auth-tls | 2 +- .../docker/environment-configs/router-permissive-tls | 2 +- .../JavaScriptTieredBrokerSelectorStrategyTest.java | 10 ++++++++++ 6 files changed, 26 insertions(+), 3 deletions(-) diff --git a/core/src/test/java/org/apache/druid/java/util/http/client/JankyServersTest.java b/core/src/test/java/org/apache/druid/java/util/http/client/JankyServersTest.java index 3cc2d06018c..3d12cf7a1fc 100644 --- a/core/src/test/java/org/apache/druid/java/util/http/client/JankyServersTest.java +++ b/core/src/test/java/org/apache/druid/java/util/http/client/JankyServersTest.java @@ -41,6 +41,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.ServerSocket; import java.net.Socket; +import java.net.SocketException; import java.net.URL; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; @@ -298,6 +299,7 @@ public class JankyServersTest public boolean isChannelClosedException(Throwable e) { return e instanceof ChannelException || + (e instanceof SocketException && e.getMessage().contains("Connection reset")) || (e instanceof IOException && e.getMessage().contains("Connection reset by peer")); } diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/setup/JavaScriptWorkerSelectStrategyTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/setup/JavaScriptWorkerSelectStrategyTest.java index cac81d1438f..8717edca6bb 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/setup/JavaScriptWorkerSelectStrategyTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/setup/JavaScriptWorkerSelectStrategyTest.java @@ -32,10 +32,14 @@ import org.easymock.EasyMock; import org.hamcrest.CoreMatchers; import org.joda.time.Period; import org.junit.Assert; +import org.junit.Assume; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import javax.script.ScriptEngineManager; + public class JavaScriptWorkerSelectStrategyTest { @Rule @@ -71,6 +75,13 @@ public class JavaScriptWorkerSelectStrategyTest JavaScriptConfig.getEnabledInstance() ); + @Before + public void checkJdkCompatibility() + { + // skip tests for newer JDKs without javascript support + Assume.assumeNotNull(new ScriptEngineManager().getEngineByName("javascript")); + } + @Test public void testSerde() throws Exception { diff --git a/integration-tests/docker/environment-configs/router-custom-check-tls b/integration-tests/docker/environment-configs/router-custom-check-tls index d506a80a4bf..0414b16b65c 100644 --- a/integration-tests/docker/environment-configs/router-custom-check-tls +++ b/integration-tests/docker/environment-configs/router-custom-check-tls @@ -21,7 +21,7 @@ DRUID_SERVICE=router DRUID_LOG_PATH=/shared/logs/router-custom-check-tls.log # JAVA OPTS -SERVICE_DRUID_JAVA_OPTS=-server -Xmx64m -Xms64m -XX:+UseConcMarkSweepGC -XX:+PrintGCDetails -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5003 +SERVICE_DRUID_JAVA_OPTS=-server -Xmx64m -Xms64m -XX:+UseG1GC -XX:+PrintGCDetails -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5003 # Druid configs druid_plaintextPort=8891 diff --git a/integration-tests/docker/environment-configs/router-no-client-auth-tls b/integration-tests/docker/environment-configs/router-no-client-auth-tls index 7d3cc8144ed..9396b3b1742 100644 --- a/integration-tests/docker/environment-configs/router-no-client-auth-tls +++ b/integration-tests/docker/environment-configs/router-no-client-auth-tls @@ -21,7 +21,7 @@ DRUID_SERVICE=router DRUID_LOG_PATH=/shared/logs/router-no-client-auth-tls.log # JAVA OPTS -SERVICE_DRUID_JAVA_OPTS=-server -Xmx64m -Xms64m -XX:+UseConcMarkSweepGC -XX:+PrintGCDetails -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5002 +SERVICE_DRUID_JAVA_OPTS=-server -Xmx64m -Xms64m -XX:+UseG1GC -XX:+PrintGCDetails -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5002 # Druid configs druid_plaintextPort=8890 diff --git a/integration-tests/docker/environment-configs/router-permissive-tls b/integration-tests/docker/environment-configs/router-permissive-tls index d4aae6aa3dd..d827dae555b 100644 --- a/integration-tests/docker/environment-configs/router-permissive-tls +++ b/integration-tests/docker/environment-configs/router-permissive-tls @@ -21,7 +21,7 @@ DRUID_SERVICE=router DRUID_LOG_PATH=/shared/logs/router-permissive-tls.log # JAVA OPTS -SERVICE_DRUID_JAVA_OPTS=-server -Xmx64m -Xms64m -XX:+UseConcMarkSweepGC -XX:+PrintGCDetails -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5001 +SERVICE_DRUID_JAVA_OPTS=-server -Xmx64m -Xms64m -XX:+UseG1GC -XX:+PrintGCDetails -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5001 # Druid configs druid_plaintextPort=8889 diff --git a/server/src/test/java/org/apache/druid/server/router/JavaScriptTieredBrokerSelectorStrategyTest.java b/server/src/test/java/org/apache/druid/server/router/JavaScriptTieredBrokerSelectorStrategyTest.java index ec1ddb9f66a..fa8e931f0cd 100644 --- a/server/src/test/java/org/apache/druid/server/router/JavaScriptTieredBrokerSelectorStrategyTest.java +++ b/server/src/test/java/org/apache/druid/server/router/JavaScriptTieredBrokerSelectorStrategyTest.java @@ -32,10 +32,13 @@ import org.apache.druid.query.aggregation.LongSumAggregatorFactory; import org.apache.druid.query.topn.TopNQueryBuilder; import org.hamcrest.CoreMatchers; import org.junit.Assert; +import org.junit.Assume; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import javax.script.ScriptEngineManager; import java.util.LinkedHashMap; public class JavaScriptTieredBrokerSelectorStrategyTest @@ -48,6 +51,13 @@ public class JavaScriptTieredBrokerSelectorStrategyTest JavaScriptConfig.getEnabledInstance() ); + @Before + public void checkJdkCompatibility() + { + // skip tests for newer JDKs without javascript support + Assume.assumeNotNull(new ScriptEngineManager().getEngineByName("javascript")); + } + @Test public void testSerde() throws Exception {