Skip to content

Commit 56f5055

Browse files
committed
Set default processor allocation for test clusters (#133204)
Setting the number of processors available for node to adequately size thread pools. Related to #130612
1 parent c485424 commit 56f5055

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalTestClustersPlugin.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ public void apply(Project project) {
3434
|| buildParams.getBwcVersions().unreleasedInfo(version) == null
3535
);
3636

37-
if (shouldConfigureTestClustersWithOneProcessor()) {
38-
NamedDomainObjectContainer<ElasticsearchCluster> testClusters = (NamedDomainObjectContainer<ElasticsearchCluster>) project
39-
.getExtensions()
40-
.getByName(TestClustersPlugin.EXTENSION_NAME);
41-
testClusters.configureEach(elasticsearchCluster -> elasticsearchCluster.setting("node.processors", "1"));
42-
}
37+
NamedDomainObjectContainer<ElasticsearchCluster> testClusters = (NamedDomainObjectContainer<ElasticsearchCluster>) project
38+
.getExtensions()
39+
.getByName(TestClustersPlugin.EXTENSION_NAME);
40+
// Limit the number of allocated processors for all nodes to 2 in the cluster by default.
41+
// This is to ensure that the tests run consistently across different environments.
42+
String processorCount = shouldConfigureTestClustersWithOneProcessor() ? "1" : "2";
43+
testClusters.configureEach(elasticsearchCluster -> elasticsearchCluster.setting("node.processors", processorCount));
4344
}
4445

4546
private boolean shouldConfigureTestClustersWithOneProcessor() {

test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultSettingsProvider.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ public Map<String, String> get(LocalNodeSpec nodeSpec) {
4242
}
4343
}
4444

45+
// Limit the number of allocated processors for all nodes in the cluster by default.
46+
// This is to ensure that the tests run consistently across different environments.
47+
settings.put("node.processors", "2");
48+
4549
// Default the watermarks to absurdly low to prevent the tests from failing on nodes without enough disk space
4650
settings.put("cluster.routing.allocation.disk.watermark.low", "1b");
4751
settings.put("cluster.routing.allocation.disk.watermark.high", "1b");

0 commit comments

Comments
 (0)