From 563141c6c9e642be572796aa2dd29dc04f9ba901 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Mon, 11 Jun 2018 16:55:07 -0400 Subject: [PATCH] Upgrade to Netty 4.1.25.Final (#31232) This commit upgrades us to Netty 4.1.25. This upgrade is more challenging than past upgrades, all because of a new object cleaner thread that they have added. This thread requires an additional security permission (set context class loader, needed to avoid leaks in certain scenarios). Additionally, there is not a clean way to shutdown this thread which means that the thread can fail thread leak control during tests. As such, we have to filter this thread from thread leak control. --- .../ReindexFromRemoteWithAuthTests.java | 3 ++ .../index/reindex/RetryTests.java | 3 ++ .../test/ObjectCleanerThreadThreadFilter.java | 32 ++++++++++++++++ modules/transport-netty4/build.gradle | 16 ++++---- .../netty-buffer-4.1.16.Final.jar.sha1 | 1 - .../netty-buffer-4.1.25.Final.jar.sha1 | 1 + .../netty-codec-4.1.16.Final.jar.sha1 | 1 - .../netty-codec-4.1.25.Final.jar.sha1 | 1 + .../netty-codec-http-4.1.16.Final.jar.sha1 | 1 - .../netty-codec-http-4.1.25.Final.jar.sha1 | 1 + .../netty-common-4.1.16.Final.jar.sha1 | 1 - .../netty-common-4.1.25.Final.jar.sha1 | 1 + .../netty-handler-4.1.16.Final.jar.sha1 | 1 - .../netty-handler-4.1.25.Final.jar.sha1 | 1 + .../netty-resolver-4.1.16.Final.jar.sha1 | 1 - .../netty-resolver-4.1.25.Final.jar.sha1 | 1 + .../netty-transport-4.1.16.Final.jar.sha1 | 1 - .../netty-transport-4.1.25.Final.jar.sha1 | 1 + .../plugin-metadata/plugin-security.policy | 2 + .../http/netty4/Netty4BadRequestTests.java | 4 +- .../http/netty4/Netty4HttpChannelTests.java | 4 +- .../Netty4HttpPipeliningHandlerTests.java | 4 +- .../netty4/Netty4HttpRequestSizeLimitIT.java | 4 +- .../Netty4HttpServerPipeliningTests.java | 4 +- .../Netty4HttpServerTransportTests.java | 4 +- .../http/netty4/Netty4PipeliningIT.java | 4 +- .../Netty4IntegTestCase.java} | 8 ++-- .../elasticsearch/test/Netty4TestCase.java | 26 +++++++++++++ .../test/ObjectCleanerThreadThreadFilter.java | 38 +++++++++++++++++++ .../netty4/ByteBufBytesReferenceTests.java | 3 ++ .../transport/netty4/ESLoggingHandlerIT.java | 4 +- .../netty4/Netty4ScheduledPingTests.java | 4 +- .../Netty4SizeHeaderFrameDecoderTests.java | 4 +- .../transport/netty4/Netty4TransportIT.java | 4 +- ...Netty4TransportMultiPortIntegrationIT.java | 4 +- .../Netty4TransportPublishAddressIT.java | 4 +- .../netty4/NettyTransportMultiPortTests.java | 4 +- .../netty4/SimpleNetty4TransportTests.java | 3 ++ plugins/transport-nio/build.gradle | 16 ++++---- .../netty-buffer-4.1.16.Final.jar.sha1 | 1 - .../netty-buffer-4.1.25.Final.jar.sha1 | 1 + .../netty-codec-4.1.16.Final.jar.sha1 | 1 - .../netty-codec-4.1.25.Final.jar.sha1 | 1 + .../netty-codec-http-4.1.16.Final.jar.sha1 | 1 - .../netty-codec-http-4.1.25.Final.jar.sha1 | 1 + .../netty-common-4.1.16.Final.jar.sha1 | 1 - .../netty-common-4.1.25.Final.jar.sha1 | 1 + .../netty-handler-4.1.16.Final.jar.sha1 | 1 - .../netty-handler-4.1.25.Final.jar.sha1 | 1 + .../netty-resolver-4.1.16.Final.jar.sha1 | 1 - .../netty-resolver-4.1.25.Final.jar.sha1 | 1 + .../netty-transport-4.1.16.Final.jar.sha1 | 1 - .../netty-transport-4.1.25.Final.jar.sha1 | 1 + .../plugin-metadata/plugin-security.policy | 2 + .../http/nio/HttpReadWriteHandlerTests.java | 4 +- .../http/nio/NettyAdaptorTests.java | 4 +- .../nio/NioHttpPipeliningHandlerTests.java | 4 +- .../http/nio/NioHttpServerTransportTests.java | 4 +- .../http/nio/NioPipeliningIT.java | 4 +- .../test/NioHttpIntegTestCase.java | 26 +++++++++++++ .../elasticsearch/test/NioHttpTestCase.java | 26 +++++++++++++ .../{ => test}/NioIntegTestCase.java | 3 +- .../test/ObjectCleanerThreadThreadFilter.java | 38 +++++++++++++++++++ .../transport/nio/NioTransportIT.java | 2 +- .../smoketest/ESSmokeClientTestCase.java | 18 +++++++++ .../elasticsearch/http/HttpSmokeTestCase.java | 14 +++++++ .../plugin-metadata/plugin-security.policy | 2 + .../AbstractLicensesIntegrationTestCase.java | 5 ++- .../license/StartBasicLicenseTests.java | 1 + .../test/ObjectCleanerThreadThreadFilter.java | 24 ++++++++++++ .../xpack/core/test/XPackIntegTestCase.java | 14 +++++++ .../core/test/XPackSingleNodeTestCase.java | 14 +++++++ .../xpack/ml/support/BaseMlIntegTestCase.java | 15 ++++---- .../plugin-metadata/plugin-security.policy | 2 + .../test/SecurityIntegTestCase.java | 5 ++- .../test/SecuritySingleNodeTestCase.java | 4 +- .../AbstractWatcherIntegrationTestCase.java | 4 +- .../xpack/security/audit/IndexAuditIT.java | 5 ++- .../MlNativeAutodetectIntegTestCase.java | 4 ++ x-pack/qa/security-client-tests/build.gradle | 1 + .../qa/SecurityTransportClientIT.java | 10 +++-- .../build.gradle | 1 + .../example/realm/CustomRealmIT.java | 5 ++- .../example/role/CustomRolesProviderIT.java | 3 +- x-pack/qa/security-migrate-tests/build.gradle | 1 + .../xpack/security/MigrateToolTestCase.java | 4 ++ x-pack/qa/smoke-test-plugins-ssl/build.gradle | 1 + .../SmokeTestMonitoringWithSecurityIT.java | 3 +- x-pack/qa/transport-client-tests/build.gradle | 1 + .../ml/client/ESXPackSmokeClientTestCase.java | 3 ++ 90 files changed, 419 insertions(+), 96 deletions(-) create mode 100644 modules/reindex/src/test/java/org/elasticsearch/index/reindex/test/ObjectCleanerThreadThreadFilter.java delete mode 100644 modules/transport-netty4/licenses/netty-buffer-4.1.16.Final.jar.sha1 create mode 100644 modules/transport-netty4/licenses/netty-buffer-4.1.25.Final.jar.sha1 delete mode 100644 modules/transport-netty4/licenses/netty-codec-4.1.16.Final.jar.sha1 create mode 100644 modules/transport-netty4/licenses/netty-codec-4.1.25.Final.jar.sha1 delete mode 100644 modules/transport-netty4/licenses/netty-codec-http-4.1.16.Final.jar.sha1 create mode 100644 modules/transport-netty4/licenses/netty-codec-http-4.1.25.Final.jar.sha1 delete mode 100644 modules/transport-netty4/licenses/netty-common-4.1.16.Final.jar.sha1 create mode 100644 modules/transport-netty4/licenses/netty-common-4.1.25.Final.jar.sha1 delete mode 100644 modules/transport-netty4/licenses/netty-handler-4.1.16.Final.jar.sha1 create mode 100644 modules/transport-netty4/licenses/netty-handler-4.1.25.Final.jar.sha1 delete mode 100644 modules/transport-netty4/licenses/netty-resolver-4.1.16.Final.jar.sha1 create mode 100644 modules/transport-netty4/licenses/netty-resolver-4.1.25.Final.jar.sha1 delete mode 100644 modules/transport-netty4/licenses/netty-transport-4.1.16.Final.jar.sha1 create mode 100644 modules/transport-netty4/licenses/netty-transport-4.1.25.Final.jar.sha1 rename modules/transport-netty4/src/test/java/org/elasticsearch/{ESNetty4IntegTestCase.java => test/Netty4IntegTestCase.java} (90%) create mode 100644 modules/transport-netty4/src/test/java/org/elasticsearch/test/Netty4TestCase.java create mode 100644 modules/transport-netty4/src/test/java/org/elasticsearch/test/ObjectCleanerThreadThreadFilter.java delete mode 100644 plugins/transport-nio/licenses/netty-buffer-4.1.16.Final.jar.sha1 create mode 100644 plugins/transport-nio/licenses/netty-buffer-4.1.25.Final.jar.sha1 delete mode 100644 plugins/transport-nio/licenses/netty-codec-4.1.16.Final.jar.sha1 create mode 100644 plugins/transport-nio/licenses/netty-codec-4.1.25.Final.jar.sha1 delete mode 100644 plugins/transport-nio/licenses/netty-codec-http-4.1.16.Final.jar.sha1 create mode 100644 plugins/transport-nio/licenses/netty-codec-http-4.1.25.Final.jar.sha1 delete mode 100644 plugins/transport-nio/licenses/netty-common-4.1.16.Final.jar.sha1 create mode 100644 plugins/transport-nio/licenses/netty-common-4.1.25.Final.jar.sha1 delete mode 100644 plugins/transport-nio/licenses/netty-handler-4.1.16.Final.jar.sha1 create mode 100644 plugins/transport-nio/licenses/netty-handler-4.1.25.Final.jar.sha1 delete mode 100644 plugins/transport-nio/licenses/netty-resolver-4.1.16.Final.jar.sha1 create mode 100644 plugins/transport-nio/licenses/netty-resolver-4.1.25.Final.jar.sha1 delete mode 100644 plugins/transport-nio/licenses/netty-transport-4.1.16.Final.jar.sha1 create mode 100644 plugins/transport-nio/licenses/netty-transport-4.1.25.Final.jar.sha1 create mode 100644 plugins/transport-nio/src/test/java/org/elasticsearch/test/NioHttpIntegTestCase.java create mode 100644 plugins/transport-nio/src/test/java/org/elasticsearch/test/NioHttpTestCase.java rename plugins/transport-nio/src/test/java/org/elasticsearch/{ => test}/NioIntegTestCase.java (97%) create mode 100644 plugins/transport-nio/src/test/java/org/elasticsearch/test/ObjectCleanerThreadThreadFilter.java create mode 100644 x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/test/ObjectCleanerThreadThreadFilter.java create mode 100644 x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/test/XPackIntegTestCase.java create mode 100644 x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/test/XPackSingleNodeTestCase.java diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexFromRemoteWithAuthTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexFromRemoteWithAuthTests.java index 72ba651dff9ae..940918de10dc6 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexFromRemoteWithAuthTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexFromRemoteWithAuthTests.java @@ -19,6 +19,7 @@ package org.elasticsearch.index.reindex; +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; import org.apache.lucene.util.SetOnce; import org.elasticsearch.ElasticsearchSecurityException; import org.elasticsearch.ElasticsearchStatusException; @@ -41,6 +42,7 @@ import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.env.Environment; import org.elasticsearch.env.NodeEnvironment; +import org.elasticsearch.index.reindex.test.ObjectCleanerThreadThreadFilter; import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.rest.RestStatus; @@ -64,6 +66,7 @@ import static org.elasticsearch.index.reindex.ReindexTestCase.matcher; import static org.hamcrest.Matchers.containsString; +@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class}) public class ReindexFromRemoteWithAuthTests extends ESSingleNodeTestCase { private TransportAddress address; diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RetryTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RetryTests.java index 1107a36086927..df00083587018 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RetryTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RetryTests.java @@ -19,6 +19,7 @@ package org.elasticsearch.index.reindex; +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse; @@ -32,6 +33,7 @@ import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.index.reindex.test.ObjectCleanerThreadThreadFilter; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.threadpool.ThreadPool; @@ -55,6 +57,7 @@ * Integration test for retry behavior. Useful because retrying relies on the way that the * rest of Elasticsearch throws exceptions and unit tests won't verify that. */ +@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class}) public class RetryTests extends ESIntegTestCase { private static final int DOC_COUNT = 20; diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/test/ObjectCleanerThreadThreadFilter.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/test/ObjectCleanerThreadThreadFilter.java new file mode 100644 index 0000000000000..948f1ec7fd6f6 --- /dev/null +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/test/ObjectCleanerThreadThreadFilter.java @@ -0,0 +1,32 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.index.reindex.test; + +import com.carrotsearch.randomizedtesting.ThreadFilter; + +public class ObjectCleanerThreadThreadFilter implements ThreadFilter { + + @Override + public boolean reject(final Thread t) { + // TODO: replace with constant from Netty when https://github.com/netty/netty/pull/8014 is integrated + return "ObjectCleanerThread".equals(t.getName()); + } + +} diff --git a/modules/transport-netty4/build.gradle b/modules/transport-netty4/build.gradle index 5d4bcd7c10a84..ed905a530c48e 100644 --- a/modules/transport-netty4/build.gradle +++ b/modules/transport-netty4/build.gradle @@ -34,13 +34,13 @@ compileTestJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-rawtypes,-tr dependencies { // network stack - compile "io.netty:netty-buffer:4.1.16.Final" - compile "io.netty:netty-codec:4.1.16.Final" - compile "io.netty:netty-codec-http:4.1.16.Final" - compile "io.netty:netty-common:4.1.16.Final" - compile "io.netty:netty-handler:4.1.16.Final" - compile "io.netty:netty-resolver:4.1.16.Final" - compile "io.netty:netty-transport:4.1.16.Final" + compile "io.netty:netty-buffer:4.1.25.Final" + compile "io.netty:netty-codec:4.1.25.Final" + compile "io.netty:netty-codec-http:4.1.25.Final" + compile "io.netty:netty-common:4.1.25.Final" + compile "io.netty:netty-handler:4.1.25.Final" + compile "io.netty:netty-resolver:4.1.25.Final" + compile "io.netty:netty-transport:4.1.25.Final" } dependencyLicenses { @@ -161,6 +161,6 @@ thirdPartyAudit.excludes = [ 'org.conscrypt.AllocatedBuffer', 'org.conscrypt.BufferAllocator', - 'org.conscrypt.Conscrypt$Engines', + 'org.conscrypt.Conscrypt', 'org.conscrypt.HandshakeListener' ] diff --git a/modules/transport-netty4/licenses/netty-buffer-4.1.16.Final.jar.sha1 b/modules/transport-netty4/licenses/netty-buffer-4.1.16.Final.jar.sha1 deleted file mode 100644 index c546222971985..0000000000000 --- a/modules/transport-netty4/licenses/netty-buffer-4.1.16.Final.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -63b5fa95c74785e16f2c30ce268bc222e35c8cb5 \ No newline at end of file diff --git a/modules/transport-netty4/licenses/netty-buffer-4.1.25.Final.jar.sha1 b/modules/transport-netty4/licenses/netty-buffer-4.1.25.Final.jar.sha1 new file mode 100644 index 0000000000000..3ca0cbb45ec31 --- /dev/null +++ b/modules/transport-netty4/licenses/netty-buffer-4.1.25.Final.jar.sha1 @@ -0,0 +1 @@ +f366d0cc87b158ca064d27507127e3cc4eb2f089 \ No newline at end of file diff --git a/modules/transport-netty4/licenses/netty-codec-4.1.16.Final.jar.sha1 b/modules/transport-netty4/licenses/netty-codec-4.1.16.Final.jar.sha1 deleted file mode 100644 index 1e6c241ea0b17..0000000000000 --- a/modules/transport-netty4/licenses/netty-codec-4.1.16.Final.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -d84a1f21768b7309c2954521cf5a1f46c2309eb1 \ No newline at end of file diff --git a/modules/transport-netty4/licenses/netty-codec-4.1.25.Final.jar.sha1 b/modules/transport-netty4/licenses/netty-codec-4.1.25.Final.jar.sha1 new file mode 100644 index 0000000000000..5e2bc85c548dd --- /dev/null +++ b/modules/transport-netty4/licenses/netty-codec-4.1.25.Final.jar.sha1 @@ -0,0 +1 @@ +3e465c75bead40d06b5b9c0612b37cf77c548887 \ No newline at end of file diff --git a/modules/transport-netty4/licenses/netty-codec-http-4.1.16.Final.jar.sha1 b/modules/transport-netty4/licenses/netty-codec-http-4.1.16.Final.jar.sha1 deleted file mode 100644 index 71c33af1c5fc2..0000000000000 --- a/modules/transport-netty4/licenses/netty-codec-http-4.1.16.Final.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -d64312378b438dfdad84267c599a053327c6f02a \ No newline at end of file diff --git a/modules/transport-netty4/licenses/netty-codec-http-4.1.25.Final.jar.sha1 b/modules/transport-netty4/licenses/netty-codec-http-4.1.25.Final.jar.sha1 new file mode 100644 index 0000000000000..58cb7fd987949 --- /dev/null +++ b/modules/transport-netty4/licenses/netty-codec-http-4.1.25.Final.jar.sha1 @@ -0,0 +1 @@ +70888d3f2a829541378f68503ddd52c3193df35a \ No newline at end of file diff --git a/modules/transport-netty4/licenses/netty-common-4.1.16.Final.jar.sha1 b/modules/transport-netty4/licenses/netty-common-4.1.16.Final.jar.sha1 deleted file mode 100644 index 3edf5fcea59b3..0000000000000 --- a/modules/transport-netty4/licenses/netty-common-4.1.16.Final.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -177a6b30cca92f6f5f9873c9befd681377a4c328 \ No newline at end of file diff --git a/modules/transport-netty4/licenses/netty-common-4.1.25.Final.jar.sha1 b/modules/transport-netty4/licenses/netty-common-4.1.25.Final.jar.sha1 new file mode 100644 index 0000000000000..62f85f8965513 --- /dev/null +++ b/modules/transport-netty4/licenses/netty-common-4.1.25.Final.jar.sha1 @@ -0,0 +1 @@ +e17d5c05c101fe14536ce3fb34b36c54e04791f6 \ No newline at end of file diff --git a/modules/transport-netty4/licenses/netty-handler-4.1.16.Final.jar.sha1 b/modules/transport-netty4/licenses/netty-handler-4.1.16.Final.jar.sha1 deleted file mode 100644 index cba27387268d1..0000000000000 --- a/modules/transport-netty4/licenses/netty-handler-4.1.16.Final.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -fec0e63e7dd7f4eeef7ea8dc47a1ff32dfc7ebc2 \ No newline at end of file diff --git a/modules/transport-netty4/licenses/netty-handler-4.1.25.Final.jar.sha1 b/modules/transport-netty4/licenses/netty-handler-4.1.25.Final.jar.sha1 new file mode 100644 index 0000000000000..5391f625a4df0 --- /dev/null +++ b/modules/transport-netty4/licenses/netty-handler-4.1.25.Final.jar.sha1 @@ -0,0 +1 @@ +ecdfb8fe93a8b75db3ea8746d3437eed845c24bd \ No newline at end of file diff --git a/modules/transport-netty4/licenses/netty-resolver-4.1.16.Final.jar.sha1 b/modules/transport-netty4/licenses/netty-resolver-4.1.16.Final.jar.sha1 deleted file mode 100644 index 3571d2ecfdc48..0000000000000 --- a/modules/transport-netty4/licenses/netty-resolver-4.1.16.Final.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -f6eb553b53fb3a90a8ac1170697093fed82eae28 \ No newline at end of file diff --git a/modules/transport-netty4/licenses/netty-resolver-4.1.25.Final.jar.sha1 b/modules/transport-netty4/licenses/netty-resolver-4.1.25.Final.jar.sha1 new file mode 100644 index 0000000000000..8225fb799e3ff --- /dev/null +++ b/modules/transport-netty4/licenses/netty-resolver-4.1.25.Final.jar.sha1 @@ -0,0 +1 @@ +dc0965d00746b782b33f419b005cbc130973030d \ No newline at end of file diff --git a/modules/transport-netty4/licenses/netty-transport-4.1.16.Final.jar.sha1 b/modules/transport-netty4/licenses/netty-transport-4.1.16.Final.jar.sha1 deleted file mode 100644 index e502d4c77084c..0000000000000 --- a/modules/transport-netty4/licenses/netty-transport-4.1.16.Final.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -3c8ee2c4d4a1cbb947a5c184c7aeb2204260958b \ No newline at end of file diff --git a/modules/transport-netty4/licenses/netty-transport-4.1.25.Final.jar.sha1 b/modules/transport-netty4/licenses/netty-transport-4.1.25.Final.jar.sha1 new file mode 100644 index 0000000000000..1049ea4b98bc6 --- /dev/null +++ b/modules/transport-netty4/licenses/netty-transport-4.1.25.Final.jar.sha1 @@ -0,0 +1 @@ +19a6f1f649894b6705aa9d8cbcced188dff133b0 \ No newline at end of file diff --git a/modules/transport-netty4/src/main/plugin-metadata/plugin-security.policy b/modules/transport-netty4/src/main/plugin-metadata/plugin-security.policy index 32b2dc9bd1540..3775931efb150 100644 --- a/modules/transport-netty4/src/main/plugin-metadata/plugin-security.policy +++ b/modules/transport-netty4/src/main/plugin-metadata/plugin-security.policy @@ -21,6 +21,8 @@ grant codeBase "${codebase.netty-common}" { // for reading the system-wide configuration for the backlog of established sockets permission java.io.FilePermission "/proc/sys/net/core/somaxconn", "read"; + permission java.lang.RuntimePermission "setContextClassLoader"; + // netty makes and accepts socket connections permission java.net.SocketPermission "*", "accept,connect"; }; diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4BadRequestTests.java b/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4BadRequestTests.java index 094f339059876..8baf818975ed8 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4BadRequestTests.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4BadRequestTests.java @@ -20,6 +20,7 @@ package org.elasticsearch.http.netty4; import io.netty.handler.codec.http.FullHttpResponse; +import org.elasticsearch.test.Netty4TestCase; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.common.network.NetworkService; import org.elasticsearch.common.settings.Settings; @@ -33,7 +34,6 @@ import org.elasticsearch.rest.RestChannel; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; import org.junit.After; @@ -48,7 +48,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; -public class Netty4BadRequestTests extends ESTestCase { +public class Netty4BadRequestTests extends Netty4TestCase { private NetworkService networkService; private MockBigArrays bigArrays; diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpChannelTests.java b/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpChannelTests.java index 7c5b35a322996..f7f04cfa540f6 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpChannelTests.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpChannelTests.java @@ -41,6 +41,7 @@ import io.netty.handler.codec.http.HttpVersion; import io.netty.util.Attribute; import io.netty.util.AttributeKey; +import org.elasticsearch.test.Netty4TestCase; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.bytes.ReleasablePagedBytesReference; import org.elasticsearch.common.io.stream.BytesStreamOutput; @@ -64,7 +65,6 @@ import org.elasticsearch.rest.BytesRestResponse; import org.elasticsearch.rest.RestResponse; import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.netty4.Netty4Utils; @@ -90,7 +90,7 @@ import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; -public class Netty4HttpChannelTests extends ESTestCase { +public class Netty4HttpChannelTests extends Netty4TestCase { private NetworkService networkService; private ThreadPool threadPool; diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpPipeliningHandlerTests.java b/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpPipeliningHandlerTests.java index 21151304424c1..606b050f4e393 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpPipeliningHandlerTests.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpPipeliningHandlerTests.java @@ -36,9 +36,9 @@ import io.netty.handler.codec.http.HttpVersion; import io.netty.handler.codec.http.LastHttpContent; import io.netty.handler.codec.http.QueryStringDecoder; +import org.elasticsearch.test.Netty4TestCase; import org.elasticsearch.common.Randomness; import org.elasticsearch.http.HttpPipelinedRequest; -import org.elasticsearch.test.ESTestCase; import org.junit.After; import java.nio.channels.ClosedChannelException; @@ -61,7 +61,7 @@ import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; import static org.hamcrest.core.Is.is; -public class Netty4HttpPipeliningHandlerTests extends ESTestCase { +public class Netty4HttpPipeliningHandlerTests extends Netty4TestCase { private final ExecutorService handlerService = Executors.newFixedThreadPool(randomIntBetween(4, 8)); private final ExecutorService eventLoopService = Executors.newFixedThreadPool(1); diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpRequestSizeLimitIT.java b/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpRequestSizeLimitIT.java index 269773fbb634c..ec3dbbf3846f0 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpRequestSizeLimitIT.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpRequestSizeLimitIT.java @@ -20,7 +20,7 @@ package org.elasticsearch.http.netty4; import io.netty.handler.codec.http.FullHttpResponse; -import org.elasticsearch.ESNetty4IntegTestCase; +import org.elasticsearch.test.Netty4IntegTestCase; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; @@ -45,7 +45,7 @@ * a single node "cluster". We also force test infrastructure to use the node client instead of the transport client for the same reason. */ @ClusterScope(scope = Scope.TEST, supportsDedicatedMasters = false, numClientNodes = 0, numDataNodes = 1, transportClientRatio = 0) -public class Netty4HttpRequestSizeLimitIT extends ESNetty4IntegTestCase { +public class Netty4HttpRequestSizeLimitIT extends Netty4IntegTestCase { private static final ByteSizeValue LIMIT = new ByteSizeValue(2, ByteSizeUnit.KB); diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpServerPipeliningTests.java b/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpServerPipeliningTests.java index f2b28b909187b..68b51f8acc13f 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpServerPipeliningTests.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpServerPipeliningTests.java @@ -32,6 +32,7 @@ import io.netty.handler.codec.http.HttpHeaderNames; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.handler.codec.http.HttpVersion; +import org.elasticsearch.test.Netty4TestCase; import org.elasticsearch.common.network.NetworkService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; @@ -42,7 +43,6 @@ import org.elasticsearch.http.HttpServerTransport; import org.elasticsearch.http.NullDispatcher; import org.elasticsearch.indices.breaker.NoneCircuitBreakerService; -import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; import org.junit.After; @@ -61,7 +61,7 @@ /** * This test just tests, if he pipelining works in general with out any connection the Elasticsearch handler */ -public class Netty4HttpServerPipeliningTests extends ESTestCase { +public class Netty4HttpServerPipeliningTests extends Netty4TestCase { private NetworkService networkService; private ThreadPool threadPool; private MockBigArrays bigArrays; diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpServerTransportTests.java b/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpServerTransportTests.java index 5b22409b92da0..1df18459a0352 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpServerTransportTests.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpServerTransportTests.java @@ -38,6 +38,7 @@ import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.handler.codec.http.HttpUtil; import io.netty.handler.codec.http.HttpVersion; +import org.elasticsearch.test.Netty4TestCase; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesArray; @@ -59,7 +60,6 @@ import org.elasticsearch.rest.BytesRestResponse; import org.elasticsearch.rest.RestChannel; import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; import org.junit.After; @@ -94,7 +94,7 @@ /** * Tests for the {@link Netty4HttpServerTransport} class. */ -public class Netty4HttpServerTransportTests extends ESTestCase { +public class Netty4HttpServerTransportTests extends Netty4TestCase { private NetworkService networkService; private ThreadPool threadPool; diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4PipeliningIT.java b/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4PipeliningIT.java index ebb91d9663ed5..c90992a69d0b3 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4PipeliningIT.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4PipeliningIT.java @@ -20,7 +20,7 @@ package org.elasticsearch.http.netty4; import io.netty.handler.codec.http.FullHttpResponse; -import org.elasticsearch.ESNetty4IntegTestCase; +import org.elasticsearch.test.Netty4IntegTestCase; import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.http.HttpServerTransport; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; @@ -33,7 +33,7 @@ import static org.hamcrest.Matchers.is; @ClusterScope(scope = Scope.TEST, supportsDedicatedMasters = false, numDataNodes = 1) -public class Netty4PipeliningIT extends ESNetty4IntegTestCase { +public class Netty4PipeliningIT extends Netty4IntegTestCase { @Override protected boolean addMockHttpTransport() { diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/ESNetty4IntegTestCase.java b/modules/transport-netty4/src/test/java/org/elasticsearch/test/Netty4IntegTestCase.java similarity index 90% rename from modules/transport-netty4/src/test/java/org/elasticsearch/ESNetty4IntegTestCase.java rename to modules/transport-netty4/src/test/java/org/elasticsearch/test/Netty4IntegTestCase.java index b38cda76c6980..c21b863d196b7 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/ESNetty4IntegTestCase.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/test/Netty4IntegTestCase.java @@ -16,19 +16,21 @@ * specific language governing permissions and limitations * under the License. */ -package org.elasticsearch; +package org.elasticsearch.test; + +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.transport.Netty4Plugin; import org.elasticsearch.transport.netty4.Netty4Transport; import java.util.Arrays; import java.util.Collection; -public abstract class ESNetty4IntegTestCase extends ESIntegTestCase { +@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class}) +public abstract class Netty4IntegTestCase extends ESIntegTestCase { @Override protected boolean ignoreExternalCluster() { diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/test/Netty4TestCase.java b/modules/transport-netty4/src/test/java/org/elasticsearch/test/Netty4TestCase.java new file mode 100644 index 0000000000000..df931d61992ef --- /dev/null +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/test/Netty4TestCase.java @@ -0,0 +1,26 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.test; + +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; + +@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class}) +public abstract class Netty4TestCase extends ESTestCase { +} diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/test/ObjectCleanerThreadThreadFilter.java b/modules/transport-netty4/src/test/java/org/elasticsearch/test/ObjectCleanerThreadThreadFilter.java new file mode 100644 index 0000000000000..e47c536665d13 --- /dev/null +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/test/ObjectCleanerThreadThreadFilter.java @@ -0,0 +1,38 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.test; + +import com.carrotsearch.randomizedtesting.ThreadFilter; + +/** + * The Netty object cleaner thread is not closeable and it does not terminate in a timely manner. This means that thread leak control in + * tests will fail test suites when the object cleaner thread has not terminated. Since there is not a reliable way to terminate this thread + * we instead filter it out of thread leak control. + */ +public class ObjectCleanerThreadThreadFilter implements ThreadFilter { + + @Override + public boolean reject(final Thread t) { + // TODO: replace with constant from Netty when https://github.com/netty/netty/pull/8014 is integrated + return "ObjectCleanerThread".equals(t.getName()); + } + +} + diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/ByteBufBytesReferenceTests.java b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/ByteBufBytesReferenceTests.java index 4a41aaec952a0..618d3ffe8f96a 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/ByteBufBytesReferenceTests.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/ByteBufBytesReferenceTests.java @@ -18,15 +18,18 @@ */ package org.elasticsearch.transport.netty4; +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import org.apache.lucene.util.BytesRef; +import org.elasticsearch.test.ObjectCleanerThreadThreadFilter; import org.elasticsearch.common.bytes.AbstractBytesReferenceTestCase; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.ReleasableBytesStreamOutput; import java.io.IOException; +@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class}) public class ByteBufBytesReferenceTests extends AbstractBytesReferenceTestCase { @Override diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/ESLoggingHandlerIT.java b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/ESLoggingHandlerIT.java index acd71749e2333..8ef8b28dc1497 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/ESLoggingHandlerIT.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/ESLoggingHandlerIT.java @@ -20,7 +20,7 @@ package org.elasticsearch.transport.netty4; import org.apache.logging.log4j.Level; -import org.elasticsearch.ESNetty4IntegTestCase; +import org.elasticsearch.test.Netty4IntegTestCase; import org.elasticsearch.action.admin.cluster.node.hotthreads.NodesHotThreadsRequest; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.test.ESIntegTestCase; @@ -29,7 +29,7 @@ @ESIntegTestCase.ClusterScope(numDataNodes = 2) @TestLogging(value = "org.elasticsearch.transport.netty4.ESLoggingHandler:trace") -public class ESLoggingHandlerIT extends ESNetty4IntegTestCase { +public class ESLoggingHandlerIT extends Netty4IntegTestCase { private MockLogAppender appender; diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4ScheduledPingTests.java b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4ScheduledPingTests.java index b967a7ea41069..b4b33ba96211c 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4ScheduledPingTests.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4ScheduledPingTests.java @@ -18,6 +18,7 @@ */ package org.elasticsearch.transport.netty4; +import org.elasticsearch.test.Netty4TestCase; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.lease.Releasables; @@ -26,7 +27,6 @@ import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.indices.breaker.NoneCircuitBreakerService; -import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.transport.MockTransportService; import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; @@ -47,7 +47,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; -public class Netty4ScheduledPingTests extends ESTestCase { +public class Netty4ScheduledPingTests extends Netty4TestCase { public void testScheduledPing() throws Exception { ThreadPool threadPool = new TestThreadPool(getClass().getName()); diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4SizeHeaderFrameDecoderTests.java b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4SizeHeaderFrameDecoderTests.java index 7343da6c3b11a..0819548907296 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4SizeHeaderFrameDecoderTests.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4SizeHeaderFrameDecoderTests.java @@ -19,6 +19,7 @@ package org.elasticsearch.transport.netty4; +import org.elasticsearch.test.Netty4TestCase; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.network.NetworkService; import org.elasticsearch.common.settings.Settings; @@ -28,7 +29,6 @@ import org.elasticsearch.common.util.MockPageCacheRecycler; import org.elasticsearch.indices.breaker.NoneCircuitBreakerService; import org.elasticsearch.mocksocket.MockSocket; -import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TcpTransport; import org.junit.After; @@ -47,7 +47,7 @@ * This test checks, if a HTTP look-alike request (starting with a HTTP method and a space) * actually returns text response instead of just dropping the connection */ -public class Netty4SizeHeaderFrameDecoderTests extends ESTestCase { +public class Netty4SizeHeaderFrameDecoderTests extends Netty4TestCase { private final Settings settings = Settings.builder() .put("node.name", "NettySizeHeaderFrameDecoderTests") diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4TransportIT.java b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4TransportIT.java index b81c8efcb47ee..a426c11db8245 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4TransportIT.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4TransportIT.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.transport.netty4; -import org.elasticsearch.ESNetty4IntegTestCase; +import org.elasticsearch.test.Netty4IntegTestCase; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.Version; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; @@ -54,7 +54,7 @@ import static org.hamcrest.Matchers.is; @ClusterScope(scope = Scope.TEST, supportsDedicatedMasters = false, numDataNodes = 1) -public class Netty4TransportIT extends ESNetty4IntegTestCase { +public class Netty4TransportIT extends Netty4IntegTestCase { // static so we can use it in anonymous classes private static String channelProfileName = null; diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4TransportMultiPortIntegrationIT.java b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4TransportMultiPortIntegrationIT.java index 52ad32efb5645..ddef8abcf0181 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4TransportMultiPortIntegrationIT.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4TransportMultiPortIntegrationIT.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.transport.netty4; -import org.elasticsearch.ESNetty4IntegTestCase; +import org.elasticsearch.test.Netty4IntegTestCase; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; @@ -48,7 +48,7 @@ import static org.hamcrest.Matchers.lessThanOrEqualTo; @ClusterScope(scope = Scope.SUITE, supportsDedicatedMasters = false, numDataNodes = 1, numClientNodes = 0) -public class Netty4TransportMultiPortIntegrationIT extends ESNetty4IntegTestCase { +public class Netty4TransportMultiPortIntegrationIT extends Netty4IntegTestCase { private static int randomPort = -1; private static String randomPortRange; diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4TransportPublishAddressIT.java b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4TransportPublishAddressIT.java index 922031d3c3dea..dee104a73f7d7 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4TransportPublishAddressIT.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4TransportPublishAddressIT.java @@ -19,7 +19,7 @@ package org.elasticsearch.transport.netty4; -import org.elasticsearch.ESNetty4IntegTestCase; +import org.elasticsearch.test.Netty4IntegTestCase; import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; import org.elasticsearch.common.network.NetworkModule; @@ -41,7 +41,7 @@ * different ports on ipv4 and ipv6. */ @ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) -public class Netty4TransportPublishAddressIT extends ESNetty4IntegTestCase { +public class Netty4TransportPublishAddressIT extends Netty4IntegTestCase { @Override protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder() diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/NettyTransportMultiPortTests.java b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/NettyTransportMultiPortTests.java index a49df3caaba4e..05d6d55ac42da 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/NettyTransportMultiPortTests.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/NettyTransportMultiPortTests.java @@ -18,6 +18,7 @@ */ package org.elasticsearch.transport.netty4; +import org.elasticsearch.test.Netty4TestCase; import org.elasticsearch.common.component.Lifecycle; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.network.NetworkService; @@ -27,7 +28,6 @@ import org.elasticsearch.common.util.MockBigArrays; import org.elasticsearch.common.util.MockPageCacheRecycler; import org.elasticsearch.indices.breaker.NoneCircuitBreakerService; -import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TcpTransport; @@ -37,7 +37,7 @@ import static org.hamcrest.Matchers.is; -public class NettyTransportMultiPortTests extends ESTestCase { +public class NettyTransportMultiPortTests extends Netty4TestCase { private String host; diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/SimpleNetty4TransportTests.java b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/SimpleNetty4TransportTests.java index efa296b6278af..278b00965c9a5 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/SimpleNetty4TransportTests.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/SimpleNetty4TransportTests.java @@ -19,6 +19,8 @@ package org.elasticsearch.transport.netty4; +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; +import org.elasticsearch.test.ObjectCleanerThreadThreadFilter; import org.elasticsearch.Version; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; @@ -49,6 +51,7 @@ import static java.util.Collections.emptySet; import static org.hamcrest.Matchers.containsString; +@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class}) public class SimpleNetty4TransportTests extends AbstractSimpleTransportTestCase { public static MockTransportService nettyFromThreadPool(Settings settings, ThreadPool threadPool, final Version version, diff --git a/plugins/transport-nio/build.gradle b/plugins/transport-nio/build.gradle index 856a8552b8e5a..e76008ae28400 100644 --- a/plugins/transport-nio/build.gradle +++ b/plugins/transport-nio/build.gradle @@ -29,13 +29,13 @@ dependencies { compile "org.elasticsearch:elasticsearch-nio:${version}" // network stack - compile "io.netty:netty-buffer:4.1.16.Final" - compile "io.netty:netty-codec:4.1.16.Final" - compile "io.netty:netty-codec-http:4.1.16.Final" - compile "io.netty:netty-common:4.1.16.Final" - compile "io.netty:netty-handler:4.1.16.Final" - compile "io.netty:netty-resolver:4.1.16.Final" - compile "io.netty:netty-transport:4.1.16.Final" + compile "io.netty:netty-buffer:4.1.25.Final" + compile "io.netty:netty-codec:4.1.25.Final" + compile "io.netty:netty-codec-http:4.1.25.Final" + compile "io.netty:netty-common:4.1.25.Final" + compile "io.netty:netty-handler:4.1.25.Final" + compile "io.netty:netty-resolver:4.1.25.Final" + compile "io.netty:netty-transport:4.1.25.Final" } dependencyLicenses { @@ -140,6 +140,6 @@ thirdPartyAudit.excludes = [ 'org.conscrypt.AllocatedBuffer', 'org.conscrypt.BufferAllocator', - 'org.conscrypt.Conscrypt$Engines', + 'org.conscrypt.Conscrypt', 'org.conscrypt.HandshakeListener' ] \ No newline at end of file diff --git a/plugins/transport-nio/licenses/netty-buffer-4.1.16.Final.jar.sha1 b/plugins/transport-nio/licenses/netty-buffer-4.1.16.Final.jar.sha1 deleted file mode 100644 index c546222971985..0000000000000 --- a/plugins/transport-nio/licenses/netty-buffer-4.1.16.Final.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -63b5fa95c74785e16f2c30ce268bc222e35c8cb5 \ No newline at end of file diff --git a/plugins/transport-nio/licenses/netty-buffer-4.1.25.Final.jar.sha1 b/plugins/transport-nio/licenses/netty-buffer-4.1.25.Final.jar.sha1 new file mode 100644 index 0000000000000..3ca0cbb45ec31 --- /dev/null +++ b/plugins/transport-nio/licenses/netty-buffer-4.1.25.Final.jar.sha1 @@ -0,0 +1 @@ +f366d0cc87b158ca064d27507127e3cc4eb2f089 \ No newline at end of file diff --git a/plugins/transport-nio/licenses/netty-codec-4.1.16.Final.jar.sha1 b/plugins/transport-nio/licenses/netty-codec-4.1.16.Final.jar.sha1 deleted file mode 100644 index 1e6c241ea0b17..0000000000000 --- a/plugins/transport-nio/licenses/netty-codec-4.1.16.Final.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -d84a1f21768b7309c2954521cf5a1f46c2309eb1 \ No newline at end of file diff --git a/plugins/transport-nio/licenses/netty-codec-4.1.25.Final.jar.sha1 b/plugins/transport-nio/licenses/netty-codec-4.1.25.Final.jar.sha1 new file mode 100644 index 0000000000000..5e2bc85c548dd --- /dev/null +++ b/plugins/transport-nio/licenses/netty-codec-4.1.25.Final.jar.sha1 @@ -0,0 +1 @@ +3e465c75bead40d06b5b9c0612b37cf77c548887 \ No newline at end of file diff --git a/plugins/transport-nio/licenses/netty-codec-http-4.1.16.Final.jar.sha1 b/plugins/transport-nio/licenses/netty-codec-http-4.1.16.Final.jar.sha1 deleted file mode 100644 index 71c33af1c5fc2..0000000000000 --- a/plugins/transport-nio/licenses/netty-codec-http-4.1.16.Final.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -d64312378b438dfdad84267c599a053327c6f02a \ No newline at end of file diff --git a/plugins/transport-nio/licenses/netty-codec-http-4.1.25.Final.jar.sha1 b/plugins/transport-nio/licenses/netty-codec-http-4.1.25.Final.jar.sha1 new file mode 100644 index 0000000000000..58cb7fd987949 --- /dev/null +++ b/plugins/transport-nio/licenses/netty-codec-http-4.1.25.Final.jar.sha1 @@ -0,0 +1 @@ +70888d3f2a829541378f68503ddd52c3193df35a \ No newline at end of file diff --git a/plugins/transport-nio/licenses/netty-common-4.1.16.Final.jar.sha1 b/plugins/transport-nio/licenses/netty-common-4.1.16.Final.jar.sha1 deleted file mode 100644 index 3edf5fcea59b3..0000000000000 --- a/plugins/transport-nio/licenses/netty-common-4.1.16.Final.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -177a6b30cca92f6f5f9873c9befd681377a4c328 \ No newline at end of file diff --git a/plugins/transport-nio/licenses/netty-common-4.1.25.Final.jar.sha1 b/plugins/transport-nio/licenses/netty-common-4.1.25.Final.jar.sha1 new file mode 100644 index 0000000000000..62f85f8965513 --- /dev/null +++ b/plugins/transport-nio/licenses/netty-common-4.1.25.Final.jar.sha1 @@ -0,0 +1 @@ +e17d5c05c101fe14536ce3fb34b36c54e04791f6 \ No newline at end of file diff --git a/plugins/transport-nio/licenses/netty-handler-4.1.16.Final.jar.sha1 b/plugins/transport-nio/licenses/netty-handler-4.1.16.Final.jar.sha1 deleted file mode 100644 index cba27387268d1..0000000000000 --- a/plugins/transport-nio/licenses/netty-handler-4.1.16.Final.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -fec0e63e7dd7f4eeef7ea8dc47a1ff32dfc7ebc2 \ No newline at end of file diff --git a/plugins/transport-nio/licenses/netty-handler-4.1.25.Final.jar.sha1 b/plugins/transport-nio/licenses/netty-handler-4.1.25.Final.jar.sha1 new file mode 100644 index 0000000000000..5391f625a4df0 --- /dev/null +++ b/plugins/transport-nio/licenses/netty-handler-4.1.25.Final.jar.sha1 @@ -0,0 +1 @@ +ecdfb8fe93a8b75db3ea8746d3437eed845c24bd \ No newline at end of file diff --git a/plugins/transport-nio/licenses/netty-resolver-4.1.16.Final.jar.sha1 b/plugins/transport-nio/licenses/netty-resolver-4.1.16.Final.jar.sha1 deleted file mode 100644 index 3571d2ecfdc48..0000000000000 --- a/plugins/transport-nio/licenses/netty-resolver-4.1.16.Final.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -f6eb553b53fb3a90a8ac1170697093fed82eae28 \ No newline at end of file diff --git a/plugins/transport-nio/licenses/netty-resolver-4.1.25.Final.jar.sha1 b/plugins/transport-nio/licenses/netty-resolver-4.1.25.Final.jar.sha1 new file mode 100644 index 0000000000000..8225fb799e3ff --- /dev/null +++ b/plugins/transport-nio/licenses/netty-resolver-4.1.25.Final.jar.sha1 @@ -0,0 +1 @@ +dc0965d00746b782b33f419b005cbc130973030d \ No newline at end of file diff --git a/plugins/transport-nio/licenses/netty-transport-4.1.16.Final.jar.sha1 b/plugins/transport-nio/licenses/netty-transport-4.1.16.Final.jar.sha1 deleted file mode 100644 index e502d4c77084c..0000000000000 --- a/plugins/transport-nio/licenses/netty-transport-4.1.16.Final.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -3c8ee2c4d4a1cbb947a5c184c7aeb2204260958b \ No newline at end of file diff --git a/plugins/transport-nio/licenses/netty-transport-4.1.25.Final.jar.sha1 b/plugins/transport-nio/licenses/netty-transport-4.1.25.Final.jar.sha1 new file mode 100644 index 0000000000000..1049ea4b98bc6 --- /dev/null +++ b/plugins/transport-nio/licenses/netty-transport-4.1.25.Final.jar.sha1 @@ -0,0 +1 @@ +19a6f1f649894b6705aa9d8cbcced188dff133b0 \ No newline at end of file diff --git a/plugins/transport-nio/src/main/plugin-metadata/plugin-security.policy b/plugins/transport-nio/src/main/plugin-metadata/plugin-security.policy index 8c8fe7c327412..dcd193a779b09 100644 --- a/plugins/transport-nio/src/main/plugin-metadata/plugin-security.policy +++ b/plugins/transport-nio/src/main/plugin-metadata/plugin-security.policy @@ -23,6 +23,8 @@ grant codeBase "${codebase.elasticsearch-nio}" { }; grant codeBase "${codebase.netty-common}" { + permission java.lang.RuntimePermission "setContextClassLoader"; + // This should only currently be required as we use the netty http client for tests // netty makes and accepts socket connections permission java.net.SocketPermission "*", "accept,connect"; diff --git a/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/HttpReadWriteHandlerTests.java b/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/HttpReadWriteHandlerTests.java index 6ad53521ee12a..f045de3d566a4 100644 --- a/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/HttpReadWriteHandlerTests.java +++ b/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/HttpReadWriteHandlerTests.java @@ -46,7 +46,7 @@ import org.elasticsearch.nio.SocketChannelContext; import org.elasticsearch.rest.RestChannel; import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.test.NioHttpTestCase; import org.junit.Before; import org.mockito.ArgumentCaptor; @@ -69,7 +69,7 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -public class HttpReadWriteHandlerTests extends ESTestCase { +public class HttpReadWriteHandlerTests extends NioHttpTestCase { private HttpReadWriteHandler handler; private NioSocketChannel nioSocketChannel; diff --git a/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/NettyAdaptorTests.java b/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/NettyAdaptorTests.java index d6944a5f510e2..5900af7f98bd0 100644 --- a/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/NettyAdaptorTests.java +++ b/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/NettyAdaptorTests.java @@ -27,14 +27,14 @@ import io.netty.channel.ChannelPromise; import io.netty.channel.SimpleChannelInboundHandler; import org.elasticsearch.nio.FlushOperation; -import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.test.NioHttpTestCase; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.util.Locale; import java.util.concurrent.atomic.AtomicBoolean; -public class NettyAdaptorTests extends ESTestCase { +public class NettyAdaptorTests extends NioHttpTestCase { public void testBasicRead() { TenIntsToStringsHandler handler = new TenIntsToStringsHandler(); diff --git a/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/NioHttpPipeliningHandlerTests.java b/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/NioHttpPipeliningHandlerTests.java index d12c608aeca2a..b156ef027c086 100644 --- a/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/NioHttpPipeliningHandlerTests.java +++ b/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/NioHttpPipeliningHandlerTests.java @@ -38,7 +38,7 @@ import io.netty.handler.codec.http.QueryStringDecoder; import org.elasticsearch.common.Randomness; import org.elasticsearch.http.HttpPipelinedRequest; -import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.test.NioHttpTestCase; import org.junit.After; import java.nio.channels.ClosedChannelException; @@ -61,7 +61,7 @@ import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; import static org.hamcrest.core.Is.is; -public class NioHttpPipeliningHandlerTests extends ESTestCase { +public class NioHttpPipeliningHandlerTests extends NioHttpTestCase { private final ExecutorService handlerService = Executors.newFixedThreadPool(randomIntBetween(4, 8)); private final ExecutorService eventLoopService = Executors.newFixedThreadPool(1); diff --git a/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/NioHttpServerTransportTests.java b/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/NioHttpServerTransportTests.java index c43fc7d072360..421e235baaea0 100644 --- a/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/NioHttpServerTransportTests.java +++ b/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/NioHttpServerTransportTests.java @@ -51,7 +51,7 @@ import org.elasticsearch.rest.BytesRestResponse; import org.elasticsearch.rest.RestChannel; import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.test.NioHttpTestCase; import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; import org.junit.After; @@ -83,7 +83,7 @@ /** * Tests for the {@link NioHttpServerTransport} class. */ -public class NioHttpServerTransportTests extends ESTestCase { +public class NioHttpServerTransportTests extends NioHttpTestCase { private NetworkService networkService; private ThreadPool threadPool; diff --git a/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/NioPipeliningIT.java b/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/NioPipeliningIT.java index 074aafd6eab4b..4245031aa48ff 100644 --- a/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/NioPipeliningIT.java +++ b/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/NioPipeliningIT.java @@ -20,11 +20,11 @@ package org.elasticsearch.http.nio; import io.netty.handler.codec.http.FullHttpResponse; -import org.elasticsearch.NioIntegTestCase; import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.http.HttpServerTransport; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.ESIntegTestCase.Scope; +import org.elasticsearch.test.NioHttpIntegTestCase; import java.util.Collection; import java.util.Locale; @@ -33,7 +33,7 @@ import static org.hamcrest.Matchers.is; @ClusterScope(scope = Scope.TEST, supportsDedicatedMasters = false, numDataNodes = 1) -public class NioPipeliningIT extends NioIntegTestCase { +public class NioPipeliningIT extends NioHttpIntegTestCase { @Override protected boolean addMockHttpTransport() { diff --git a/plugins/transport-nio/src/test/java/org/elasticsearch/test/NioHttpIntegTestCase.java b/plugins/transport-nio/src/test/java/org/elasticsearch/test/NioHttpIntegTestCase.java new file mode 100644 index 0000000000000..d20ac8737fadf --- /dev/null +++ b/plugins/transport-nio/src/test/java/org/elasticsearch/test/NioHttpIntegTestCase.java @@ -0,0 +1,26 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.test; + +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; + +@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class}) +public abstract class NioHttpIntegTestCase extends NioIntegTestCase { +} diff --git a/plugins/transport-nio/src/test/java/org/elasticsearch/test/NioHttpTestCase.java b/plugins/transport-nio/src/test/java/org/elasticsearch/test/NioHttpTestCase.java new file mode 100644 index 0000000000000..9e8a55170f9b7 --- /dev/null +++ b/plugins/transport-nio/src/test/java/org/elasticsearch/test/NioHttpTestCase.java @@ -0,0 +1,26 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.test; + +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; + +@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class}) +public abstract class NioHttpTestCase extends ESTestCase { +} diff --git a/plugins/transport-nio/src/test/java/org/elasticsearch/NioIntegTestCase.java b/plugins/transport-nio/src/test/java/org/elasticsearch/test/NioIntegTestCase.java similarity index 97% rename from plugins/transport-nio/src/test/java/org/elasticsearch/NioIntegTestCase.java rename to plugins/transport-nio/src/test/java/org/elasticsearch/test/NioIntegTestCase.java index 703f7acbf8257..fb0ea8d9caa9f 100644 --- a/plugins/transport-nio/src/test/java/org/elasticsearch/NioIntegTestCase.java +++ b/plugins/transport-nio/src/test/java/org/elasticsearch/test/NioIntegTestCase.java @@ -16,13 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -package org.elasticsearch; +package org.elasticsearch.test; import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.http.nio.NioHttpServerTransport; import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.transport.nio.NioTransport; import org.elasticsearch.transport.nio.NioTransportPlugin; diff --git a/plugins/transport-nio/src/test/java/org/elasticsearch/test/ObjectCleanerThreadThreadFilter.java b/plugins/transport-nio/src/test/java/org/elasticsearch/test/ObjectCleanerThreadThreadFilter.java new file mode 100644 index 0000000000000..e47c536665d13 --- /dev/null +++ b/plugins/transport-nio/src/test/java/org/elasticsearch/test/ObjectCleanerThreadThreadFilter.java @@ -0,0 +1,38 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.test; + +import com.carrotsearch.randomizedtesting.ThreadFilter; + +/** + * The Netty object cleaner thread is not closeable and it does not terminate in a timely manner. This means that thread leak control in + * tests will fail test suites when the object cleaner thread has not terminated. Since there is not a reliable way to terminate this thread + * we instead filter it out of thread leak control. + */ +public class ObjectCleanerThreadThreadFilter implements ThreadFilter { + + @Override + public boolean reject(final Thread t) { + // TODO: replace with constant from Netty when https://github.com/netty/netty/pull/8014 is integrated + return "ObjectCleanerThread".equals(t.getName()); + } + +} + diff --git a/plugins/transport-nio/src/test/java/org/elasticsearch/transport/nio/NioTransportIT.java b/plugins/transport-nio/src/test/java/org/elasticsearch/transport/nio/NioTransportIT.java index df53a4d79c7ad..d1beed213a4e5 100644 --- a/plugins/transport-nio/src/test/java/org/elasticsearch/transport/nio/NioTransportIT.java +++ b/plugins/transport-nio/src/test/java/org/elasticsearch/transport/nio/NioTransportIT.java @@ -19,7 +19,6 @@ package org.elasticsearch.transport.nio; import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.NioIntegTestCase; import org.elasticsearch.Version; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.client.Client; @@ -36,6 +35,7 @@ import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.ESIntegTestCase.Scope; +import org.elasticsearch.test.NioIntegTestCase; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TcpChannel; import org.elasticsearch.transport.TcpTransport; diff --git a/qa/smoke-test-client/src/test/java/org/elasticsearch/smoketest/ESSmokeClientTestCase.java b/qa/smoke-test-client/src/test/java/org/elasticsearch/smoketest/ESSmokeClientTestCase.java index 8f32271948763..5406c5dfde423 100644 --- a/qa/smoke-test-client/src/test/java/org/elasticsearch/smoketest/ESSmokeClientTestCase.java +++ b/qa/smoke-test-client/src/test/java/org/elasticsearch/smoketest/ESSmokeClientTestCase.java @@ -19,6 +19,8 @@ package org.elasticsearch.smoketest; +import com.carrotsearch.randomizedtesting.ThreadFilter; +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; import org.apache.logging.log4j.Logger; import org.apache.lucene.util.LuceneTestCase; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; @@ -62,8 +64,24 @@ * then run JUnit. If you changed the default port, set "-Dtests.cluster=localhost:PORT" when running your test. */ @LuceneTestCase.SuppressSysoutChecks(bugUrl = "we log a lot on purpose") +@ThreadLeakFilters(filters = {ESSmokeClientTestCase.ObjectCleanerThreadThreadFilter.class}) public abstract class ESSmokeClientTestCase extends LuceneTestCase { + /** + * The Netty object cleaner thread is not closeable and it does not terminate in a timely manner. This means that thread leak control in + * tests will fail test suites when the object cleaner thread has not terminated. Since there is not a reliable way to terminate this + * thread we instead filter it out of thread leak control. + */ + public static class ObjectCleanerThreadThreadFilter implements ThreadFilter { + + @Override + public boolean reject(final Thread t) { + // TODO: replace with constant from Netty when https://github.com/netty/netty/pull/8014 is integrated + return "ObjectCleanerThread".equals(t.getName()); + } + + } + /** * Key used to eventually switch to using an external cluster and provide its transport addresses */ diff --git a/qa/smoke-test-http/src/test/java/org/elasticsearch/http/HttpSmokeTestCase.java b/qa/smoke-test-http/src/test/java/org/elasticsearch/http/HttpSmokeTestCase.java index bac5423e751ea..4177a72e08baf 100644 --- a/qa/smoke-test-http/src/test/java/org/elasticsearch/http/HttpSmokeTestCase.java +++ b/qa/smoke-test-http/src/test/java/org/elasticsearch/http/HttpSmokeTestCase.java @@ -18,10 +18,13 @@ */ package org.elasticsearch.http; +import com.carrotsearch.randomizedtesting.ThreadFilter; +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESIntegTestCase; +import org.elasticsearch.test.ESTestCase; import org.elasticsearch.transport.MockTcpTransportPlugin; import org.elasticsearch.transport.Netty4Plugin; import org.elasticsearch.transport.nio.MockNioTransportPlugin; @@ -31,8 +34,19 @@ import java.util.Arrays; import java.util.Collection; +@ThreadLeakFilters(filters = {HttpSmokeTestCase.ObjectCleanerThreadThreadFilter.class}) public abstract class HttpSmokeTestCase extends ESIntegTestCase { + public static class ObjectCleanerThreadThreadFilter implements ThreadFilter { + + @Override + public boolean reject(final Thread t) { + // TODO: replace with constant from Netty when https://github.com/netty/netty/pull/8014 is integrated + return "ObjectCleanerThread".equals(t.getName()); + } + + } + private static String nodeTransportTypeKey; private static String nodeHttpTypeKey; private static String clientTypeKey; diff --git a/x-pack/plugin/core/src/main/plugin-metadata/plugin-security.policy b/x-pack/plugin/core/src/main/plugin-metadata/plugin-security.policy index 0cd7a32bcc47b..1f1bd66005693 100644 --- a/x-pack/plugin/core/src/main/plugin-metadata/plugin-security.policy +++ b/x-pack/plugin/core/src/main/plugin-metadata/plugin-security.policy @@ -15,6 +15,8 @@ grant { grant codeBase "${codebase.netty-common}" { // for reading the system-wide configuration for the backlog of established sockets permission java.io.FilePermission "/proc/sys/net/core/somaxconn", "read"; + + permission java.lang.RuntimePermission "setContextClassLoader"; }; grant codeBase "${codebase.netty-transport}" { diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/license/AbstractLicensesIntegrationTestCase.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/license/AbstractLicensesIntegrationTestCase.java index e9c9ba95bfd38..57ba7a0c4674d 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/license/AbstractLicensesIntegrationTestCase.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/license/AbstractLicensesIntegrationTestCase.java @@ -3,6 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + package org.elasticsearch.license; import org.elasticsearch.analysis.common.CommonAnalysisPlugin; @@ -13,16 +14,16 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.xpack.core.LocalStateCompositeXPackPlugin; import org.elasticsearch.xpack.core.XPackClientPlugin; import org.elasticsearch.xpack.core.XPackSettings; +import org.elasticsearch.xpack.core.test.XPackIntegTestCase; import java.util.Arrays; import java.util.Collection; import java.util.concurrent.CountDownLatch; -public abstract class AbstractLicensesIntegrationTestCase extends ESIntegTestCase { +public abstract class AbstractLicensesIntegrationTestCase extends XPackIntegTestCase { @Override protected Settings nodeSettings(int nodeOrdinal) { diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/license/StartBasicLicenseTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/license/StartBasicLicenseTests.java index fc8e25e3ccca9..2b0d60f321c92 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/license/StartBasicLicenseTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/license/StartBasicLicenseTests.java @@ -3,6 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + package org.elasticsearch.license; import org.elasticsearch.client.Response; diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/test/ObjectCleanerThreadThreadFilter.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/test/ObjectCleanerThreadThreadFilter.java new file mode 100644 index 0000000000000..e911920953ac2 --- /dev/null +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/test/ObjectCleanerThreadThreadFilter.java @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +package org.elasticsearch.xpack.core.test; + +import com.carrotsearch.randomizedtesting.ThreadFilter; + +/** + * The Netty object cleaner thread is not closeable and it does not terminate in a timely manner. This means that thread leak control in + * tests will fail test suites when the object cleaner thread has not terminated. Since there is not a reliable way to terminate this + * thread we instead filter it out of thread leak control. + */ +public class ObjectCleanerThreadThreadFilter implements ThreadFilter { + + @Override + public boolean reject(final Thread t) { + // TODO: replace with constant from Netty when https://github.com/netty/netty/pull/8014 is integrated + return "ObjectCleanerThread".equals(t.getName()); + } + +} diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/test/XPackIntegTestCase.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/test/XPackIntegTestCase.java new file mode 100644 index 0000000000000..87cf2d87f02a4 --- /dev/null +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/test/XPackIntegTestCase.java @@ -0,0 +1,14 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +package org.elasticsearch.xpack.core.test; + +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; +import org.elasticsearch.test.ESIntegTestCase; + +@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class}) +public abstract class XPackIntegTestCase extends ESIntegTestCase { +} diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/test/XPackSingleNodeTestCase.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/test/XPackSingleNodeTestCase.java new file mode 100644 index 0000000000000..a3cbd875503f5 --- /dev/null +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/test/XPackSingleNodeTestCase.java @@ -0,0 +1,14 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +package org.elasticsearch.xpack.core.test; + +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; +import org.elasticsearch.test.ESSingleNodeTestCase; + +@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class}) +public abstract class XPackSingleNodeTestCase extends ESSingleNodeTestCase { +} diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java index 7a1ca6a00f46c..29c0ef2516553 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java @@ -27,19 +27,17 @@ import org.elasticsearch.test.MockHttpTransport; import org.elasticsearch.test.discovery.TestZenDiscovery; import org.elasticsearch.xpack.core.XPackSettings; -import org.elasticsearch.xpack.core.ml.action.GetDatafeedsAction; -import org.elasticsearch.xpack.core.ml.action.GetJobsAction; -import org.elasticsearch.xpack.core.ml.action.util.QueryPage; -import org.elasticsearch.xpack.core.ml.client.MachineLearningClient; -import org.elasticsearch.xpack.ml.LocalStateMachineLearning; -import org.elasticsearch.xpack.ml.MachineLearning; import org.elasticsearch.xpack.core.ml.MachineLearningField; import org.elasticsearch.xpack.core.ml.action.CloseJobAction; import org.elasticsearch.xpack.core.ml.action.DeleteDatafeedAction; import org.elasticsearch.xpack.core.ml.action.DeleteJobAction; +import org.elasticsearch.xpack.core.ml.action.GetDatafeedsAction; import org.elasticsearch.xpack.core.ml.action.GetDatafeedsStatsAction; +import org.elasticsearch.xpack.core.ml.action.GetJobsAction; import org.elasticsearch.xpack.core.ml.action.GetJobsStatsAction; import org.elasticsearch.xpack.core.ml.action.StopDatafeedAction; +import org.elasticsearch.xpack.core.ml.action.util.QueryPage; +import org.elasticsearch.xpack.core.ml.client.MachineLearningClient; import org.elasticsearch.xpack.core.ml.datafeed.DatafeedConfig; import org.elasticsearch.xpack.core.ml.datafeed.DatafeedState; import org.elasticsearch.xpack.core.ml.job.config.AnalysisConfig; @@ -49,6 +47,9 @@ import org.elasticsearch.xpack.core.ml.job.config.Job; import org.elasticsearch.xpack.core.ml.job.config.JobState; import org.elasticsearch.xpack.core.ml.job.process.autodetect.state.DataCounts; +import org.elasticsearch.xpack.core.test.XPackIntegTestCase; +import org.elasticsearch.xpack.ml.LocalStateMachineLearning; +import org.elasticsearch.xpack.ml.MachineLearning; import org.junit.After; import org.junit.Before; @@ -69,7 +70,7 @@ */ @ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, numClientNodes = 0, transportClientRatio = 0, supportsDedicatedMasters = false) -public abstract class BaseMlIntegTestCase extends ESIntegTestCase { +public abstract class BaseMlIntegTestCase extends XPackIntegTestCase { @Override protected boolean ignoreExternalCluster() { diff --git a/x-pack/plugin/security/src/main/plugin-metadata/plugin-security.policy b/x-pack/plugin/security/src/main/plugin-metadata/plugin-security.policy index 857c2f6e472d5..f56affec02be0 100644 --- a/x-pack/plugin/security/src/main/plugin-metadata/plugin-security.policy +++ b/x-pack/plugin/security/src/main/plugin-metadata/plugin-security.policy @@ -23,6 +23,8 @@ grant codeBase "${codebase.xmlsec-2.0.8.jar}" { grant codeBase "${codebase.netty-common}" { // for reading the system-wide configuration for the backlog of established sockets permission java.io.FilePermission "/proc/sys/net/core/somaxconn", "read"; + + permission java.lang.RuntimePermission "setContextClassLoader"; }; grant codeBase "${codebase.netty-transport}" { diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/test/SecurityIntegTestCase.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/test/SecurityIntegTestCase.java index 815f26942767a..20e2f904323dc 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/test/SecurityIntegTestCase.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/test/SecurityIntegTestCase.java @@ -3,6 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + package org.elasticsearch.test; import io.netty.util.ThreadDeathWatcher; @@ -41,8 +42,8 @@ import org.elasticsearch.xpack.core.security.SecurityField; import org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken; import org.elasticsearch.xpack.core.security.client.SecurityClient; +import org.elasticsearch.xpack.core.test.XPackIntegTestCase; import org.elasticsearch.xpack.security.LocalStateSecurity; - import org.elasticsearch.xpack.security.support.SecurityIndexManager; import org.junit.AfterClass; import org.junit.Before; @@ -75,7 +76,7 @@ * * @see SecuritySettingsSource */ -public abstract class SecurityIntegTestCase extends ESIntegTestCase { +public abstract class SecurityIntegTestCase extends XPackIntegTestCase { private static SecuritySettingsSource SECURITY_DEFAULT_SETTINGS; protected static SecureString BOOTSTRAP_PASSWORD = null; diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/test/SecuritySingleNodeTestCase.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/test/SecuritySingleNodeTestCase.java index cda627806e7b5..1c6f8e847d39c 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/test/SecuritySingleNodeTestCase.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/test/SecuritySingleNodeTestCase.java @@ -3,6 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + package org.elasticsearch.test; import io.netty.util.ThreadDeathWatcher; @@ -22,6 +23,7 @@ import org.elasticsearch.license.LicenseService; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.PluginInfo; +import org.elasticsearch.xpack.core.test.XPackSingleNodeTestCase; import org.elasticsearch.xpack.security.LocalStateSecurity; import org.junit.AfterClass; import org.junit.Before; @@ -49,7 +51,7 @@ * {@link SecurityIntegTestCase} due to simplicity and improved speed from not needing to start * multiple nodes and wait for the cluster to form. */ -public abstract class SecuritySingleNodeTestCase extends ESSingleNodeTestCase { +public abstract class SecuritySingleNodeTestCase extends XPackSingleNodeTestCase { private static SecuritySettingsSource SECURITY_DEFAULT_SETTINGS = null; private static CustomSecuritySettingsSource customSecuritySettingsSource = null; diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java index 3461c530b4417..5926701ad0490 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java @@ -31,7 +31,6 @@ import org.elasticsearch.script.Script; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.builder.SearchSourceBuilder; -import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.InternalTestCluster; import org.elasticsearch.test.disruption.ServiceDisruptionScheme; @@ -40,6 +39,7 @@ import org.elasticsearch.xpack.core.XPackClient; import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.security.SecurityField; +import org.elasticsearch.xpack.core.test.XPackIntegTestCase; import org.elasticsearch.xpack.core.watcher.WatcherState; import org.elasticsearch.xpack.core.watcher.client.WatcherClient; import org.elasticsearch.xpack.core.watcher.execution.ExecutionState; @@ -94,7 +94,7 @@ import static org.hamcrest.core.IsNot.not; @ClusterScope(scope = SUITE, numClientNodes = 0, transportClientRatio = 0, maxNumDataNodes = 3) -public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase { +public abstract class AbstractWatcherIntegrationTestCase extends XPackIntegTestCase { public static final String WATCHER_LANG = Script.DEFAULT_SCRIPT_LANG; diff --git a/x-pack/qa/audit-tests/src/test/java/org/elasticsearch/xpack/security/audit/IndexAuditIT.java b/x-pack/qa/audit-tests/src/test/java/org/elasticsearch/xpack/security/audit/IndexAuditIT.java index 3467316c24f6c..26a98691f1323 100644 --- a/x-pack/qa/audit-tests/src/test/java/org/elasticsearch/xpack/security/audit/IndexAuditIT.java +++ b/x-pack/qa/audit-tests/src/test/java/org/elasticsearch/xpack/security/audit/IndexAuditIT.java @@ -6,6 +6,7 @@ package org.elasticsearch.xpack.security.audit; import com.carrotsearch.hppc.cursors.ObjectCursor; +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; import org.apache.http.message.BasicHeader; import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateResponse; import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; @@ -24,8 +25,9 @@ import org.elasticsearch.test.TestCluster; import org.elasticsearch.xpack.core.XPackClientPlugin; import org.elasticsearch.xpack.core.security.SecurityField; -import org.elasticsearch.xpack.security.audit.index.IndexAuditTrail; import org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken; +import org.elasticsearch.xpack.core.test.ObjectCleanerThreadThreadFilter; +import org.elasticsearch.xpack.security.audit.index.IndexAuditTrail; import java.io.IOException; import java.net.InetSocketAddress; @@ -38,6 +40,7 @@ import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.is; +@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class}) public class IndexAuditIT extends ESIntegTestCase { private static final String USER = "test_user"; private static final String PASS = "x-pack-test-password"; diff --git a/x-pack/qa/ml-native-tests/src/test/java/org/elasticsearch/xpack/ml/integration/MlNativeAutodetectIntegTestCase.java b/x-pack/qa/ml-native-tests/src/test/java/org/elasticsearch/xpack/ml/integration/MlNativeAutodetectIntegTestCase.java index f70efc72506d3..a744f3ebb6380 100644 --- a/x-pack/qa/ml-native-tests/src/test/java/org/elasticsearch/xpack/ml/integration/MlNativeAutodetectIntegTestCase.java +++ b/x-pack/qa/ml-native-tests/src/test/java/org/elasticsearch/xpack/ml/integration/MlNativeAutodetectIntegTestCase.java @@ -5,6 +5,7 @@ */ package org.elasticsearch.xpack.ml.integration; +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.client.Client; @@ -34,6 +35,7 @@ import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.tasks.Task; import org.elasticsearch.test.ESIntegTestCase; +import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.transport.Netty4Plugin; import org.elasticsearch.xpack.core.LocalStateCompositeXPackPlugin; @@ -84,6 +86,7 @@ import org.elasticsearch.xpack.core.ml.job.results.Result; import org.elasticsearch.xpack.core.security.SecurityField; import org.elasticsearch.xpack.core.security.authc.TokenMetaData; +import org.elasticsearch.xpack.core.test.ObjectCleanerThreadThreadFilter; import java.io.IOException; import java.net.URISyntaxException; @@ -107,6 +110,7 @@ /** * Base class of ML integration tests that use a native autodetect process */ +@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class}) abstract class MlNativeAutodetectIntegTestCase extends ESIntegTestCase { private List jobs = new ArrayList<>(); diff --git a/x-pack/qa/security-client-tests/build.gradle b/x-pack/qa/security-client-tests/build.gradle index 4e517f4d3633e..9706d554e95c9 100644 --- a/x-pack/qa/security-client-tests/build.gradle +++ b/x-pack/qa/security-client-tests/build.gradle @@ -3,6 +3,7 @@ apply plugin: 'elasticsearch.rest-test' dependencies { testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') testCompile project(path: xpackProject('transport-client').path, configuration: 'runtime') } diff --git a/x-pack/qa/security-client-tests/src/test/java/org/elasticsearch/xpack/security/qa/SecurityTransportClientIT.java b/x-pack/qa/security-client-tests/src/test/java/org/elasticsearch/xpack/security/qa/SecurityTransportClientIT.java index 519f365d515a0..5342c2bd78095 100644 --- a/x-pack/qa/security-client-tests/src/test/java/org/elasticsearch/xpack/security/qa/SecurityTransportClientIT.java +++ b/x-pack/qa/security-client-tests/src/test/java/org/elasticsearch/xpack/security/qa/SecurityTransportClientIT.java @@ -5,6 +5,7 @@ */ package org.elasticsearch.xpack.security.qa; +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; import org.elasticsearch.ElasticsearchSecurityException; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; @@ -15,10 +16,11 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.test.ESIntegTestCase; -import org.elasticsearch.xpack.core.XPackClientPlugin; import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient; +import org.elasticsearch.xpack.core.XPackClientPlugin; import org.elasticsearch.xpack.core.security.SecurityField; +import org.elasticsearch.xpack.core.test.ObjectCleanerThreadThreadFilter; +import org.elasticsearch.xpack.core.test.XPackIntegTestCase; import java.util.Collection; import java.util.Collections; @@ -32,7 +34,9 @@ /** * Integration tests that test a transport client with security being loaded that connect to an external cluster */ -public class SecurityTransportClientIT extends ESIntegTestCase { +@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class}) +public class SecurityTransportClientIT extends XPackIntegTestCase { + static final String ADMIN_USER_PW = "test_user:x-pack-test-password"; static final String TRANSPORT_USER_PW = "transport:x-pack-test-password"; diff --git a/x-pack/qa/security-example-spi-extension/build.gradle b/x-pack/qa/security-example-spi-extension/build.gradle index b2fac075cb315..94a7bccca8034 100644 --- a/x-pack/qa/security-example-spi-extension/build.gradle +++ b/x-pack/qa/security-example-spi-extension/build.gradle @@ -9,6 +9,7 @@ esplugin { dependencies { compileOnly project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') testCompile project(path: xpackProject('transport-client').path, configuration: 'runtime') } diff --git a/x-pack/qa/security-example-spi-extension/src/test/java/org/elasticsearch/example/realm/CustomRealmIT.java b/x-pack/qa/security-example-spi-extension/src/test/java/org/elasticsearch/example/realm/CustomRealmIT.java index 65ec595a0d409..8f8f45f0448b6 100644 --- a/x-pack/qa/security-example-spi-extension/src/test/java/org/elasticsearch/example/realm/CustomRealmIT.java +++ b/x-pack/qa/security-example-spi-extension/src/test/java/org/elasticsearch/example/realm/CustomRealmIT.java @@ -3,6 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + package org.elasticsearch.example.realm; import org.apache.http.message.BasicHeader; @@ -19,9 +20,9 @@ import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.env.Environment; import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient; import org.elasticsearch.xpack.core.XPackClientPlugin; +import org.elasticsearch.xpack.core.test.XPackIntegTestCase; import java.util.Collection; import java.util.Collections; @@ -32,7 +33,7 @@ /** * Integration test to test authentication with the custom realm */ -public class CustomRealmIT extends ESIntegTestCase { +public class CustomRealmIT extends XPackIntegTestCase { @Override protected Settings externalClusterClientSettings() { diff --git a/x-pack/qa/security-example-spi-extension/src/test/java/org/elasticsearch/example/role/CustomRolesProviderIT.java b/x-pack/qa/security-example-spi-extension/src/test/java/org/elasticsearch/example/role/CustomRolesProviderIT.java index 4e1fb72256086..85b34a9612f46 100644 --- a/x-pack/qa/security-example-spi-extension/src/test/java/org/elasticsearch/example/role/CustomRolesProviderIT.java +++ b/x-pack/qa/security-example-spi-extension/src/test/java/org/elasticsearch/example/role/CustomRolesProviderIT.java @@ -18,6 +18,7 @@ import org.elasticsearch.xpack.core.XPackClientPlugin; import org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken; import org.elasticsearch.xpack.core.security.client.SecurityClient; +import org.elasticsearch.xpack.core.test.XPackIntegTestCase; import java.util.Collection; import java.util.Collections; @@ -31,7 +32,7 @@ /** * Integration test for custom roles providers. */ -public class CustomRolesProviderIT extends ESIntegTestCase { +public class CustomRolesProviderIT extends XPackIntegTestCase { private static final String TEST_USER = "test_user"; private static final String TEST_PWD = "change_me"; diff --git a/x-pack/qa/security-migrate-tests/build.gradle b/x-pack/qa/security-migrate-tests/build.gradle index 7ccf6d2349b8b..de6f1c86b993f 100644 --- a/x-pack/qa/security-migrate-tests/build.gradle +++ b/x-pack/qa/security-migrate-tests/build.gradle @@ -3,6 +3,7 @@ apply plugin: 'elasticsearch.rest-test' dependencies { testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') testCompile project(path: xpackModule('security'), configuration: 'runtime') testCompile project(path: xpackProject('transport-client').path, configuration: 'runtime') } diff --git a/x-pack/qa/security-migrate-tests/src/test/java/org/elasticsearch/xpack/security/MigrateToolTestCase.java b/x-pack/qa/security-migrate-tests/src/test/java/org/elasticsearch/xpack/security/MigrateToolTestCase.java index 2987c1afc8daf..e7f3a5ef48061 100644 --- a/x-pack/qa/security-migrate-tests/src/test/java/org/elasticsearch/xpack/security/MigrateToolTestCase.java +++ b/x-pack/qa/security-migrate-tests/src/test/java/org/elasticsearch/xpack/security/MigrateToolTestCase.java @@ -5,6 +5,7 @@ */ package org.elasticsearch.xpack.security; +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; import org.apache.logging.log4j.Logger; import org.apache.lucene.util.LuceneTestCase; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; @@ -13,8 +14,10 @@ import org.elasticsearch.common.logging.ESLoggerFactory; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; +import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient; import org.elasticsearch.xpack.core.security.SecurityField; +import org.elasticsearch.xpack.core.test.ObjectCleanerThreadThreadFilter; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -40,6 +43,7 @@ * then run JUnit. If you changed the default port, set "tests.cluster=localhost:PORT" when running * your test. */ +@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class}) @LuceneTestCase.SuppressSysoutChecks(bugUrl = "we log a lot on purpose") public abstract class MigrateToolTestCase extends LuceneTestCase { diff --git a/x-pack/qa/smoke-test-plugins-ssl/build.gradle b/x-pack/qa/smoke-test-plugins-ssl/build.gradle index 595c562af3707..7c1f7a8d0e558 100644 --- a/x-pack/qa/smoke-test-plugins-ssl/build.gradle +++ b/x-pack/qa/smoke-test-plugins-ssl/build.gradle @@ -16,6 +16,7 @@ apply plugin: 'elasticsearch.rest-test' dependencies { testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') } String outputDir = "${buildDir}/generated-resources/${project.name}" diff --git a/x-pack/qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestMonitoringWithSecurityIT.java b/x-pack/qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestMonitoringWithSecurityIT.java index f8d1dd5e2b717..02c2faad2b085 100644 --- a/x-pack/qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestMonitoringWithSecurityIT.java +++ b/x-pack/qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestMonitoringWithSecurityIT.java @@ -17,6 +17,7 @@ import org.elasticsearch.xpack.core.action.XPackUsageResponse; import org.elasticsearch.xpack.core.monitoring.MonitoringFeatureSetUsage; import org.elasticsearch.xpack.core.security.SecurityField; +import org.elasticsearch.xpack.core.test.XPackIntegTestCase; import org.junit.After; import org.junit.Before; @@ -41,7 +42,7 @@ * then uses a transport client to check that the data have been correctly received and * indexed in the cluster. */ -public class SmokeTestMonitoringWithSecurityIT extends ESIntegTestCase { +public class SmokeTestMonitoringWithSecurityIT extends XPackIntegTestCase { private static final String USER = "test_user"; private static final String PASS = "x-pack-test-password"; private static final String MONITORING_PATTERN = ".monitoring-*"; diff --git a/x-pack/qa/transport-client-tests/build.gradle b/x-pack/qa/transport-client-tests/build.gradle index c864a9084cba8..d179fee378c63 100644 --- a/x-pack/qa/transport-client-tests/build.gradle +++ b/x-pack/qa/transport-client-tests/build.gradle @@ -3,6 +3,7 @@ apply plugin: 'elasticsearch.rest-test' dependencies { testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') testCompile project(path: xpackProject('transport-client').path, configuration: 'runtime') } diff --git a/x-pack/qa/transport-client-tests/src/test/java/org/elasticsearch/xpack/ml/client/ESXPackSmokeClientTestCase.java b/x-pack/qa/transport-client-tests/src/test/java/org/elasticsearch/xpack/ml/client/ESXPackSmokeClientTestCase.java index c77715431ec5e..4eb845ec9e90e 100644 --- a/x-pack/qa/transport-client-tests/src/test/java/org/elasticsearch/xpack/ml/client/ESXPackSmokeClientTestCase.java +++ b/x-pack/qa/transport-client-tests/src/test/java/org/elasticsearch/xpack/ml/client/ESXPackSmokeClientTestCase.java @@ -5,6 +5,7 @@ */ package org.elasticsearch.xpack.ml.client; +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; import org.apache.logging.log4j.Logger; import org.apache.lucene.util.LuceneTestCase; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; @@ -15,6 +16,7 @@ import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.env.Environment; import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient; +import org.elasticsearch.xpack.core.test.ObjectCleanerThreadThreadFilter; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -46,6 +48,7 @@ * test. */ @LuceneTestCase.SuppressSysoutChecks(bugUrl = "we log a lot on purpose") +@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class}) public abstract class ESXPackSmokeClientTestCase extends LuceneTestCase { /**