diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalTestClustersPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalTestClustersPlugin.java index f1b96016286df..2a2e1ea28d1ec 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalTestClustersPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalTestClustersPlugin.java @@ -34,12 +34,13 @@ public void apply(Project project) { || buildParams.getBwcVersions().unreleasedInfo(version) == null ); - if (shouldConfigureTestClustersWithOneProcessor()) { - NamedDomainObjectContainer testClusters = (NamedDomainObjectContainer) project - .getExtensions() - .getByName(TestClustersPlugin.EXTENSION_NAME); - testClusters.configureEach(elasticsearchCluster -> elasticsearchCluster.setting("node.processors", "1")); - } + NamedDomainObjectContainer testClusters = (NamedDomainObjectContainer) project + .getExtensions() + .getByName(TestClustersPlugin.EXTENSION_NAME); + // Limit the number of allocated processors for all nodes to 2 in the cluster by default. + // This is to ensure that the tests run consistently across different environments. + String processorCount = shouldConfigureTestClustersWithOneProcessor() ? "1" : "2"; + testClusters.configureEach(elasticsearchCluster -> elasticsearchCluster.setting("node.processors", processorCount)); } private boolean shouldConfigureTestClustersWithOneProcessor() { diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultSettingsProvider.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultSettingsProvider.java index b53f4ece46134..2fdf0df41736a 100644 --- a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultSettingsProvider.java +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultSettingsProvider.java @@ -42,6 +42,10 @@ public Map get(LocalNodeSpec nodeSpec) { } } + // Limit the number of allocated processors for all nodes in the cluster by default. + // This is to ensure that the tests run consistently across different environments. + settings.put("node.processors", "2"); + // Default the watermarks to absurdly low to prevent the tests from failing on nodes without enough disk space settings.put("cluster.routing.allocation.disk.watermark.low", "1b"); settings.put("cluster.routing.allocation.disk.watermark.high", "1b");