Skip to content

Commit 305083b

Browse files
committed
Merge remote-tracking branch 'es/6.x' into ccr-6.x
* es/6.x: Fix building Javadoc JARs on JDK for client JARs (#29274) Require JDK 10 to build Elasticsearch (#29174) Decouple NamedXContentRegistry from ElasticsearchException (#29253) Docs: Update generating test coverage reports (#29255) [TEST] Fix issue with HttpInfo passed invalid parameter Remove all dependencies from XContentBuilder (#29225) Fix sporadic failure in CompositeValuesCollectorQueueTests Propagate ignore_unmapped to inner_hits (#29261) TEST: Increase timeout for testPrimaryReplicaResyncFailed REST client: hosts marked dead for the first time should not be immediately retried (#29230) Make SearchStats implement Writeable (#29258) [Docs] Spelling and grammar changes to reindex.asciidoc (#29232) [test] packaging: gradle tasks for groovy tests (#29046) remove testUnassignedShardAndEmptyNodesInRoutingTable Add file permissions checks to precommit task Remove execute mode bit from source files #28745: remove 7.x option in the composite rest tests. Optimize the composite aggregation for match_all and range queries (#28745) Clarify deprecation warning for auto_generate_phrase_query (#29204)
2 parents bda5983 + eba9e76 commit 305083b

File tree

130 files changed

+3236
-1627
lines changed

Some content is hidden

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

130 files changed

+3236
-1627
lines changed

CONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ Contributing to the Elasticsearch codebase
9292

9393
**Repository:** [https://github.com/elastic/elasticsearch](https://github.com/elastic/elasticsearch)
9494

95-
JDK 9 is required to build Elasticsearch. You must have a JDK 9 installation
95+
JDK 10 is required to build Elasticsearch. You must have a JDK 10 installation
9696
with the environment variable `JAVA_HOME` referencing the path to Java home for
97-
your JDK 9 installation. By default, tests use the same runtime as `JAVA_HOME`.
97+
your JDK 10 installation. By default, tests use the same runtime as `JAVA_HOME`.
9898
However, since Elasticsearch, supports JDK 8 the build supports compiling with
99-
JDK 9 and testing on a JDK 8 runtime; to do this, set `RUNTIME_JAVA_HOME`
99+
JDK 10 and testing on a JDK 8 runtime; to do this, set `RUNTIME_JAVA_HOME`
100100
pointing to the Java home of a JDK 8 installation. Note that this mechanism can
101101
be used to test against other JDKs as well, this is not only limited to JDK 8.
102102

TESTING.asciidoc

+13-24
Original file line numberDiff line numberDiff line change
@@ -414,16 +414,16 @@ and in another window:
414414

415415
----------------------------------------------------
416416
vagrant up centos-7 --provider virtualbox && vagrant ssh centos-7
417-
cd $BATS_ARCHIVES
417+
cd $PACKAGING_ARCHIVES
418418
sudo -E bats $BATS_TESTS/*rpm*.bats
419419
----------------------------------------------------
420420

421421
If you wanted to retest all the release artifacts on a single VM you could:
422422

423423
-------------------------------------------------
424-
./gradlew setupBats
424+
./gradlew setupPackagingTest
425425
cd qa/vagrant; vagrant up ubuntu-1404 --provider virtualbox && vagrant ssh ubuntu-1404
426-
cd $BATS_ARCHIVES
426+
cd $PACKAGING_ARCHIVES
427427
sudo -E bats $BATS_TESTS/*.bats
428428
-------------------------------------------------
429429

@@ -499,32 +499,21 @@ will contain your change.
499499
. Push both branches to your remote repository.
500500
. Run the tests with `./gradlew check -Dtests.bwc.remote=${remote} -Dtests.bwc.refspec=index_req_bwc_5.x`.
501501

502-
== Coverage analysis
502+
== Test coverage analysis
503503

504-
Tests can be run instrumented with jacoco to produce a coverage report in
505-
`target/site/jacoco/`.
504+
Generating test coverage reports for Elasticsearch is currently not possible through Gradle.
505+
However, it _is_ possible to gain insight in code coverage using IntelliJ's built-in coverage
506+
analysis tool that can measure coverage upon executing specific tests. Eclipse may also be able
507+
to do the same using the EclEmma plugin.
506508

507-
Unit test coverage:
508-
509-
---------------------------------------------------------------------------
510-
mvn -Dtests.coverage test jacoco:report
511-
---------------------------------------------------------------------------
512-
513-
Integration test coverage:
514-
515-
---------------------------------------------------------------------------
516-
mvn -Dtests.coverage -Dskip.unit.tests verify jacoco:report
517-
---------------------------------------------------------------------------
518-
519-
Combined (Unit+Integration) coverage:
520-
521-
---------------------------------------------------------------------------
522-
mvn -Dtests.coverage verify jacoco:report
523-
---------------------------------------------------------------------------
509+
Test coverage reporting used to be possible with JaCoCo when Elasticsearch was using Maven
510+
as its build system. Since the switch to Gradle though, this is no longer possible, seeing as
511+
the code currently used to build Elasticsearch does not allow JaCoCo to recognize its tests.
512+
For more information on this, see the discussion in https://github.com/elastic/elasticsearch/issues/28867[issue #28867].
524513

525514
== Launching and debugging from an IDE
526515

527-
If you want to run elasticsearch from your IDE, the `./gradlew run` task
516+
If you want to run Elasticsearch from your IDE, the `./gradlew run` task
528517
supports a remote debugging option:
529518

530519
---------------------------------------------------------------------------

Vagrantfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,9 @@ export TAR=/elasticsearch/distribution/tar/build/distributions
334334
export RPM=/elasticsearch/distribution/rpm/build/distributions
335335
export DEB=/elasticsearch/distribution/deb/build/distributions
336336
export BATS=/project/build/bats
337-
export BATS_UTILS=/project/build/bats/utils
338-
export BATS_TESTS=/project/build/bats/tests
339-
export BATS_ARCHIVES=/project/build/bats/archives
337+
export BATS_UTILS=/project/build/packaging/bats/utils
338+
export BATS_TESTS=/project/build/packaging/bats/tests
339+
export PACKAGING_ARCHIVES=/project/build/packaging/archives
340340
VARS
341341
cat \<\<SUDOERS_VARS > /etc/sudoers.d/elasticsearch_vars
342342
Defaults env_keep += "ZIP"
@@ -346,7 +346,7 @@ Defaults env_keep += "DEB"
346346
Defaults env_keep += "BATS"
347347
Defaults env_keep += "BATS_UTILS"
348348
Defaults env_keep += "BATS_TESTS"
349-
Defaults env_keep += "BATS_ARCHIVES"
349+
Defaults env_keep += "PACKAGING_ARCHIVES"
350350
SUDOERS_VARS
351351
chmod 0440 /etc/sudoers.d/elasticsearch_vars
352352
SHELL

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import java.time.ZonedDateTime
5858
class BuildPlugin implements Plugin<Project> {
5959

6060
static final JavaVersion minimumRuntimeVersion = JavaVersion.VERSION_1_8
61-
static final JavaVersion minimumCompilerVersion = JavaVersion.VERSION_1_9
61+
static final JavaVersion minimumCompilerVersion = JavaVersion.VERSION_1_10
6262

6363
@Override
6464
void apply(Project project) {

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

+4-6
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,10 @@ public class PluginBuildPlugin extends BuildPlugin {
168168
Files.copy(jarFile.resolveSibling(sourcesFileName), jarFile.resolveSibling(clientSourcesFileName),
169169
StandardCopyOption.REPLACE_EXISTING)
170170

171-
if (project.compilerJavaVersion < JavaVersion.VERSION_1_10) {
172-
String javadocFileName = jarFile.fileName.toString().replace('.jar', '-javadoc.jar')
173-
String clientJavadocFileName = clientFileName.replace('.jar', '-javadoc.jar')
174-
Files.copy(jarFile.resolveSibling(javadocFileName), jarFile.resolveSibling(clientJavadocFileName),
175-
StandardCopyOption.REPLACE_EXISTING)
176-
}
171+
String javadocFileName = jarFile.fileName.toString().replace('.jar', '-javadoc.jar')
172+
String clientJavadocFileName = clientFileName.replace('.jar', '-javadoc.jar')
173+
Files.copy(jarFile.resolveSibling(javadocFileName), jarFile.resolveSibling(clientJavadocFileName),
174+
StandardCopyOption.REPLACE_EXISTING)
177175
}
178176
project.assemble.dependsOn(clientJar)
179177
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.elasticsearch.gradle.precommit
20+
21+
import org.gradle.api.DefaultTask
22+
import org.gradle.api.GradleException
23+
import org.gradle.api.file.FileCollection
24+
import org.gradle.api.tasks.InputFiles
25+
import org.gradle.api.tasks.OutputFile
26+
import org.gradle.api.tasks.SourceSet
27+
import org.gradle.api.tasks.TaskAction
28+
import org.gradle.api.tasks.util.PatternSet
29+
import org.gradle.api.tasks.util.PatternFilterable
30+
import org.apache.tools.ant.taskdefs.condition.Os
31+
32+
import java.nio.file.Files
33+
import java.nio.file.attribute.PosixFilePermission
34+
import java.nio.file.attribute.PosixFileAttributeView
35+
36+
import static java.nio.file.attribute.PosixFilePermission.OTHERS_EXECUTE
37+
import static java.nio.file.attribute.PosixFilePermission.GROUP_EXECUTE
38+
import static java.nio.file.attribute.PosixFilePermission.OWNER_EXECUTE
39+
40+
/**
41+
* Checks source files for correct file permissions.
42+
*/
43+
public class FilePermissionsTask extends DefaultTask {
44+
45+
/** A pattern set of which files should be checked. */
46+
private PatternFilterable filesFilter = new PatternSet()
47+
48+
@OutputFile
49+
File outputMarker = new File(project.buildDir, 'markers/filePermissions')
50+
51+
FilePermissionsTask() {
52+
onlyIf { !Os.isFamily(Os.FAMILY_WINDOWS) }
53+
description = "Checks java source files for correct file permissions"
54+
// we always include all source files, and exclude what should not be checked
55+
filesFilter.include('**')
56+
// exclude sh files that might have the executable bit set
57+
filesFilter.exclude('**/*.sh')
58+
}
59+
60+
/** Returns the files this task will check */
61+
@InputFiles
62+
FileCollection files() {
63+
List<FileCollection> collections = new ArrayList<>()
64+
for (SourceSet sourceSet : project.sourceSets) {
65+
collections.add(sourceSet.allSource.matching(filesFilter))
66+
}
67+
return project.files(collections.toArray())
68+
}
69+
70+
@TaskAction
71+
void checkInvalidPermissions() {
72+
List<String> failures = new ArrayList<>()
73+
for (File f : files()) {
74+
PosixFileAttributeView fileAttributeView = Files.getFileAttributeView(f.toPath(), PosixFileAttributeView.class)
75+
Set<PosixFilePermission> permissions = fileAttributeView.readAttributes().permissions()
76+
if (permissions.contains(OTHERS_EXECUTE) || permissions.contains(OWNER_EXECUTE) ||
77+
permissions.contains(GROUP_EXECUTE)) {
78+
failures.add("Source file is executable: " + f)
79+
}
80+
}
81+
if (failures.isEmpty() == false) {
82+
throw new GradleException('Found invalid file permissions:\n' + failures.join('\n'))
83+
}
84+
outputMarker.setText('done', 'UTF-8')
85+
}
86+
87+
}

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

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class PrecommitTasks {
3737
configureNamingConventions(project),
3838
project.tasks.create('forbiddenPatterns', ForbiddenPatternsTask.class),
3939
project.tasks.create('licenseHeaders', LicenseHeadersTask.class),
40+
project.tasks.create('filepermissions', FilePermissionsTask.class),
4041
project.tasks.create('jarHell', JarHellTask.class),
4142
project.tasks.create('thirdPartyAudit', ThirdPartyAuditTask.class)]
4243

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantPropertiesExtension.groovy

-7
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ class VagrantPropertiesExtension {
3737
@Input
3838
Boolean inheritTests
3939

40-
@Input
41-
Boolean inheritTestArchives
42-
4340
@Input
4441
Boolean inheritTestUtils
4542

@@ -60,10 +57,6 @@ class VagrantPropertiesExtension {
6057
this.inheritTests = inheritTests
6158
}
6259

63-
void setInheritTestArchives(Boolean inheritTestArchives) {
64-
this.inheritTestArchives = inheritTestArchives
65-
}
66-
6760
void setInheritTestUtils(Boolean inheritTestUtils) {
6861
this.inheritTestUtils = inheritTestUtils
6962
}

0 commit comments

Comments
 (0)