Skip to content

Commit 833df18

Browse files
committed
Merge branch 'master' into replicated-closed-indices
2 parents 8e93bc4 + 9f3effd commit 833df18

File tree

2,535 files changed

+62806
-17375
lines changed

Some content is hidden

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

2,535 files changed

+62806
-17375
lines changed

.ci/java-versions.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ ES_BUILD_JAVA=java11
88
ES_RUNTIME_JAVA=java8
99
GRADLE_TASK=build
1010

11+
GRADLE_EXTRA_ARGS=-Dtests.bwc.refspec=elastic/index-lifecycle-6.x

CONTRIBUTING.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ 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
162+
* Lines of code surrounded by `// tag` and `// end` comments are included in the
163+
documentation and should only be 76 characters wide not counting
164+
leading indentation
163165
* The rest is left to Java coding standards
164166
* 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.
165167
* Wildcard imports (`import foo.bar.baz.*`) are forbidden and will cause the build to fail. This can be done automatically by your IDE:
@@ -194,11 +196,26 @@ the settings window and/or restart IntelliJ to see your changes take effect.
194196

195197
### Creating A Distribution
196198

197-
To create a distribution from the source, simply run:
199+
Run all build commands from within the root directory:
198200

199201
```sh
200202
cd elasticsearch/
201-
./gradlew assemble
203+
```
204+
205+
To build a tar distribution, run this command:
206+
207+
```sh
208+
./gradlew -p distribution/archives/tar assemble --parallel
209+
```
210+
211+
You will find the distribution under:
212+
`./distribution/archives/tar/build/distributions/`
213+
214+
To create all build artifacts (e.g., plugins and Javadocs) as well as
215+
distributions in all formats, run this command:
216+
217+
```sh
218+
./gradlew assemble --parallel
202219
```
203220

204221
The package distributions (Debian and RPM) can be found under:
@@ -207,7 +224,6 @@ The package distributions (Debian and RPM) can be found under:
207224
The archive distributions (tar and zip) can be found under:
208225
`./distribution/archives/(tar|zip)/build/distributions/`
209226

210-
211227
### Running The Full Test Suite
212228

213229
Before submitting your changes, run the test suite to make sure that nothing is broken, with:

TESTING.asciidoc

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -229,34 +229,6 @@ Pass arbitrary jvm arguments.
229229
./gradlew test -Dtests.jvm.argline="-Djava.security.debug=access,failure"
230230
------------------------------
231231

232-
== Backwards Compatibility Tests
233-
234-
Running backwards compatibility tests is disabled by default since it
235-
requires a release version of elasticsearch to be present on the test system.
236-
To run backwards compatibility tests untar or unzip a release and run the tests
237-
with the following command:
238-
239-
---------------------------------------------------------------------------
240-
./gradlew test -Dtests.filter="@backwards" -Dtests.bwc.version=x.y.z -Dtests.bwc.path=/path/to/elasticsearch -Dtests.security.manager=false
241-
---------------------------------------------------------------------------
242-
243-
Note that backwards tests must be run with security manager disabled.
244-
If the elasticsearch release is placed under `./backwards/elasticsearch-x.y.z` the path
245-
can be omitted:
246-
247-
---------------------------------------------------------------------------
248-
./gradlew test -Dtests.filter="@backwards" -Dtests.bwc.version=x.y.z -Dtests.security.manager=false
249-
---------------------------------------------------------------------------
250-
251-
To setup the bwc test environment execute the following steps (provided you are
252-
already in your elasticsearch clone):
253-
254-
---------------------------------------------------------------------------
255-
$ mkdir backwards && cd backwards
256-
$ curl -O https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.2.1.tar.gz
257-
$ tar -xzf elasticsearch-1.2.1.tar.gz
258-
---------------------------------------------------------------------------
259-
260232
== Running verification tasks
261233

262234
To run all verification tasks, including static checks, unit tests, and integration tests:
@@ -554,25 +526,28 @@ environment variable.
554526
== Testing backwards compatibility
555527

556528
Backwards compatibility tests exist to test upgrading from each supported version
557-
to the current version. To run all backcompat tests use:
529+
to the current version. To run them all use:
558530

559531
-------------------------------------------------
560532
./gradlew bwcTest
561533
-------------------------------------------------
562534

563-
A specific version can be tested as well. For example, to test backcompat with
535+
A specific version can be tested as well. For example, to test bwc with
564536
version 5.3.2 run:
565537

566538
-------------------------------------------------
567539
./gradlew v5.3.2#bwcTest
568540
-------------------------------------------------
569541

