Skip to content

Commit cbea639

Browse files
authored
Add the ability to run REST integration tests with 1 allocated processor (elastic#89234)
This commit adds a new system property `tests.configure_test_clusters_with_one_processor` that configures REST integration tests to run with 1 allocated processor, this should help finding possible deadlocks (if any) when the Elasticsearch nodes have `node.processors` set to 1.
1 parent f849847 commit cbea639

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
import org.elasticsearch.gradle.VersionProperties;
1212
import org.elasticsearch.gradle.internal.info.BuildParams;
13+
import org.elasticsearch.gradle.testclusters.ElasticsearchCluster;
1314
import org.elasticsearch.gradle.testclusters.TestClustersPlugin;
15+
import org.gradle.api.NamedDomainObjectContainer;
1416
import org.gradle.api.Plugin;
1517
import org.gradle.api.Project;
1618
import org.gradle.api.provider.ProviderFactory;
@@ -36,6 +38,16 @@ public void apply(Project project) {
3638
version -> (version.equals(VersionProperties.getElasticsearchVersion()) && BuildParams.isSnapshotBuild() == false)
3739
|| BuildParams.getBwcVersions().unreleasedInfo(version) == null
3840
);
41+
42+
if (shouldConfigureTestClustersWithOneProcessor()) {
43+
NamedDomainObjectContainer<ElasticsearchCluster> testClusters = (NamedDomainObjectContainer<ElasticsearchCluster>) project
44+
.getExtensions()
45+
.getByName(TestClustersPlugin.EXTENSION_NAME);
46+
testClusters.configureEach(elasticsearchCluster -> elasticsearchCluster.setting("node.processors", "1"));
47+
}
3948
}
4049

50+
private boolean shouldConfigureTestClustersWithOneProcessor() {
51+
return Boolean.parseBoolean(System.getProperty("tests.configure_test_clusters_with_one_processor", "false"));
52+
}
4153
}

test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ private static Settings getRandomNodeSettings(long seed) {
524524

525525
builder.put(
526526
EsExecutors.NODE_PROCESSORS_SETTING.getKey(),
527-
1 + random.nextInt(Math.min(4, Runtime.getRuntime().availableProcessors()))
527+
RandomNumbers.randomIntBetween(random, 1, Math.min(4, Runtime.getRuntime().availableProcessors()))
528528
);
529529
if (random.nextBoolean()) {
530530
if (random.nextBoolean()) {

0 commit comments

Comments
 (0)