Skip to content

Commit 6ac0cb1

Browse files
author
Andrey Ershov
committed
Merge branch master into zen2
2 types of conflicts during the merge: 1) Line length fix 2) Classes no longer extend AbstractComponent
2 parents 8939a78 + bdf632b commit 6ac0cb1

File tree

669 files changed

+17449
-5877
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

669 files changed

+17449
-5877
lines changed

TESTING.asciidoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ Default value provided below in [brackets].
150150

151151
=== Load balancing and caches.
152152

153-
By default the tests run on up to 4 JVMs based on the number of cores. If you
154-
want to explicitly specify the number of JVMs you can do so on the command
153+
By default the tests run on multiple processes using all the available cores on all
154+
available CPUs. Not including hyper-threading.
155+
If you want to explicitly specify the number of JVMs you can do so on the command
155156
line:
156157

157158
----------------------------

build.gradle

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ import org.elasticsearch.gradle.VersionCollection
2525
import org.elasticsearch.gradle.VersionProperties
2626
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
2727
import org.gradle.plugins.ide.eclipse.model.SourceFolder
28+
import com.carrotsearch.gradle.junit4.RandomizedTestingTask
29+
30+
import java.util.function.Predicate
2831

2932
plugins {
3033
id 'com.gradle.build-scan' version '1.13.2'
@@ -622,3 +625,19 @@ allprojects {
622625
}
623626
}
624627
}
628+
629+
allprojects {
630+
task checkPart1
631+
task checkPart2
632+
tasks.matching { it.name == "check" }.all { check ->
633+
if (check.path.startsWith(":x-pack:")) {
634+
checkPart2.dependsOn check
635+
} else {
636+
checkPart1.dependsOn check
637+
}
638+
}
639+
}
640+
641+
642+
643+

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,9 +773,32 @@ class BuildPlugin implements Plugin<Project> {
773773
}
774774

