Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

import org.elasticsearch.gradle.VersionProperties;
import org.elasticsearch.gradle.internal.info.GlobalBuildInfoPlugin;
import org.elasticsearch.gradle.testclusters.ElasticsearchCluster;
import org.elasticsearch.gradle.testclusters.TestClustersPlugin;
import org.gradle.api.NamedDomainObjectContainer;
import org.gradle.api.Plugin;
import org.gradle.api.Project;

Expand All @@ -33,17 +31,5 @@ public void apply(Project project) {
version -> (version.equals(VersionProperties.getElasticsearchVersion()) && buildParams.getSnapshotBuild() == false)
|| buildParams.getBwcVersions().unreleasedInfo(version) == null
);

NamedDomainObjectContainer<ElasticsearchCluster> testClusters = (NamedDomainObjectContainer<ElasticsearchCluster>) 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() {
return Boolean.parseBoolean(System.getProperty("tests.configure_test_clusters_with_one_processor", "false"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,15 @@ private void createConfiguration() {
baseConfig.put("cluster.service.slow_master_task_logging_threshold", "5s");
}

// 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.
String processorCount = shouldConfigureTestClustersWithOneProcessor() ? "1" : "2";
if (getVersion().onOrAfter("7.6.0")) {
baseConfig.put("node.processors", processorCount);
} else {
baseConfig.put("processors", processorCount);
}

baseConfig.put("action.destructive_requires_name", "false");

HashSet<String> overriden = new HashSet<>(baseConfig.keySet());
Expand Down Expand Up @@ -1791,4 +1800,8 @@ private static class LinkCreationException extends UncheckedIOException {
super(message, cause);
}
}

private boolean shouldConfigureTestClustersWithOneProcessor() {
return Boolean.parseBoolean(System.getProperty("tests.configure_test_clusters_with_one_processor", "false"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ public Map<String, String> 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");
if (nodeSpec.getVersion().onOrAfter("7.6.0")) {
settings.put("node.processors", "2");
} else {
settings.put("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");
Expand Down