570-
When running `./gradlew check`, some minimal backcompat checks are run. Which version
571-
is tested depends on the branch. On master, this will test against the current
572-
stable branch. On the stable branch, it will test against the latest release
573-
branch. Finally, on a release branch, it will test against the most recent release.
542+
Tests are ran for versions that are not yet released but with which the current version will be compatible with.
543+
These are automatically checked out and built from source.
544+
See link:./buildSrc/src/main/java/org/elasticsearch/gradle/VersionCollection.java[VersionCollection]
545+
and link:./distribution/bwc/build.gradle[distribution/bwc/build.gradle]
546+
for more information.
547+
548+
When running `./gradlew check`, minimal bwc checks are also run against compatible versions that are not yet released.
574549

575-
=== BWC Testing against a specific remote/branch
550+
==== BWC Testing against a specific remote/branch
576551

577552
Sometimes a backward compatibility change spans two versions. A common case is a new functionality
578553
that needs a BWC bridge in an unreleased versioned of a release branch (for example, 5.x).
@@ -597,7 +572,7 @@ will contain your change.
597572
. Push both branches to your remote repository.
598573
. Run the tests with `./gradlew check -Dtests.bwc.remote=${remote} -Dtests.bwc.refspec.5.x=index_req_bwc_5.x`.
599574

600-
== Skip fetching latest
575+
==== Skip fetching latest
601576

602577
For some BWC testing scenarios, you want to use the local clone of the
603578
repository without fetching latest. For these use cases, you can set the system

