Skip to content

Commit 8e245a3

Browse files
committed
Merge branch '6.x' into ccr-6.x
* 6.x: Docs: Remove duplicate test setup Docs: Fix description of percentile ranks example example (#31652) Remove deprecation warnings to prepare for Gradle 5 (sourceSets.main.output.classesDirs) (#30389) Do not check for Azure container existence (#31617) Merge AwsS3Service and InternalAwsS3Service in a S3Service class (#31580) Remove item listed in 6.3 notes that's not in 6.3 (#31623) remove unused import Upgrade gradle wrapper to 4.8 (#31525) Only set vm.max_map_count if greater than default (#31512) QA: Merge query-builder-bwc to restart test (#30979) Docs: Skip xpack snippet tests if no xpack (#31619) [TEST] Fix RemoteClusterConnectionTests Remove legacy MetaDataStateFormat (#31603) [TEST] call yaml client close method from test suite (#31591) [TEST] Close additional clients created while running yaml tests (#31575) Node selector per client rather than per request (#31471) Preserve thread context when connecting to remote cluster (#31574) Remove redundant 'minimum_should_match' Unify headers for full text queries JDBC driver prepared statement set* methods (#31494) add logging breaking changes from 5.3 to 6.0 (#31583) Fix a formatting issue in the docvalue_fields documentation. (#31563) Improve robustness of geo shape parser for malformed shapes QA: Create xpack yaml features (#31403)
2 parents e258970 + 840b768 commit 8e245a3

File tree

217 files changed

+2356
-1160
lines changed

Some content is hidden

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

217 files changed

+2356
-1160
lines changed

benchmarks/build.gradle

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ buildscript {
2929
}
3030

3131
apply plugin: 'elasticsearch.build'
32-
// build an uberjar with all benchmarks
33-
apply plugin: 'com.github.johnrengelman.shadow'
34-
// have the shadow plugin provide the runShadow task
35-
apply plugin: 'application'
32+
33+
// order of this section matters, see: https://github.com/johnrengelman/shadow/issues/336
34+
apply plugin: 'application' // have the shadow plugin provide the runShadow task
35+
mainClassName = 'org.openjdk.jmh.Main'
36+
apply plugin: 'com.github.johnrengelman.shadow' // build an uberjar with all benchmarks
3637

3738
// Not published so no need to assemble
3839
tasks.remove(assemble)

build.gradle

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,9 @@ gradle.projectsEvaluated {
320320
// :test:framework:test cannot run before and after :server:test
321321
return
322322
}
323+
if (tasks.findByPath('test') != null && tasks.findByPath('integTest') != null) {
324+
integTest.mustRunAfter test
325+
}
323326
configurations.all { Configuration configuration ->
324327
/*
325328
* The featureAwarePlugin configuration has a dependency on x-pack:plugin:core and x-pack:plugin:core has a dependency on the
@@ -569,3 +572,28 @@ gradle.projectsEvaluated {
569572
}
570573
}
571574
}
575+
576+
if (System.properties.get("build.compare") != null) {
577+
apply plugin: 'compare-gradle-builds'
578+
compareGradleBuilds {
579+
ext.referenceProject = System.properties.get("build.compare")
580+
doFirst {
581+
if (file(referenceProject).exists() == false) {
582+
throw new GradleException(
583+
"Use git worktree to check out a version to compare against to ../elasticsearch_build_reference"
584+
)
585+
}
586+
}
587+
sourceBuild {
588+
gradleVersion = "4.7" // does not default to gradle weapper of project dir, but current version
589+
projectDir = referenceProject
590+
tasks = ["clean", "assemble"]
591+
arguments = ["-Dbuild.compare_friendly=true"]
592+
}
593+
targetBuild {
594+
tasks = ["clean", "assemble"]
595+
// use -Dorg.gradle.java.home= to alter jdk versions
596+
arguments = ["-Dbuild.compare_friendly=true"]
597+
}
598+
}
599+
}

buildSrc/build.gradle

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
* under the License.
1818
*/
1919

20-
import java.nio.file.Files
2120

22-
import org.gradle.util.GradleVersion
21+
import java.nio.file.Files
2322

24-
apply plugin: 'groovy'
23+
plugins {
24+
id 'java-gradle-plugin'
25+
id 'groovy'
26+
}
2527

2628
group = 'org.elasticsearch.gradle'
2729

@@ -83,9 +85,10 @@ repositories {
8385
}
8486

8587
dependencies {
86-
compile gradleApi()
8788
compile localGroovy()
8889
compile "com.carrotsearch.randomizedtesting:junit4-ant:${props.getProperty('randomizedrunner')}"
90+
compile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${props.getProperty('randomizedrunner')}"
91+
8992
compile("junit:junit:${props.getProperty('junit')}") {
9093
transitive = false
9194
}
@@ -97,31 +100,30 @@ dependencies {
97100
compile 'de.thetaphi:forbiddenapis:2.5'
98101
compile 'org.apache.rat:apache-rat:0.11'
99102
compile "org.elasticsearch:jna:4.5.1"
103+
testCompile "junit:junit:${props.getProperty('junit')}"
100104
}
101105

106+
102107
// Gradle 2.14+ removed ProgressLogger(-Factory) classes from the public APIs
103108
// Use logging dependency instead
104109
// Gradle 4.3.1 stopped releasing the logging jars to jcenter, just use the last available one
105110
GradleVersion logVersion = GradleVersion.current() > GradleVersion.version('4.3') ? GradleVersion.version('4.3') : GradleVersion.current()
106111

107112
dependencies {
108113
compileOnly "org.gradle:gradle-logging:${logVersion.getVersion()}"
109-
compile 'ru.vyarus:gradle-animalsniffer-plugin:1.2.0' // Gradle 2.14 requires a version > 1.0.1
110114
}
111115

112116
/*****************************************************************************
113117
* Bootstrap repositories *
114118
*****************************************************************************/
115119
// this will only happen when buildSrc is built on its own during build init
116120
if (project == rootProject) {
117-
118121
repositories {
119122
if (System.getProperty("repos.mavenLocal") != null) {
120123
mavenLocal()
121124
}
122125
mavenCentral()
123126
}
124-
test.exclude 'org/elasticsearch/test/NamingConventionsCheckBadClasses*'
125127
}
126128

127129
/*****************************************************************************
@@ -146,9 +148,6 @@ if (project != rootProject) {
146148
jarHell.enabled = false
147149
thirdPartyAudit.enabled = false
148150

149-
// test for elasticsearch.build tries to run with ES...
150-
test.enabled = false
151-
152151
// TODO: re-enable once randomizedtesting gradle code is published and removed from here
153152
licenseHeaders.enabled = false
154153

@@ -159,14 +158,7 @@ if (project != rootProject) {
159158
}
160159

161160
namingConventions {
162-
testClass = 'org.elasticsearch.test.NamingConventionsCheckBadClasses$UnitTestCase'
163-
integTestClass = 'org.elasticsearch.test.NamingConventionsCheckBadClasses$IntegTestCase'
164-
}
165-
166-
task namingConventionsMain(type: org.elasticsearch.gradle.precommit.NamingConventionsTask) {
167-
checkForTestsInMain = true
168-
testClass = namingConventions.testClass
169-
integTestClass = namingConventions.integTestClass
161+
testClass = 'org.elasticsearch.gradle.test.GradleUnitTestCase'
162+
integTestClass = 'org.elasticsearch.gradle.test.GradleIntegrationTestCase'
170163
}
171-
precommit.dependsOn namingConventionsMain
172164
}

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

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,44 @@
11
package com.carrotsearch.gradle.junit4
22

33
import com.carrotsearch.ant.tasks.junit4.JUnit4
4-
import org.gradle.api.AntBuilder
4+
import org.gradle.api.GradleException
55
import org.gradle.api.Plugin
66
import org.gradle.api.Project
77
import org.gradle.api.Task
8+
import org.gradle.api.UnknownTaskException
89
import org.gradle.api.plugins.JavaBasePlugin
910
import org.gradle.api.tasks.TaskContainer
11+
import org.gradle.api.tasks.TaskProvider
1012
import org.gradle.api.tasks.testing.Test
1113

14+
import java.util.concurrent.atomic.AtomicBoolean
15+
1216
class RandomizedTestingPlugin implements Plugin<Project> {
1317

18+
static private AtomicBoolean sanityCheckConfigured = new AtomicBoolean(false)
19+
1420
void apply(Project project) {
1521
setupSeed(project)
1622
replaceTestTask(project.tasks)
1723
configureAnt(project.ant)
24+
configureSanityCheck(project)
25+
}
26+
27+
private static void configureSanityCheck(Project project) {
28+
// Check the task graph to confirm tasks were indeed replaced
29+
// https://github.com/elastic/elasticsearch/issues/31324
30+
if (sanityCheckConfigured.getAndSet(true) == false) {
31+
project.rootProject.getGradle().getTaskGraph().whenReady {
32+
List<Task> nonConforming = project.getGradle().getTaskGraph().allTasks
33+
.findAll { it.name == "test" }
34+
.findAll { (it instanceof RandomizedTestingTask) == false}
35+
.collect { "${it.path} -> ${it.class}" }
36+
if (nonConforming.isEmpty() == false) {
37+
throw new GradleException("Found the ${nonConforming.size()} `test` tasks:" +
38+
"\n ${nonConforming.join("\n ")}")
39+
}
40+
}
41+
}
1842
}
1943

2044
/**
@@ -45,29 +69,32 @@ class RandomizedTestingPlugin implements Plugin<Project> {
4569
}
4670

4771
static void replaceTestTask(TaskContainer tasks) {
48-
Test oldTestTask = tasks.findByPath('test')
49-
if (oldTestTask == null) {
72+
// Gradle 4.8 introduced lazy tasks, thus we deal both with the `test` task as well as it's provider
73+
// https://github.com/gradle/gradle/issues/5730#issuecomment-398822153
74+
// since we can't be sure if the task was ever realized, we remove both the provider and the task
75+
TaskProvider<Test> oldTestProvider
76+
try {
77+
oldTestProvider = tasks.getByNameLater(Test, 'test')
78+
} catch (UnknownTaskException unused) {
5079
// no test task, ok, user will use testing task on their own
5180
return
5281
}
53-
tasks.remove(oldTestTask)
82+
Test oldTestTask = oldTestProvider.get()
5483

55-
Map properties = [
56-
name: 'test',
57-
type: RandomizedTestingTask,
58-
dependsOn: oldTestTask.dependsOn,
59-
group: JavaBasePlugin.VERIFICATION_GROUP,
60-
description: 'Runs unit tests with the randomized testing framework'
61-
]
62-
RandomizedTestingTask newTestTask = tasks.create(properties)
63-
newTestTask.classpath = oldTestTask.classpath
64-
newTestTask.testClassesDir = oldTestTask.project.sourceSets.test.output.classesDir
65-
// since gradle 4.5, tasks immutable dependencies are "hidden" (do not show up in dependsOn)
66-
// so we must explicitly add a dependency on generating the test classpath
67-
newTestTask.dependsOn('testClasses')
84+
// we still have to use replace here despite the remove above because the task container knows about the provider
85+
// by the same name
86+
RandomizedTestingTask newTestTask = tasks.replace('test', RandomizedTestingTask)
87+
newTestTask.configure{
88+
group = JavaBasePlugin.VERIFICATION_GROUP
89+
description = 'Runs unit tests with the randomized testing framework'
90+
dependsOn oldTestTask.dependsOn, 'testClasses'
91+
classpath = oldTestTask.classpath
92+
testClassesDirs = oldTestTask.project.sourceSets.test.output.classesDirs
93+
}
6894

6995
// hack so check task depends on custom test
70-
Task checkTask = tasks.findByPath('check')
96+
Task checkTask = tasks.getByName('check')
97+
checkTask.dependsOn.remove(oldTestProvider)
7198
checkTask.dependsOn.remove(oldTestTask)
7299
checkTask.dependsOn.add(newTestTask)
73100
}

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@ import groovy.xml.NamespaceBuilder
66
import groovy.xml.NamespaceBuilderSupport
77
import org.apache.tools.ant.BuildException
88
import org.apache.tools.ant.DefaultLogger
9+
import org.apache.tools.ant.Project
910
import org.apache.tools.ant.RuntimeConfigurable
1011
import org.apache.tools.ant.UnknownElement
12+
import org.elasticsearch.gradle.BuildPlugin
1113
import org.gradle.api.DefaultTask
1214
import org.gradle.api.InvalidUserDataException
1315
import org.gradle.api.file.FileCollection
1416
import org.gradle.api.file.FileTreeElement
15-
import org.gradle.api.internal.tasks.options.Option
1617
import org.gradle.api.specs.Spec
1718
import org.gradle.api.tasks.Input
1819
import org.gradle.api.tasks.InputDirectory
1920
import org.gradle.api.tasks.Optional
2021
import org.gradle.api.tasks.TaskAction
22+
import org.gradle.api.tasks.options.Option
2123
import org.gradle.api.tasks.util.PatternFilterable
2224
import org.gradle.api.tasks.util.PatternSet
2325
import org.gradle.internal.logging.progress.ProgressLoggerFactory
@@ -43,8 +45,8 @@ class RandomizedTestingTask extends DefaultTask {
4345
@Input
4446
String parallelism = '1'
4547

46-
@InputDirectory
47-
File testClassesDir
48+
@Input
49+
FileCollection testClassesDirs
4850

4951
@Optional
5052
@Input
@@ -220,15 +222,15 @@ class RandomizedTestingTask extends DefaultTask {
220222
listener = new DefaultLogger(
221223
errorPrintStream: System.err,
222224
outputPrintStream: System.out,
223-
messageOutputLevel: org.apache.tools.ant.Project.MSG_INFO)
225+
messageOutputLevel: Project.MSG_INFO)
224226
} else {
225227
// we want to buffer the info, and emit it if the test fails
226228
antLoggingBuffer = new ByteArrayOutputStream()
227229
PrintStream stream = new PrintStream(antLoggingBuffer, true, "UTF-8")
228230
listener = new DefaultLogger(
229231
errorPrintStream: stream,
230232
outputPrintStream: stream,
231-
messageOutputLevel: org.apache.tools.ant.Project.MSG_INFO)
233+
messageOutputLevel: Project.MSG_INFO)
232234
}
233235
project.ant.project.addBuildListener(listener)
234236
}
@@ -251,12 +253,10 @@ class RandomizedTestingTask extends DefaultTask {
251253
if (argLine != null) {
252254
jvmarg(line: argLine)
253255
}
254-
fileset(dir: testClassesDir) {
255-
for (String includePattern : patternSet.getIncludes()) {
256-
include(name: includePattern)
257-
}
258-
for (String excludePattern : patternSet.getExcludes()) {
259-
exclude(name: excludePattern)
256+
testClassesDirs.each { testClassDir ->
257+
fileset(dir: testClassDir) {
258+
patternSet.getIncludes().each { include(name: it) }
259+
patternSet.getExcludes().each { exclude(name: it) }
260260
}
261261
}
262262
for (Map.Entry<String, Object> prop : systemProperties) {

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

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,9 @@ class BuildPlugin implements Plugin<Project> {
348348
// just a self contained test-fixture configuration, likely transitive and hellacious
349349
return
350350
}
351-
configuration.resolutionStrategy.failOnVersionConflict()
351+
configuration.resolutionStrategy {
352+
failOnVersionConflict()
353+
}
352354
})
353355

354356
// force all dependencies added directly to compile/testCompile to be non-transitive, except for ES itself
@@ -475,13 +477,17 @@ class BuildPlugin implements Plugin<Project> {
475477
}
476478
}
477479

478-
project.tasks.withType(GenerateMavenPom.class) { GenerateMavenPom t ->
479-
// place the pom next to the jar it is for
480-
t.destination = new File(project.buildDir, "distributions/${project.archivesBaseName}-${project.version}.pom")
481-
// build poms with assemble (if the assemble task exists)
482-
Task assemble = project.tasks.findByName('assemble')
483-
if (assemble) {
484-
assemble.dependsOn(t)
480+
// Work around Gradle 4.8 issue until we `enableFeaturePreview('STABLE_PUBLISHING')`
481+
// https://github.com/gradle/gradle/issues/5696#issuecomment-396965185
482+
project.getGradle().getTaskGraph().whenReady {
483+
project.tasks.withType(GenerateMavenPom.class) { GenerateMavenPom t ->
484+
// place the pom next to the jar it is for
485+
t.destination = new File(project.buildDir, "distributions/${project.archivesBaseName}-${project.version}.pom")
486+
// build poms with assemble (if the assemble task exists)
487+
Task assemble = project.tasks.findByName('assemble')
488+
if (assemble) {
489+
assemble.dependsOn(t)
490+
}
485491
}
486492
}
487493
}
@@ -625,6 +631,10 @@ class BuildPlugin implements Plugin<Project> {
625631
jarTask.manifest.attributes('Change': shortHash)
626632
}
627633
}
634+
// Force manifest entries that change by nature to a constant to be able to compare builds more effectively
635+
if (System.properties.getProperty("build.compare_friendly", "false") == "true") {
636+
jarTask.manifest.getAttributes().clear()
637+
}
628638
}
629639
// add license/notice files
630640
project.afterEvaluate {
@@ -741,7 +751,7 @@ class BuildPlugin implements Plugin<Project> {
741751
project.extensions.add('additionalTest', { String name, Closure config ->
742752
RandomizedTestingTask additionalTest = project.tasks.create(name, RandomizedTestingTask.class)
743753
additionalTest.classpath = test.classpath
744-
additionalTest.testClassesDir = test.testClassesDir
754+
additionalTest.testClassesDirs = test.testClassesDirs
745755
additionalTest.configure(commonTestConfig(project))
746756
additionalTest.configure(config)
747757
test.dependsOn(additionalTest)

0 commit comments

Comments
 (0)