Skip to content

Commit 843ae8f

Browse files
committed
Merge branch 'master' into ccr-docs
* master: (74 commits) XContent: Check for bad parsers (elastic#34561) Docs: Align prose with snippet (elastic#34839) document the search context is freed if the scroll is not extended (elastic#34739) Test: Lookup node versions on rest test start (elastic#34657) SQL: Return error with ORDER BY on non-grouped. (elastic#34855) Reduce channels in AbstractSimpleTransportTestCase (elastic#34863) [DOCS] Updates Elasticsearch monitoring tasks (elastic#34339) Check self references in metric agg after last doc collection (elastic#33593) (elastic#34001) [Docs] Add `indices.query.bool.max_clause_count` setting (elastic#34779) Add 6.6.0 version to master (elastic#34847) Test: ensure char[] doesn't being with prefix (elastic#34816) Remove static import from HLRC doc snippet (elastic#34834) Logging: server: clean up logging (elastic#34593) Logging: tests: clean up logging (elastic#34606) SQL: Fix edge case: `<field> IN (null)` (elastic#34802) [Test] Mute FullClusterRestartIT.testShrink() until test is fixed SQL: Introduce ODBC mode, similar to JDBC (elastic#34825) SQL: handle X-Pack or X-Pack SQL not being available in a more graceful way (elastic#34736) [Docs] Add explanation for code snippets line width (elastic#34796) CCR: Rename follow-task parameters and stats (elastic#34836) ...
2 parents 6fbe1cd + 3cde135 commit 843ae8f

File tree

568 files changed

+8045
-4080
lines changed

Some content is hidden

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

568 files changed

+8045
-4080
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ Please follow these formatting guidelines:
159159

160160
* Java indent is 4 spaces
161161
* Line width is 140 characters
162+
* Line width for code snippets that are included in the documentation (the ones surrounded by `// tag` and `// end` comments) is 76 characters
162163
* The rest is left to Java coding standards
163164
* Disable “auto-format on save” to prevent unnecessary format changes. This makes reviews much harder as it generates unnecessary formatting changes. If your IDE supports formatting only modified chunks that is fine to do.
164165
* Wildcard imports (`import foo.bar.baz.*`) are forbidden and will cause the build to fail. This can be done automatically by your IDE:

buildSrc/build.gradle

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,12 @@ if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion)) {
3131
throw new GradleException("Gradle ${minimumGradleVersion}+ is required to build elasticsearch")
3232
}
3333

34-
if (JavaVersion.current() < JavaVersion.VERSION_1_8) {
35-
throw new GradleException('Java 1.8 is required to build elasticsearch gradle tools')
36-
}
37-
3834
if (project == rootProject) {
3935
// change the build dir used during build init, so that doing a clean
4036
// won't wipe out the buildscript jar
4137
buildDir = 'build-bootstrap'
4238
}
4339

44-
// Make sure :buildSrc: doesn't generate classes incompatible with RUNTIME_JAVA_HOME
45-
// We can't use BuildPlugin here, so read from file
46-
String minimumRuntimeVersion = file('src/main/resources/minimumRuntimeVersion').text.trim()
47-
targetCompatibility = minimumRuntimeVersion
48-
sourceCompatibility = minimumRuntimeVersion
49-
5040
/*****************************************************************************
5141
* Propagating version.properties to the rest of the build *
5242
*****************************************************************************/
@@ -82,6 +72,45 @@ processResources {
8272
from tempPropertiesFile
8373
}
8474