775775
static void applyCommonTestConfig(Project project) {
776+
String defaultParallel = 'auto'
777+
// Count physical cores on any Linux distro ( don't count hyper-threading )
778+
if (project.file("/proc/cpuinfo").exists()) {
779+
Map<String, Integer> socketToCore = [:]
780+
String currentID = ""
781+
project.file("/proc/cpuinfo").readLines().forEach({ line ->
782+
if (line.contains(":")) {
783+
List<String> parts = line.split(":", 2).collect({it.trim()})
784+
String name = parts[0], value = parts[1]
785+
// the ID of the CPU socket
786+
if (name == "physical id") {
787+
currentID = value
788+
}
789+
// Number of cores not including hyper-threading
790+
if (name == "cpu cores") {
791+
assert currentID.isEmpty() == false
792+
socketToCore[currentID] = Integer.valueOf(value)
793+
currentID = ""
794+
}
795+
}
796+
})
797+
defaultParallel = socketToCore.values().sum().toString();
798+
}
776799
project.tasks.withType(RandomizedTestingTask) {
777800
jvm "${project.runtimeJavaHome}/bin/java"
778-
parallelism System.getProperty('tests.jvms', 'auto')
801+
parallelism System.getProperty('tests.jvms', defaultParallel)
779802
ifNoTests System.getProperty('tests.ifNoTests', 'fail')
780803
onNonEmptyWorkDirectory 'wipe'
781804
leaveTemporary true

buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/LicenseHeadersTask.groovy

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ import org.apache.rat.license.SimpleLicenseFamily
2424
import org.elasticsearch.gradle.AntTask
2525
import org.gradle.api.file.FileCollection
2626
import org.gradle.api.tasks.Input
27+
import org.gradle.api.tasks.InputFiles
2728
import org.gradle.api.tasks.OutputFile
29+
import org.gradle.api.tasks.SkipWhenEmpty
2830
import org.gradle.api.tasks.SourceSet
2931

3032
import java.nio.file.Files
@@ -39,12 +41,6 @@ public class LicenseHeadersTask extends AntTask {
3941
@OutputFile
4042
File reportFile = new File(project.buildDir, 'reports/licenseHeaders/rat.log')
4143

42-
/**
43-
* The list of java files to check. protected so the afterEvaluate closure in the
44-
* constructor can write to it.
45-
*/
46-
protected List<FileCollection> javaFiles
47-
4844
/** Allowed license families for this project. */
4945
@Input
5046
List<String> approvedLicenses = ['Apache', 'Generated']
@@ -65,11 +61,16 @@ public class LicenseHeadersTask extends AntTask {
6561

6662
LicenseHeadersTask() {
6763
description = "Checks sources for missing, incorrect, or unacceptable license headers"
68-
// Delay resolving the dependencies until after evaluation so we pick up generated sources
69-
project.afterEvaluate {
70-
javaFiles = project.sourceSets.collect({it.allJava})
71-
inputs.files(javaFiles)
72-
}
64+
}
65+
66+
/**
67+
* The list of java files to check. protected so the afterEvaluate closure in the
68+
* constructor can write to it.
69+
*/
70+
@InputFiles
71+
@SkipWhenEmpty
72+
public List<FileCollection> getJavaFiles() {
73+
return project.sourceSets.collect({it.allJava})
7374
}
7475

7576
/**
@@ -97,9 +98,8 @@ public class LicenseHeadersTask extends AntTask {
9798
Files.deleteIfExists(reportFile.toPath())
9899

99100
// run rat, going to the file
100-
List<FileCollection> input = javaFiles
101101
ant.ratReport(reportFile: reportFile.absolutePath, addDefaultLicenseMatchers: true) {
102-
for (FileCollection dirSet : input) {
102+
for (FileCollection dirSet : javaFiles) {
103103
for (File dir: dirSet.srcDirs) {
104104
// sometimes these dirs don't exist, e.g. site-plugin has no actual java src/main...
105105
if (dir.exists()) {

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterConfiguration.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class ClusterConfiguration {
6969
*/
7070
@Input
7171
Closure<Integer> minimumMasterNodes = {
72-
if (bwcVersion != null && bwcVersion.before("6.5.0-SNAPSHOT")) {
72+
if (bwcVersion != null && bwcVersion.before("6.5.0")) {
7373
return numNodes > 1 ? numNodes : -1
7474
} else {
7575
return numNodes > 1 ? numNodes.intdiv(2) + 1 : -1

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class ClusterFormationTasks {
127127
nodes.add(node)
128128
Closure<Map> writeConfigSetup
129129
Object dependsOn
130-
if (node.nodeVersion.onOrAfter("6.5.0-SNAPSHOT")) {
130+
if (node.nodeVersion.onOrAfter("6.5.0")) {
131131
writeConfigSetup = { Map esConfig ->
132132
// Don't force discovery provider if one is set by the test cluster specs already
133133
if (esConfig.containsKey('discovery.zen.hosts_provider') == false) {
@@ -140,7 +140,7 @@ class ClusterFormationTasks {
140140
} else {
141141
dependsOn = startTasks.empty ? startDependencies : startTasks.get(0)
142142
writeConfigSetup = { Map esConfig ->
143-
String unicastTransportUri = node.config.unicastTransportUri(nodes.get(0), node, project.ant)
143+
String unicastTransportUri = node.config.unicastTransportUri(nodes.get(0), node, project.createAntBuilder())
144144
if (unicastTransportUri == null) {
145145
esConfig['discovery.zen.ping.unicast.hosts'] = []
146146
} else {
@@ -717,7 +717,7 @@ class ClusterFormationTasks {
717717
Collection<String> unicastHosts = new HashSet<>()
718718
nodes.forEach { node ->
719719
unicastHosts.addAll(node.config.otherUnicastHostAddresses.call())
720-
String unicastHost = node.config.unicastTransportUri(node, null, project.ant)
720+
String unicastHost = node.config.unicastTransportUri(node, null, project.createAntBuilder())
721721
if (unicastHost != null) {
722722
unicastHosts.add(unicastHost)
723723
}
@@ -913,9 +913,10 @@ class ClusterFormationTasks {
913913
outputPrintStream: outputStream,
914914
messageOutputLevel: org.apache.tools.ant.Project.MSG_INFO)
915915

916-
project.ant.project.addBuildListener(listener)
917-
Object retVal = command(project.ant)
918-
project.ant.project.removeBuildListener(listener)
916+
AntBuilder ant = project.createAntBuilder()
917+
ant.project.addBuildListener(listener)
918+
Object retVal = command(ant)
919+
ant.project.removeBuildListener(listener)
919920
return retVal
920921
}
921922

0 commit comments

Comments
 (0)