Skip to content

Commit 2cea4cd

Browse files
committed
Merge branch 'master' into pr/26166
* master: (278 commits) Move pre-6.0 node checkpoint to SequenceNumbers Invalid JSON request body caused endless loop (elastic#26680) added comment fix line length violation Moved the check to fetch phase. This basically means that we throw a better error message instead of an AOBE and not adding more restrictions. inner hits: Do not allow inner hits that use _source and have a non nested object field as parent Separate Painless Whitelist Loading from the Painless Definition (elastic#26540) convert more admin requests to writeable (elastic#26566) Handle release of 5.6.1 Allow `InputStreamStreamInput` array size validation where applicable (elastic#26692) Update global checkpoint with permit after recovery Filter pre-6.0 nodes for checkpoint invariants Skip bad request REST test on pre-6.0 Reenable BWC tests after disabling for backport Add global checkpoint tracking on the primary [Test] Fix reference/cat/allocation/line_8 test failure [Docs] improved description for fs.total.available_in_bytes (elastic#26657) Fix discovery-file plugin to use custom config path fix testSniffNodes to use the new error message Add check for invalid index in WildcardExpressionResolver (elastic#26409) ...
2 parents e88ebc0 + 2567210 commit 2cea4cd

File tree

1,405 files changed

+27297
-19447
lines changed

Some content is hidden

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

1,405 files changed

+27297
-19447
lines changed

CONTRIBUTING.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ Make sure you have [Gradle](http://gradle.org) installed, as
9191
Elasticsearch uses it as its build system. Gradle must be at least
9292
version 3.3 in order to build successfully.
9393

94+
We support development in the Eclipse and IntelliJ IDEs. For Eclipse, the
95+
minimum version that we support is [Eclipse Oxygen][eclipse] (version 4.7). For
96+
IntelliJ, the minimum version that we support is [IntelliJ 2017.2][intellij].
97+
9498
Eclipse users can automatically configure their IDE: `gradle eclipse`
9599
then `File: Import: Existing Projects into Workspace`. Select the
96100
option `Search for nested projects`. Additionally you will want to
@@ -102,11 +106,10 @@ then `File->New Project From Existing Sources`. Point to the root of
102106
the source directory, select
103107
`Import project from external model->Gradle`, enable
104108
`Use auto-import`. Additionally, in order to run tests directly from
105-
IDEA 2017.1 and above it is required to disable IDEA run launcher,
109+
IDEA 2017.2 and above it is required to disable IDEA run launcher,
106110
which can be achieved by adding `-Didea.no.launcher=true`
107111
[JVM option](https://intellij-support.jetbrains.com/hc/en-us/articles/206544869-Configuring-JVM-options-and-platform-properties)
108112

109-
110113
The Elasticsearch codebase makes heavy use of Java `assert`s and the
111114
test runner requires that assertions be enabled within the JVM. This
112115
can be accomplished by passing the flag `-ea` to the JVM on startup.
@@ -172,3 +175,6 @@ especially when they are unlikely to become long time contributors.
172175
Finally, we require that you run `gradle check` before submitting a
173176
non-documentation contribution. This is mentioned above, but it is worth
174177
repeating in this section because it has come up in this context.
178+
179+
[eclipse]: http://www.eclipse.org/community/eclipse_newsletter/2017/june/
180+
[intellij]: https://blog.jetbrains.com/idea/2017/07/intellij-idea-2017-2-is-here-smart-sleek-and-snappy/

TESTING.asciidoc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,3 +548,17 @@ included as part of the build by checking the projects of the build.
548548
---------------------------------------------------------------------------
549549
gradle projects
550550
---------------------------------------------------------------------------
551+
552+
== Environment misc
553+
554+
There is a known issue with macOS localhost resolve strategy that can cause
555+
some integration tests to fail. This is because integration tests have timings
556+
for cluster formation, discovery, etc. that can be exceeded if name resolution
557+
takes a long time.
558+
To fix this, make sure you have your computer name (as returned by `hostname`)
559+
inside `/etc/hosts`, e.g.:
560+
....
561+
127.0.0.1 localhost ElasticMBP.local
562+
255.255.255.255 broadcasthost
563+
::1 localhost ElasticMBP.local`
564+
....

build.gradle

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import org.eclipse.jgit.lib.Repository
2323
import org.eclipse.jgit.lib.RepositoryBuilder
2424
import org.gradle.plugins.ide.eclipse.model.SourceFolder
2525
import org.apache.tools.ant.taskdefs.condition.Os
26+
import org.elasticsearch.gradle.BuildPlugin
2627
import org.elasticsearch.gradle.VersionProperties
2728
import org.elasticsearch.gradle.Version
2829

@@ -60,6 +61,10 @@ configure(subprojects.findAll { it.projectDir.toPath().startsWith(rootPath) }) {
6061
}
6162
}
6263
}
64+
plugins.withType(BuildPlugin).whenPluginAdded {
65+
project.licenseFile = project.rootProject.file('LICENSE.txt')
66+
project.noticeFile = project.rootProject.file('NOTICE.txt')
67+
}
6368
}
6469

6570
/* Introspect all versions of ES that may be tested agains for backwards
@@ -122,6 +127,16 @@ if (currentVersion.bugfix == 0) {
122127
}
123128
}
124129

130+
// build metadata from previous build, contains eg hashes for bwc builds
131+
String buildMetadataValue = System.getenv('BUILD_METADATA')
132+
if (buildMetadataValue == null) {
133+
buildMetadataValue = ''
134+
}
135+
Map<String, String> buildMetadataMap = buildMetadataValue.tokenize(';').collectEntries {
136+
def (String key, String value) = it.split('=')
137+
return [key, value]
138+
}
139+
125140
// injecting groovy property variables into all projects
126141
allprojects {
127142
project.ext {
@@ -131,6 +146,7 @@ allprojects {
131146
// for backcompat testing
132147
indexCompatVersions = versions
133148
wireCompatVersions = versions.subList(prevMinorIndex, versions.size())
149+
buildMetadata = buildMetadataMap
134150
}
135151
}
136152

@@ -188,33 +204,15 @@ task branchConsistency {
188204
}
189205

190206
subprojects {
191-
project.afterEvaluate {
192-
// include license and notice in jars
193-
tasks.withType(Jar) {
194-
into('META-INF') {
195-
from project.rootProject.rootDir
196-
include 'LICENSE.txt'
197-
include 'NOTICE.txt'
198-
}
199-
}
200-
// ignore missing javadocs
201-
tasks.withType(Javadoc) { Javadoc javadoc ->
202-
// the -quiet here is because of a bug in gradle, in that adding a string option
203-
// by itself is not added to the options. By adding quiet, both this option and
204-
// the "value" -quiet is added, separated by a space. This is ok since the javadoc
205-
// command already adds -quiet, so we are just duplicating it
206-
// see https://discuss.gradle.org/t/add-custom-javadoc-option-that-does-not-take-an-argument/5959
207-
javadoc.options.encoding='UTF8'
208-
javadoc.options.addStringOption('Xdoclint:all,-missing', '-quiet')
209-
/*
210-
TODO: building javadocs with java 9 b118 is currently broken with weird errors, so
211-
for now this is commented out...try again with the next ea build...
212-
javadoc.executable = new File(project.javaHome, 'bin/javadoc')
213-
if (project.javaVersion == JavaVersion.VERSION_1_9) {
214-
// TODO: remove this hack! gradle should be passing this...
215-
javadoc.options.addStringOption('source', '8')
216-
}*/
217-
}
207+
// ignore missing javadocs
208+
tasks.withType(Javadoc) { Javadoc javadoc ->
209+
// the -quiet here is because of a bug in gradle, in that adding a string option
210+
// by itself is not added to the options. By adding quiet, both this option and
211+
// the "value" -quiet is added, separated by a space. This is ok since the javadoc
212+
// command already adds -quiet, so we are just duplicating it
213+
// see https://discuss.gradle.org/t/add-custom-javadoc-option-that-does-not-take-an-argument/5959
214+
javadoc.options.encoding='UTF8'
215+
javadoc.options.addStringOption('Xdoclint:all,-missing', '-quiet')
218216
}
219217

220218
/* Sets up the dependencies that we build as part of this project but
@@ -272,6 +270,27 @@ subprojects {
272270
}
273271
}
274272
}
273+
274+
// Handle javadoc dependencies across projects. Order matters: the linksOffline for
275+
// org.elasticsearch:elasticsearch must be the last one or all the links for the
276+
// other packages (e.g org.elasticsearch.client) will point to core rather than
277+
// their own artifacts.
278+
if (project.plugins.hasPlugin(BuildPlugin)) {
279+
String artifactsHost = VersionProperties.elasticsearch.endsWith("-SNAPSHOT") ? "https://snapshots.elastic.co" : "https://artifacts.elastic.co"
280+
Closure sortClosure = { a, b -> b.group <=> a.group }
281+
Closure depJavadocClosure = { dep ->
282+
if (dep.group != null && dep.group.startsWith('org.elasticsearch')) {
283+
String substitution = project.ext.projectSubstitutions.get("${dep.group}:${dep.name}:${dep.version}")
284+
if (substitution != null) {
285+
project.javadoc.dependsOn substitution + ':javadoc'
286+
String artifactPath = dep.group.replaceAll('\\.', '/') + '/' + dep.name.replaceAll('\\.', '/') + '/' + dep.version
287+
project.javadoc.options.linksOffline artifactsHost + "/javadoc/" + artifactPath, "${project.project(substitution).buildDir}/docs/javadoc/"
288+
}
289+
}
290+
}
291+
project.configurations.compile.dependencies.findAll().toSorted(sortClosure).each(depJavadocClosure)
292+
project.configurations.provided.dependencies.findAll().toSorted(sortClosure).each(depJavadocClosure)
293+
}
275294
}
276295
}
277296

@@ -281,7 +300,7 @@ subprojects {
281300
// the dependency is added.
282301
gradle.projectsEvaluated {
283302
allprojects {
284-
if (project.path == ':test:framework' || project.path == ':client:test') {
303+
if (project.path == ':test:framework') {
285304
// :test:framework:test cannot run before and after :core:test
286305
return
287306
}

buildSrc/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ dependencies {
9494
compile 'com.perforce:p4java:2012.3.551082' // THIS IS SUPPOSED TO BE OPTIONAL IN THE FUTURE....
9595
compile 'de.thetaphi:forbiddenapis:2.3'
9696
compile 'org.apache.rat:apache-rat:0.11'
97+
compile "org.elasticsearch:jna:4.4.0-1"
9798
}
9899

99100
// Gradle 2.14+ removed ProgressLogger(-Factory) classes from the public APIs

buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/RandomizedTestingPlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class RandomizedTestingPlugin implements Plugin<Project> {
6161
]
6262
RandomizedTestingTask newTestTask = tasks.create(properties)
6363
newTestTask.classpath = oldTestTask.classpath
64-
newTestTask.testClassesDir = oldTestTask.testClassesDir
64+
newTestTask.testClassesDir = oldTestTask.project.sourceSets.test.output.classesDir
6565

6666
// hack so check task depends on custom test
6767
Task checkTask = tasks.findByPath('check')

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

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,25 @@ import org.gradle.api.Project
3030
import org.gradle.api.Task
3131
import org.gradle.api.XmlProvider
3232
import org.gradle.api.artifacts.Configuration
33-
import org.gradle.api.artifacts.Dependency
3433
import org.gradle.api.artifacts.ModuleDependency
3534
import org.gradle.api.artifacts.ModuleVersionIdentifier
3635
import org.gradle.api.artifacts.ProjectDependency
3736
import org.gradle.api.artifacts.ResolvedArtifact
3837
import org.gradle.api.artifacts.dsl.RepositoryHandler
38+
import org.gradle.api.file.CopySpec
3939
import org.gradle.api.plugins.JavaPlugin
4040
import org.gradle.api.publish.maven.MavenPublication
4141
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
4242
import org.gradle.api.publish.maven.tasks.GenerateMavenPom
4343
import org.gradle.api.tasks.bundling.Jar
4444
import org.gradle.api.tasks.compile.JavaCompile
45+
import org.gradle.api.tasks.javadoc.Javadoc
4546
import org.gradle.internal.jvm.Jvm
4647
import org.gradle.process.ExecResult
4748
import org.gradle.util.GradleVersion
4849

4950
import java.time.ZoneOffset
5051
import java.time.ZonedDateTime
51-
5252
/**
5353
* Encapsulates build configuration for elasticsearch projects.
5454
*/
@@ -79,7 +79,7 @@ class BuildPlugin implements Plugin<Project> {
7979
configureConfigurations(project)
8080
project.ext.versions = VersionProperties.versions
8181
configureCompile(project)
82-
configureJavadocJar(project)
82+
configureJavadoc(project)
8383
configureSourcesJar(project)
8484
configurePomGeneration(project)
8585

@@ -270,8 +270,8 @@ class BuildPlugin implements Plugin<Project> {
270270
})
271271

272272
// force all dependencies added directly to compile/testCompile to be non-transitive, except for ES itself
273-
Closure disableTransitiveDeps = { Dependency dep ->
274-
if (dep instanceof ModuleDependency && !(dep instanceof ProjectDependency) && dep.group.startsWith('org.elasticsearch') == false) {
273+
Closure disableTransitiveDeps = { ModuleDependency dep ->
274+
if (!(dep instanceof ProjectDependency) && dep.group.startsWith('org.elasticsearch') == false) {
275275
dep.transitive = false
276276

277277
// also create a configuration just for this dependency version, so that later
@@ -289,7 +289,7 @@ class BuildPlugin implements Plugin<Project> {
289289
project.configurations.provided.dependencies.all(disableTransitiveDeps)
290290
}
291291

292-
/** Adds repositores used by ES dependencies */
292+
/** Adds repositories used by ES dependencies */
293293
static void configureRepositories(Project project) {
294294
RepositoryHandler repos = project.repositories
295295
if (System.getProperty("repos.mavenlocal") != null) {
@@ -454,6 +454,13 @@ class BuildPlugin implements Plugin<Project> {
454454
}
455455
}
456456

457+
static void configureJavadoc(Project project) {
458+
project.tasks.withType(Javadoc) {
459+
executable = new File(project.javaHome, 'bin/javadoc')
460+
}
461+
configureJavadocJar(project)
462+
}
463+
457464
/** Adds a javadocJar task to generate a jar containing javadocs. */
458465
static void configureJavadocJar(Project project) {
459466
Jar javadocJarTask = project.task('javadocJar', type: Jar)
@@ -473,8 +480,10 @@ class BuildPlugin implements Plugin<Project> {
473480
project.assemble.dependsOn(sourcesJarTask)
474481
}
475482

476-
/** Adds additional manifest info to jars, and adds source and javadoc jars */
483+
/** Adds additional manifest info to jars */
477484
static void configureJars(Project project) {
485+
project.ext.licenseFile = null
486+
project.ext.noticeFile = null
478487
project.tasks.withType(Jar) { Jar jarTask ->
479488
// we put all our distributable files under distributions
480489
jarTask.destinationDir = new File(project.buildDir, 'distributions')
@@ -498,6 +507,20 @@ class BuildPlugin implements Plugin<Project> {
498507
jarTask.manifest.attributes('Change': 'Unknown')
499508
}
500509
}
510+
// add license/notice files
511+
project.afterEvaluate {
512+
if (project.licenseFile == null || project.noticeFile == null) {
513+
throw new GradleException("Must specify license and notice file for project ${project.path}")
514+
}
515+
jarTask.into('META-INF') {
516+
from(project.licenseFile.parent) {
517+
include project.licenseFile.name
518+
}
519+
from(project.noticeFile.parent) {
520+
include project.noticeFile.name
521+
}
522+
}
523+
}
501524
}
502525
}
503526

@@ -526,8 +549,6 @@ class BuildPlugin implements Plugin<Project> {
526549
systemProperty 'tests.artifact', project.name
527550
systemProperty 'tests.task', path
528551
systemProperty 'tests.security.manager', 'true'
529-
// Breaking change in JDK-9, revert to JDK-8 behavior for now, see https://github.com/elastic/elasticsearch/issues/21534
530-
systemProperty 'jdk.io.permissionsUseCanonicalPath', 'true'
531552
systemProperty 'jna.nosys', 'true'
532553
// default test sysprop values
533554
systemProperty 'tests.ifNoTests', 'fail'

buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/RestTestsFromSnippetsTask.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
9393
*
9494
* `sh` snippets that contain `curl` almost always should be marked
9595
* with `// CONSOLE`. In the exceptionally rare cases where they are
96-
* not communicating with Elasticsearch, like the xamples in the ec2
96+
* not communicating with Elasticsearch, like the examples in the ec2
9797
* and gce discovery plugins, the snippets should be marked
9898
* `// NOTCONSOLE`. */
9999
return snippet.language == 'js' || snippet.curl

buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/SnippetsTask.groovy

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020
package org.elasticsearch.gradle.doc
2121

22+
import groovy.json.JsonException
23+
import groovy.json.JsonParserType
24+
import groovy.json.JsonSlurper
25+
2226
import org.gradle.api.DefaultTask
2327
import org.gradle.api.InvalidUserDataException
2428
import org.gradle.api.file.ConfigurableFileTree
@@ -117,6 +121,23 @@ public class SnippetsTask extends DefaultTask {
117121
+ "contain `curl`.")
118122
}
119123
}
124+
if (snippet.testResponse && snippet.language == 'js') {
125+
String quoted = snippet.contents
126+
// quote values starting with $
127+
.replaceAll(/([:,])\s*(\$[^ ,\n}]+)/, '$1 "$2"')
128+
// quote fields starting with $
129+
.replaceAll(/(\$[^ ,\n}]+)\s*:/, '"$1":')
130+
JsonSlurper slurper =
131+
new JsonSlurper(type: JsonParserType.INDEX_OVERLAY)
132+
try {
133+
slurper.parseText(quoted)
134+
} catch (JsonException e) {
135+
throw new InvalidUserDataException("Invalid json "
136+
+ "in $snippet. The error is:\n${e.message}.\n"
137+
+ "After substitutions and munging, the json "
138+
+ "looks like:\n$quoted", e)
139+
}
140+
}
120141
perSnippet(snippet)
121142
snippet = null
122143
}

buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesExtension.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ class PluginPropertiesExtension {
4646
@Input
4747
boolean hasClientJar = false
4848

49+
/** True if the plugin requires the elasticsearch keystore to exist, false otherwise. */
50+
@Input
51+
boolean requiresKeystore = false
52+
4953
/** A license file that should be included in the built plugin zip. */
5054
@Input
5155
File licenseFile = null

buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesTask.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ class PluginPropertiesTask extends Copy {
8080
'elasticsearchVersion': stringSnap(VersionProperties.elasticsearch),
8181
'javaVersion': project.targetCompatibility as String,
8282
'classname': extension.classname,
83-
'hasNativeController': extension.hasNativeController
83+
'hasNativeController': extension.hasNativeController,
84+
'requiresKeystore': extension.requiresKeystore
8485
]
8586
}
8687
}

0 commit comments

Comments
 (0)