From da19bbf4f770731d24efb6c6c7ce70ac4101a0ec Mon Sep 17 00:00:00 2001 From: Mark Vieira Date: Tue, 27 Jul 2021 11:21:42 -0700 Subject: [PATCH] Set netty available processors system property for tests globally (#75699) (cherry picked from commit 9d14bc91d779eabb79869ca69ba8b4b1e1e145ce) --- modules/reindex/build.gradle | 9 --------- modules/transport-netty4/build.gradle | 19 ------------------- qa/smoke-test-http/build.gradle | 8 -------- .../org/elasticsearch/test/ESTestCase.java | 4 ++++ x-pack/plugin/build.gradle | 6 ------ x-pack/plugin/core/build.gradle | 8 -------- x-pack/plugin/data-streams/build.gradle | 8 -------- x-pack/plugin/identity-provider/build.gradle | 12 ------------ .../qa/native-multi-node-tests/build.gradle | 5 ----- x-pack/plugin/security/build.gradle | 14 -------------- x-pack/plugin/watcher/build.gradle | 8 -------- .../third-party/active-directory/build.gradle | 5 ----- 12 files changed, 4 insertions(+), 102 deletions(-) diff --git a/modules/reindex/build.gradle b/modules/reindex/build.gradle index e4f91434783d3..3e80da427858b 100644 --- a/modules/reindex/build.gradle +++ b/modules/reindex/build.gradle @@ -32,15 +32,6 @@ testClusters.all { setting 'reindex.remote.whitelist', '127.0.0.1:*' } -tasks.named("test").configure { - /* - * We have to disable setting the number of available processors as tests in the - * same JVM randomize processors and will step on each other if we allow them to - * set the number of available processors as it's set-once in Netty. - */ - systemProperty 'es.set.netty.runtime.available.processors', 'false' -} - dependencies { api project(":client:rest") api project(":libs:elasticsearch-ssl-config") diff --git a/modules/transport-netty4/build.gradle b/modules/transport-netty4/build.gradle index 8d6f9340ee541..e6dc2d6b05683 100644 --- a/modules/transport-netty4/build.gradle +++ b/modules/transport-netty4/build.gradle @@ -49,31 +49,13 @@ tasks.named("dependencyLicenses").configure { mapping from: /netty-.*/, to: 'netty' } -tasks.named("test").configure { - /* - * We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each - * other if we allow them to set the number of available processors as it's set-once in Netty. - */ - systemProperty 'es.set.netty.runtime.available.processors', 'false' -} - -tasks.named("internalClusterTest").configure { - systemProperty 'es.set.netty.runtime.available.processors', 'false' -} - -tasks.named("javaRestTest").configure { - systemProperty 'es.set.netty.runtime.available.processors', 'false' -} - TaskProvider pooledTest = tasks.register("pooledTest", Test) { include '**/*Tests.class' - systemProperty 'es.set.netty.runtime.available.processors', 'false' systemProperty 'es.use_unpooled_allocator', 'false' } TaskProvider pooledInternalClusterTest = tasks.register("pooledInternalClusterTest", Test) { include '**/*IT.class' - systemProperty 'es.set.netty.runtime.available.processors', 'false' systemProperty 'es.use_unpooled_allocator', 'false' SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); SourceSet internalTestSourceSet = sourceSets.getByName(InternalClusterTestPlugin.SOURCE_SET_NAME) @@ -82,7 +64,6 @@ TaskProvider pooledInternalClusterTest = tasks.register("pooledInternalClu } TaskProvider pooledJavaRestTest = tasks.register("pooledJavaRestTest", RestIntegTestTask) { - systemProperty 'es.set.netty.runtime.available.processors', 'false' SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); SourceSet javaRestTestSourceSet = sourceSets.getByName(JavaRestTestPlugin.SOURCE_SET_NAME) setTestClassesDirs(javaRestTestSourceSet.getOutput().getClassesDirs()) diff --git a/qa/smoke-test-http/build.gradle b/qa/smoke-test-http/build.gradle index 55aa1e0cc8ff2..b7bc1fafe23aa 100644 --- a/qa/smoke-test-http/build.gradle +++ b/qa/smoke-test-http/build.gradle @@ -19,11 +19,3 @@ dependencies { testClusters.all { setting 'xpack.security.enabled', 'false' } - -tasks.named("integTest").configure { - /* - * We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each - * other if we allow them to set the number of available processors as it's set-once in Netty. - */ - systemProperty 'es.set.netty.runtime.available.processors', 'false' -} diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java index 32695f9184578..fd5bd31a586c1 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java @@ -249,6 +249,10 @@ private static void setTestSysProps() { // Enable Netty leak detection and monitor logger for logged leak errors System.setProperty("io.netty.leakDetection.level", "paranoid"); + + // We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each + // other if we allow them to set the number of available processors as it's set-once in Netty. + System.setProperty("es.set.netty.runtime.available.processors", "false"); } protected final Logger logger = LogManager.getLogger(getClass()); diff --git a/x-pack/plugin/build.gradle b/x-pack/plugin/build.gradle index 9ee4f1cd4a771..3f9ad93ff6cdc 100644 --- a/x-pack/plugin/build.gradle +++ b/x-pack/plugin/build.gradle @@ -114,12 +114,6 @@ tasks.named("processYamlRestTestResources").configure { } tasks.named("yamlRestTest").configure { - /* - * We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each - * other if we allow them to set the number of available processors as it's set-once in Netty. - */ - systemProperty 'es.set.netty.runtime.available.processors', 'false' - // TODO: fix this rest test to not depend on a hardcoded port! def blacklist = ['getting_started/10_monitor_cluster_health/*'] if (BuildParams.isSnapshotBuild() == false) { diff --git a/x-pack/plugin/core/build.gradle b/x-pack/plugin/core/build.gradle index b36aa8321e9b3..2de92a8804d1d 100644 --- a/x-pack/plugin/core/build.gradle +++ b/x-pack/plugin/core/build.gradle @@ -112,14 +112,6 @@ sourceSets.test.resources { srcDir 'src/main/config' } -tasks.named("test").configure { - /* - * We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each - * other if we allow them to set the number of available processors as it's set-once in Netty. - */ - systemProperty 'es.set.netty.runtime.available.processors', 'false' -} - // TODO: don't publish test artifacts just to run messy tests, fix the tests! // https://github.com/elastic/x-plugins/issues/724 diff --git a/x-pack/plugin/data-streams/build.gradle b/x-pack/plugin/data-streams/build.gradle index 06dc0b9cdcae5..b1ceab4f4bdea 100644 --- a/x-pack/plugin/data-streams/build.gradle +++ b/x-pack/plugin/data-streams/build.gradle @@ -16,11 +16,3 @@ dependencies { } addQaCheckDependencies() - -tasks.named("internalClusterTest").configure { - /* - * We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each - * other if we allow them to set the number of available processors as it's set-once in Netty. - */ - systemProperty 'es.set.netty.runtime.available.processors', 'false' -} diff --git a/x-pack/plugin/identity-provider/build.gradle b/x-pack/plugin/identity-provider/build.gradle index cf4ebea8df891..1e2e662018cd6 100644 --- a/x-pack/plugin/identity-provider/build.gradle +++ b/x-pack/plugin/identity-provider/build.gradle @@ -343,18 +343,6 @@ if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_1_8) { } -tasks.named("test").configure { - /* - * We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each - * other if we allow them to set the number of available processors as it's set-once in Netty. - */ - systemProperty 'es.set.netty.runtime.available.processors', 'false' -} - -tasks.named("internalClusterTest").configure { - systemProperty 'es.set.netty.runtime.available.processors', 'false' -} - addQaCheckDependencies() if (BuildParams.inFipsJvm) { diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/build.gradle b/x-pack/plugin/ml/qa/native-multi-node-tests/build.gradle index 0dacea41f6ae6..fc466e62c1546 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/build.gradle +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/build.gradle @@ -26,11 +26,6 @@ tasks.named("processJavaRestTestResources").configure { dependsOn("copyKeyCerts" tasks.named("javaRestTest").configure { dependsOn "copyKeyCerts" - /* - * We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each - * other if we allow them to set the number of available processors as it's set-once in Netty. - */ - systemProperty 'es.set.netty.runtime.available.processors', 'false' } testClusters.all { diff --git a/x-pack/plugin/security/build.gradle b/x-pack/plugin/security/build.gradle index eb832f8f7c237..b03710f9d4d3e 100644 --- a/x-pack/plugin/security/build.gradle +++ b/x-pack/plugin/security/build.gradle @@ -470,21 +470,7 @@ tasks.named("thirdPartyAudit").configure { } -tasks.named("test").configure { - /* - * We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each - * other if we allow them to set the number of available processors as it's set-once in Netty. - */ - systemProperty 'es.set.netty.runtime.available.processors', 'false' -} - tasks.named("internalClusterTest").configure { - /* - * We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each - * other if we allow them to set the number of available processors as it's set-once in Netty. - */ - systemProperty 'es.set.netty.runtime.available.processors', 'false' - /* * Some tests in this module set up a lot of transport threads so we reduce the buffer size per transport thread from the 1M default * to keep direct memory usage under control. diff --git a/x-pack/plugin/watcher/build.gradle b/x-pack/plugin/watcher/build.gradle index c95369b87dc5b..201980139a284 100644 --- a/x-pack/plugin/watcher/build.gradle +++ b/x-pack/plugin/watcher/build.gradle @@ -124,12 +124,4 @@ if (BuildParams.runtimeJavaVersion <= JavaVersion.VERSION_1_8) { } } -tasks.named("internalClusterTest").configure { - /* - * We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each - * other if we allow them to set the number of available processors as it's set-once in Netty. - */ - systemProperty 'es.set.netty.runtime.available.processors', 'false' -} - addQaCheckDependencies() diff --git a/x-pack/qa/third-party/active-directory/build.gradle b/x-pack/qa/third-party/active-directory/build.gradle index bb63be7a90c28..7f6f5d832d89d 100644 --- a/x-pack/qa/third-party/active-directory/build.gradle +++ b/x-pack/qa/third-party/active-directory/build.gradle @@ -22,11 +22,6 @@ tasks.named("forbiddenPatterns").configure { } tasks.named("test").configure { - /* - * We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each - * other if we allow them to set the number of available processors as it's set-once in Netty. - */ - systemProperty 'es.set.netty.runtime.available.processors', 'false' include '**/*IT.class' include '**/*Tests.class' }