benchmarks/src/main/java/org/elasticsearch/benchmark/routing/allocation/Allocators.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ public final class Allocators {
4646
private static class NoopGatewayAllocator extends GatewayAllocator {
4747
public static final NoopGatewayAllocator INSTANCE = new NoopGatewayAllocator();
4848

49-
protected NoopGatewayAllocator() {
50-
super(Settings.EMPTY);
51-
}
52-
5349
@Override
5450
public void applyStartedShards(RoutingAllocation allocation, List<ShardRouting> startedShards) {
5551
// noop
@@ -79,7 +75,7 @@ public static AllocationService createAllocationService(Settings settings) throw
7975

8076
public static AllocationService createAllocationService(Settings settings, ClusterSettings clusterSettings) throws
8177
InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
82-
return new AllocationService(settings,
78+
return new AllocationService(
8379
defaultAllocationDeciders(settings, clusterSettings),
8480
NoopGatewayAllocator.INSTANCE, new BalancedShardsAllocator(settings), EmptyClusterInfoService.INSTANCE);
8581
}
@@ -88,7 +84,7 @@ public static AllocationDeciders defaultAllocationDeciders(Settings settings, Cl
8884
IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException {
8985
Collection<AllocationDecider> deciders =
9086
ClusterModule.createAllocationDeciders(settings, clusterSettings, Collections.emptyList());
91-
return new AllocationDeciders(settings, deciders);
87+
return new AllocationDeciders(deciders);
9288

9389
}
9490

build.gradle

Lines changed: 27 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ if (properties.get("org.elasticsearch.acceptScanTOS", "false") == "true") {
3939
// common maven publishing configuration
4040
subprojects {
4141
group = 'org.elasticsearch'
42-
version = VersionProperties.elasticsearch.toString()
42+
version = VersionProperties.elasticsearch
4343
description = "Elasticsearch subproject ${project.path}"
4444
}
4545

@@ -103,10 +103,6 @@ subprojects {
103103
* in a branch if there are only betas and rcs in the branch so we have
104104
* *something* to test against. */
105105
VersionCollection versions = new VersionCollection(file('server/src/main/java/org/elasticsearch/Version.java').readLines('UTF-8'))
106-
if (versions.currentVersion != VersionProperties.elasticsearch) {
107-
throw new GradleException("The last version in Versions.java [${versions.currentVersion}] does not match " +
108-
"VersionProperties.elasticsearch [${VersionProperties.elasticsearch}]")
109-
}
110106

111107
// build metadata from previous build, contains eg hashes for bwc builds
112108
String buildMetadataValue = System.getenv('BUILD_METADATA')
@@ -140,26 +136,16 @@ task verifyVersions {
140136
if (gradle.startParameter.isOffline()) {
141137
throw new GradleException("Must run in online mode to verify versions")
142138
}
143-
// Read the list from maven central
144-
Node xml
139+
// Read the list from maven central.
140+
// Fetch the metadata an parse the xml into Version instances because it's more straight forward here
141+
// rather than bwcVersion ( VersionCollection ).
145142
new URL('https://repo1.maven.org/maven2/org/elasticsearch/elasticsearch/maven-metadata.xml').openStream().withStream { s ->
146-
xml = new XmlParser().parse(s)
147-
}
148-
Set<Version> knownVersions = new TreeSet<>(xml.versioning.versions.version.collect { it.text() }.findAll { it ==~ /\d+\.\d+\.\d+/ }.collect { Version.fromString(it) })
149-
150-
// Limit the known versions to those that should be index compatible, and are not future versions
151-
knownVersions = knownVersions.findAll { it.major >= bwcVersions.currentVersion.major - 1 && it.before(VersionProperties.elasticsearch) }
152-
153-
/* Limit the listed versions to those that have been marked as released.
154-
* Versions not marked as released don't get the same testing and we want
155-
* to make sure that we flip all unreleased versions to released as soon
156-
* as possible after release. */
157-
Set<Version> actualVersions = new TreeSet<>(bwcVersions.indexCompatible.findAll { false == it.snapshot })
158-
159-
// Finally, compare!
160-
if (knownVersions.equals(actualVersions) == false) {
161-
throw new GradleException("out-of-date released versions\nActual :" + actualVersions + "\nExpected:" + knownVersions +
162-
"\nUpdate Version.java. Note that Version.CURRENT doesn't count because it is not released.")
143+
bwcVersions.compareToAuthoritative(
144+
new XmlParser().parse(s)
145+
.versioning.versions.version
146+
.collect { it.text() }.findAll { it ==~ /\d+\.\d+\.\d+/ }
147+
.collect { Version.fromString(it) }
148+
)
163149
}
164150
}
165151
}
@@ -251,20 +237,17 @@ subprojects {
251237
"org.elasticsearch.plugin:percolator-client:${version}": ':modules:percolator',
252238
"org.elasticsearch.plugin:rank-eval-client:${version}": ':modules:rank-eval',
253239
]
254-
255-
bwcVersions.snapshotProjectNames.each { snapshotName ->
256-
Version snapshot = bwcVersions.getSnapshotForProject(snapshotName)
257-
if (snapshot != null ) {
258-
String snapshotProject = ":distribution:bwc:${snapshotName}"
259-
project(snapshotProject).ext.bwcVersion = snapshot
260-
ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${snapshot}"] = snapshotProject
261-
ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${snapshot}"] = snapshotProject
262-
ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${snapshot}"] = snapshotProject
263-
if (snapshot.onOrAfter('6.3.0')) {
264-
ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch-oss:${snapshot}"] = snapshotProject
265-
ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch-oss:${snapshot}"] = snapshotProject
266-
ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch-oss:${snapshot}"] = snapshotProject
267-
}
240+
// substitute unreleased versions with projects that check out and build locally
241+
bwcVersions.forPreviousUnreleased { VersionCollection.UnreleasedVersionInfo unreleasedVersion ->
242+
Version unreleased = unreleasedVersion.version
243+
String snapshotProject = ":distribution:bwc:${unreleasedVersion.gradleProjectName}"
244+
ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${unreleased}"] = snapshotProject
245+
ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${unreleased}"] = snapshotProject
246+
ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${unreleased}"] = snapshotProject
247+
if (unreleased.onOrAfter('6.3.0')) {
248+
ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch-oss:${unreleased}"] = snapshotProject
249+
ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch-oss:${unreleased}"] = snapshotProject
250+
ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch-oss:${unreleased}"] = snapshotProject
268251
}
269252
}
270253

@@ -299,7 +282,7 @@ subprojects {
299282
// other packages (e.g org.elasticsearch.client) will point to server rather than
300283
// their own artifacts.
301284
if (project.plugins.hasPlugin(BuildPlugin) || project.plugins.hasPlugin(PluginBuildPlugin)) {
302-
String artifactsHost = VersionProperties.elasticsearch.isSnapshot() ? "https://snapshots.elastic.co" : "https://artifacts.elastic.co"
285+
String artifactsHost = VersionProperties.elasticsearch.endsWith("-SNAPSHOT") ? "https://snapshots.elastic.co" : "https://artifacts.elastic.co"
303286
Closure sortClosure = { a, b -> b.group <=> a.group }
304287
Closure depJavadocClosure = { shadowed, dep ->
305288
if (dep.group == null || false == dep.group.startsWith('org.elasticsearch')) {
@@ -572,11 +555,13 @@ wrapper {
572555
}
573556
}
574557

575-
/* Remove assemble/dependenciesInfo on all qa projects because we don't need to publish
576-
* artifacts for them. */
577558
gradle.projectsEvaluated {
578559
subprojects {
579-
if (project.path.startsWith(':qa')) {
560+
/*
561+
* Remove assemble/dependenciesInfo on all qa projects because we don't
562+
* need to publish artifacts for them.
563+
*/
564+
if (project.name.equals('qa') || project.path.contains(':qa:')) {
580565
Task assemble = project.tasks.findByName('assemble')
581566
if (assemble) {
582567
assemble.enabled = false

buildSrc/build.gradle

Lines changed: 55 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -41,46 +41,33 @@ if (project == rootProject) {
4141
* Propagating version.properties to the rest of the build *
4242
*****************************************************************************/
4343

44-
Properties props = new Properties()
45-
props.load(project.file('version.properties').newDataInputStream())
46-
version = props.getProperty('elasticsearch')
47-
boolean snapshot = "true".equals(System.getProperty("build.snapshot", "true"));
48-
if (snapshot) {
49-
// we update the version property to reflect if we are building a snapshot or a release build
50-
// we write this back out below to load it in the Build.java which will be shown in rest main action
51-
// to indicate this being a snapshot build or a release build.
52-
version += "-SNAPSHOT"
53-
props.put("elasticsearch", version);
54-
}
55-
56-
File tempPropertiesFile = new File(project.buildDir, "version.properties")
57-
task writeVersionProperties {
58-
inputs.properties(props)
59-
outputs.file(tempPropertiesFile)
44+
// we update the version property to reflect if we are building a snapshot or a release build
45+
// we write this back out below to load it in the Build.java which will be shown in rest main action
46+
// to indicate this being a snapshot build or a release build.
47+
File propsFile = project.file('version.properties')
48+
Properties props = VersionPropertiesLoader.loadBuildSrcVersion(propsFile)
49+
version = props.getProperty("elasticsearch")
50+
processResources {
51+
inputs.file(propsFile)
52+
// We need to be explicit with the version because we add snapshot and qualifier to it based on properties
53+
inputs.property("dynamic_elasticsearch_version", props.getProperty("elasticsearch"))
6054
doLast {
61-
OutputStream stream = Files.newOutputStream(tempPropertiesFile.toPath());
55+
Writer writer = file("$destinationDir/version.properties").newWriter()
6256
try {
63-
props.store(stream, "UTF-8");
57+
props.store(writer, "Generated version properties")
6458
} finally {
65-
stream.close();
59+
writer.close()
6660
}
6761
}
6862
}
6963

70-
processResources {
71-
dependsOn writeVersionProperties
72-
from tempPropertiesFile
73-
}
74-
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-
8064
/*****************************************************************************
8165
* Java version *
8266
*****************************************************************************/
8367

68+
if (JavaVersion.current() < JavaVersion.VERSION_11) {
69+
throw new GradleException('At least Java 11 is required to build elasticsearch gradle tools')
70+
}
8471
// Gradle 4.10 does not support setting this to 11 yet
8572
targetCompatibility = "10"
8673
sourceCompatibility = "10"
@@ -232,3 +219,42 @@ if (project != rootProject) {
232219
generatePomFileForPluginMavenPublication.enabled = false
233220
}
234221
}
222+
223+
// Define this here because we need it early.
224+
class VersionPropertiesLoader {
225+
static Properties loadBuildSrcVersion(File input) throws IOException {
226+
Properties props = new Properties();
227+
InputStream is = new FileInputStream(input)
228+
try {
229+
props.load(is)
230+
} finally {
231+
is.close()
232+
}
233+
loadBuildSrcVersion(props, System.getProperties())
234+
return props
235+
}
236+
237+
protected static void loadBuildSrcVersion(Properties loadedProps, Properties systemProperties) {
238+
String elasticsearch = loadedProps.getProperty("elasticsearch")
239+
if (elasticsearch == null) {
240+
throw new IllegalStateException("Elasticsearch version is missing from properties.")
241+
}
242+
if (elasticsearch.matches("[0-9]+\\.[0-9]+\\.[0-9]+") == false) {
243+
throw new IllegalStateException(
244+
"Expected elasticsearch version to be numbers only of the form X.Y.Z but it was: " +
245+
elasticsearch
246+
)
247+
}
248+
String qualifier = systemProperties.getProperty("build.version_qualifier", "alpha1");
249+
if (qualifier.isEmpty() == false) {
250+
if (qualifier.matches("(alpha|beta|rc)\\d+") == false) {
251+
throw new IllegalStateException("Invalid qualifier: " + qualifier)
252+
}
253+
elasticsearch += "-" + qualifier
254+
}
255+
if ("true".equals(systemProperties.getProperty("build.snapshot", "true"))) {
256+
elasticsearch += "-SNAPSHOT"
257+
}
258+
loadedProps.put("elasticsearch", elasticsearch)
259+
}
260+
}

0 commit comments

Comments
 (0)