75+
76+
if (JavaVersion.current() < JavaVersion.VERSION_1_10) {
77+
throw new GradleException('At least Java 10 is required to build elasticsearch gradle tools')
78+
}
79+
80+
/*****************************************************************************
81+
* Java version *
82+
*****************************************************************************/
83+
84+
// Gradle 4.10 does not support setting this to 11 yet
85+
targetCompatibility = "10"
86+
sourceCompatibility = "10"
87+
88+
// We have a few classes that need to be compiled for older java versions because these are used to run checks against
89+
// those
90+
sourceSets {
91+
minimumRuntime {
92+
// We only want Java here, but the Groovy doesn't configure javadoc correctly if we don't define this as groovy
93+
groovy {
94+
srcDirs = ['src/main/minimumRuntime']
95+
}
96+
}
97+
}
98+
compileMinimumRuntimeGroovy {
99+
// We can't use BuildPlugin here, so read from file
100+
String minimumRuntimeVersion = file('src/main/resources/minimumRuntimeVersion').text.trim()
101+
targetCompatibility = minimumRuntimeVersion
102+
sourceCompatibility = minimumRuntimeVersion
103+
}
104+
dependencies {
105+
compile sourceSets.minimumRuntime.output
106+
minimumRuntimeCompile "junit:junit:${props.getProperty('junit')}"
107+
minimumRuntimeCompile localGroovy()
108+
}
109+
jar {
110+
from sourceSets.minimumRuntime.output
111+
}
112+
113+
85114
/*****************************************************************************
86115
* Dependencies used by the entire build *
87116
*****************************************************************************/
@@ -94,10 +123,7 @@ dependencies {
94123
compile localGroovy()
95124
compile "com.carrotsearch.randomizedtesting:junit4-ant:${props.getProperty('randomizedrunner')}"
96125
compile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${props.getProperty('randomizedrunner')}"
97-
98-
compile("junit:junit:${props.getProperty('junit')}") {
99-
transitive = false
100-
}
126+
101127
compile 'com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3'
102128
compile 'com.netflix.nebula:nebula-publishing-plugin:4.4.4'
103129
compile 'com.netflix.nebula:gradle-info-plugin:3.0.3'
@@ -156,6 +182,7 @@ if (project != rootProject) {
156182
dependenciesInfo.enabled = false
157183
forbiddenApisMain.enabled = false
158184
forbiddenApisTest.enabled = false
185+
forbiddenApisMinimumRuntime.enabled = false
159186
jarHell.enabled = false
160187
thirdPartyAudit.enabled = false
161188

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

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,14 @@ class BuildPlugin implements Plugin<Project> {
9999
configureSourcesJar(project)
100100
configurePomGeneration(project)
101101

102+
applyCommonTestConfig(project)
102103
configureTest(project)
103104
configurePrecommit(project)
104105
configureDependenciesInfo(project)
105106
}
106107

107108

109+
108110
/** Performs checks on the build environment and prints information about the build environment. */
109111
static void globalBuildInfo(Project project) {
110112
if (project.rootProject.ext.has('buildChecksDone') == false) {
@@ -776,9 +778,8 @@ class BuildPlugin implements Plugin<Project> {
776778
}
777779
}
778780

779-
/** Returns a closure of common configuration shared by unit and integration tests. */
780-
static Closure commonTestConfig(Project project) {
781-
return {
781+
static void applyCommonTestConfig(Project project) {
782+
project.tasks.withType(RandomizedTestingTask) {
782783
jvm "${project.runtimeJavaHome}/bin/java"
783784
parallelism System.getProperty('tests.jvms', 'auto')
784785
ifNoTests System.getProperty('tests.ifNoTests', 'fail')
@@ -873,6 +874,8 @@ class BuildPlugin implements Plugin<Project> {
873874

874875
exclude '**/*$*.class'
875876

877+
dependsOn(project.tasks.testClasses)
878+
876879
project.plugins.withType(ShadowPlugin).whenPluginAdded {
877880
// Test against a shadow jar if we made one
878881
classpath -= project.tasks.compileJava.outputs.files
@@ -884,23 +887,9 @@ class BuildPlugin implements Plugin<Project> {
884887

885888
/** Configures the test task */
886889
static Task configureTest(Project project) {
887-
RandomizedTestingTask test = project.tasks.getByName('test')
888-
test.configure(commonTestConfig(project))
889-
test.configure {
890+
project.tasks.getByName('test') {
890891
include '**/*Tests.class'
891892
}
892-
893-
// Add a method to create additional unit tests for a project, which will share the same
894-
// randomized testing setup, but by default run no tests.
895-
project.extensions.add('additionalTest', { String name, Closure config ->
896-
RandomizedTestingTask additionalTest = project.tasks.create(name, RandomizedTestingTask.class)
897-
additionalTest.classpath = test.classpath
898-
additionalTest.testClassesDirs = test.testClassesDirs
899-
additionalTest.configure(commonTestConfig(project))
900-
additionalTest.configure(config)
901-
additionalTest.dependsOn(project.tasks.testClasses)
902-
project.check.dependsOn(additionalTest)
903-
});
904893
}
905894

906895
private static configurePrecommit(Project project) {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ class ClusterConfiguration {
6868
* In case of more than one node, this defaults to the number of nodes
6969
*/
7070
@Input
71-
Closure<Integer> minimumMasterNodes = { getNumNodes() > 1 ? getNumNodes() : -1 }
71+
Closure<Integer> minimumMasterNodes = {
72+
return getNumNodes() > 1 ? getNumNodes() : -1
73+
}
7274

7375
@Input
7476
String jvmArgs = "-Xms" + System.getProperty('tests.heap.size', '512m') +

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

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,31 @@ class ClusterFormationTasks {
122122
}
123123
NodeInfo node = new NodeInfo(config, i, project, prefix, elasticsearchVersion, sharedDir)
124124
nodes.add(node)
125-
Object dependsOn = startTasks.empty ? startDependencies : startTasks.get(0)
126-
startTasks.add(configureNode(project, prefix, runner, dependsOn, node, config, distro, nodes.get(0)))
125+
Closure<Map> writeConfigSetup
126+
Object dependsOn
127+
if (node.nodeVersion.onOrAfter("6.5.0-SNAPSHOT")) {
128+
writeConfigSetup = { Map esConfig ->
129+
// Don't force discovery provider if one is set by the test cluster specs already
130+
if (esConfig.containsKey('discovery.zen.hosts_provider') == false) {
131+
esConfig['discovery.zen.hosts_provider'] = 'file'
132+
}
133+
esConfig['discovery.zen.ping.unicast.hosts'] = []
134+
esConfig
135+
}
136+
dependsOn = startDependencies
137+
} else {
138+
dependsOn = startTasks.empty ? startDependencies : startTasks.get(0)
139+
writeConfigSetup = { Map esConfig ->
140+
String unicastTransportUri = node.config.unicastTransportUri(nodes.get(0), node, project.ant)
141+
if (unicastTransportUri == null) {
142+
esConfig['discovery.zen.ping.unicast.hosts'] = []
143+
} else {
144+
esConfig['discovery.zen.ping.unicast.hosts'] = "\"${unicastTransportUri}\""
145+
}
146+
esConfig
147+
}
148+
}
149+
startTasks.add(configureNode(project, prefix, runner, dependsOn, node, config, distro, writeConfigSetup))
127150
}
128151

129152
Task wait = configureWaitTask("${prefix}#wait", project, nodes, startTasks, config.nodeStartupWaitSeconds)
@@ -182,7 +205,7 @@ class ClusterFormationTasks {
182205
* @return a task which starts the node.
183206
*/
184207
static Task configureNode(Project project, String prefix, Task runner, Object dependsOn, NodeInfo node, ClusterConfiguration config,
185-
Configuration distribution, NodeInfo seedNode) {
208+
Configuration distribution, Closure<Map> writeConfig) {
186209

187210
// tasks are chained so their execution order is maintained
188211
Task setup = project.tasks.create(name: taskName(prefix, node, 'clean'), type: Delete, dependsOn: dependsOn) {
@@ -198,7 +221,7 @@ class ClusterFormationTasks {
198221
setup = configureCheckPreviousTask(taskName(prefix, node, 'checkPrevious'), project, setup, node)
199222
setup = configureStopTask(taskName(prefix, node, 'stopPrevious'), project, setup, node)
200223
setup = configureExtractTask(taskName(prefix, node, 'extract'), project, setup, node, distribution)
201-
setup = configureWriteConfigTask(taskName(prefix, node, 'configure'), project, setup, node, seedNode)
224+
setup = configureWriteConfigTask(taskName(prefix, node, 'configure'), project, setup, node, writeConfig)
202225
setup = configureCreateKeystoreTask(taskName(prefix, node, 'createKeystore'), project, setup, node)
203226
setup = configureAddKeystoreSettingTasks(prefix, project, setup, node)
204227
setup = configureAddKeystoreFileTasks(prefix, project, setup, node)
@@ -301,7 +324,7 @@ class ClusterFormationTasks {
301324
}
302325

303326
/** Adds a task to write elasticsearch.yml for the given node configuration */
304-
static Task configureWriteConfigTask(String name, Project project, Task setup, NodeInfo node, NodeInfo seedNode) {
327+
static Task configureWriteConfigTask(String name, Project project, Task setup, NodeInfo node, Closure<Map> configFilter) {
305328
Map esConfig = [
306329
'cluster.name' : node.clusterName,
307330
'node.name' : "node-" + node.nodeNum,
@@ -347,10 +370,7 @@ class ClusterFormationTasks {
347370

348371
Task writeConfig = project.tasks.create(name: name, type: DefaultTask, dependsOn: setup)
349372
writeConfig.doFirst {
350-
String unicastTransportUri = node.config.unicastTransportUri(seedNode, node, project.ant)
351-
if (unicastTransportUri != null) {
352-
esConfig['discovery.zen.ping.unicast.hosts'] = "\"${unicastTransportUri}\""
353-
}
373+
esConfig = configFilter.call(esConfig)
354374
File configFile = new File(node.pathConf, 'elasticsearch.yml')
355375
logger.info("Configuring ${configFile}")
356376
configFile.setText(esConfig.collect { key, value -> "${key}: ${value}" }.join('\n'), 'UTF-8')
@@ -681,6 +701,19 @@ class ClusterFormationTasks {
681701
static Task configureWaitTask(String name, Project project, List<NodeInfo> nodes, List<Task> startTasks, int waitSeconds) {
682702
Task wait = project.tasks.create(name: name, dependsOn: startTasks)
683703
wait.doLast {
704+
705+
Collection<String> unicastHosts = new HashSet<>()
706+
nodes.forEach { otherNode ->
707+
String unicastHost = otherNode.config.unicastTransportUri(otherNode, null, project.ant)
708+
if (unicastHost != null) {
709+
unicastHosts.addAll(Arrays.asList(unicastHost.split(",")))
710+
}
711+
}
712+
String unicastHostsTxt = String.join("\n", unicastHosts)
713+
nodes.forEach { node ->
714+
node.pathConf.toPath().resolve("unicast_hosts.txt").setText(unicastHostsTxt)
715+
}
716+
684717
ant.waitfor(maxwait: "${waitSeconds}", maxwaitunit: 'second', checkevery: '500', checkeveryunit: 'millisecond', timeoutproperty: "failed${name}") {
685718
or {
686719
for (NodeInfo node : nodes) {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ public class RestIntegTestTask extends DefaultTask {
6464
runner.testClassesDirs = project.sourceSets.test.output.classesDirs
6565
clusterConfig = project.extensions.create("${name}Cluster", ClusterConfiguration.class, project)
6666

67-
// start with the common test configuration
68-
runner.configure(BuildPlugin.commonTestConfig(project))
6967
// override/add more for rest tests
7068
runner.parallelism = '1'
7169
runner.include('**/*IT.class')

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public class StandaloneRestTestPlugin implements Plugin<Project> {
5050
project.getTasks().create("buildResources", ExportElasticsearchBuildResourcesTask)
5151
BuildPlugin.globalBuildInfo(project)
5252
BuildPlugin.configureRepositories(project)
53+
BuildPlugin.applyCommonTestConfig(project)
5354

5455
// only setup tests to build
5556
project.sourceSets.create('test')

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import org.elasticsearch.gradle.BuildPlugin
2424
import org.gradle.api.Plugin
2525
import org.gradle.api.Project
2626
import org.gradle.api.plugins.JavaBasePlugin
27-
import org.gradle.api.tasks.compile.JavaCompile
2827

2928
/**
3029
* Configures the build to compile against Elasticsearch's test framework and
@@ -44,7 +43,6 @@ public class StandaloneTestPlugin implements Plugin<Project> {
4443
description: 'Runs unit tests that are separate'
4544
]
4645
RandomizedTestingTask test = project.tasks.create(testOptions)
47-
test.configure(BuildPlugin.commonTestConfig(project))
4846
BuildPlugin.configureCompile(project)
4947
test.classpath = project.sourceSets.test.runtimeClasspath
5048
test.testClassesDirs = project.sourceSets.test.output.classesDirs

buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersPlugin.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939

4040
public class TestClustersPlugin implements Plugin<Project> {
4141

42-
public static final String LIST_TASK_NAME = "listElasticSearchClusters";
43-
public static final String EXTENSION_NAME = "elasticSearchClusters";
42+
private static final String LIST_TASK_NAME = "listTestClusters";
43+
private static final String NODE_EXTENSION_NAME = "testClusters";
4444

4545
private final Logger logger = Logging.getLogger(TestClustersPlugin.class);
4646

@@ -50,7 +50,7 @@ public void apply(Project project) {
5050
ElasticsearchNode.class,
5151
(name) -> new ElasticsearchNode(name, GradleServicesAdapter.getInstance(project))
5252
);
53-
project.getExtensions().add(EXTENSION_NAME, container);
53+
project.getExtensions().add(NODE_EXTENSION_NAME, container);
5454

5555
Task listTask = project.getTasks().create(LIST_TASK_NAME);
5656
listTask.setGroup("ES cluster formation");

buildSrc/src/main/resources/checkstyle_suppressions.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -614,9 +614,6 @@
614614
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]bucket[/\\]TermsDocCountErrorIT.java" checks="LineLength" />
615615
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]bucket[/\\]TermsShardMinDocCountIT.java" checks="LineLength" />
616616
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]bucket[/\\]nested[/\\]NestedAggregatorTests.java" checks="LineLength" />
617-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]pipeline[/\\]ExtendedStatsBucketIT.java" checks="LineLength" />
618-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]pipeline[/\\]moving[/\\]avg[/\\]MovAvgIT.java" checks="LineLength" />
619-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]pipeline[/\\]serialdiff[/\\]SerialDiffIT.java" checks="LineLength" />
620617
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]basic[/\\]SearchWhileCreatingIndexIT.java" checks="LineLength" />
621618
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]basic[/\\]SearchWhileRelocatingIT.java" checks="LineLength" />
622619
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]basic[/\\]SearchWithRandomExceptionsIT.java" checks="LineLength" />

buildSrc/src/test/java/org/elasticsearch/gradle/testclusters/TestClustersPluginIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ public class TestClustersPluginIT extends GradleIntegrationTestCase {
3131
public void testListClusters() {
3232
BuildResult result = GradleRunner.create()
3333
.withProjectDir(getProjectDir("testclusters"))
34-
.withArguments("listElasticSearchClusters", "-s")
34+
.withArguments("listTestClusters", "-s")
3535
.withPluginClasspath()
3636
.build();
3737

38-
assertEquals(TaskOutcome.SUCCESS, result.task(":listElasticSearchClusters").getOutcome());
38+
assertEquals(TaskOutcome.SUCCESS, result.task(":listTestClusters").getOutcome());
3939
assertOutputContains(
4040
result.getOutput(),
4141
" * myTestCluster:"

buildSrc/src/testKit/testclusters/build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,40 @@ plugins {
22
id 'elasticsearch.testclusters'
33
}
44

5-
elasticSearchClusters {
5+
testClusters {
66
myTestCluster {
77
distribution = 'ZIP'
88
}
99
}
1010

1111
task user1 {
12-
useCluster elasticSearchClusters.myTestCluster
12+
useCluster testClusters.myTestCluster
1313
doLast {
1414
println "user1 executing"
1515
}
1616
}
1717

1818
task user2 {
19-
useCluster elasticSearchClusters.myTestCluster
19+
useCluster testClusters.myTestCluster
2020
doLast {
2121
println "user2 executing"
2222
}
2323
}
2424

2525
task upToDate1 {
26-
useCluster elasticSearchClusters.myTestCluster
26+
useCluster testClusters.myTestCluster
2727
}
2828

2929
task upToDate2 {
30-
useCluster elasticSearchClusters.myTestCluster
30+
useCluster testClusters.myTestCluster
3131
}
3232

3333
task skipped1 {
3434
enabled = false
35-
useCluster elasticSearchClusters.myTestCluster
35+
useCluster testClusters.myTestCluster
3636
}
3737

3838
task skipped2 {
3939
enabled = false
40-
useCluster elasticSearchClusters.myTestCluster
40+
useCluster testClusters.myTestCluster
4141
}

client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterRequestConverters.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
final class ClusterRequestConverters {
3333

34+
private ClusterRequestConverters() {}
35+
3436
static Request clusterPutSettings(ClusterUpdateSettingsRequest clusterUpdateSettingsRequest) throws IOException {
3537
Request request = new Request(HttpPut.METHOD_NAME, "/_cluster/settings");
3638

0 commit comments

Comments
 (0)