Skip to content

Commit e869b60

Browse files
Merge branch 'master' into feature-ml-data-frame-analytics
2 parents 9bb2a02 + d21df2a commit e869b60

File tree

2,563 files changed

+66842
-28834
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,563 files changed

+66842
-28834
lines changed

.ci/matrix-build-javas.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77

88
ES_BUILD_JAVA:
99
- java11
10+
- openjdk12

.ci/matrix-runtime-javas.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ ES_RUNTIME_JAVA:
99
- java8
1010
- java8fips
1111
- java11
12+
- openjdk12
1213
- zulu8
1314
- zulu11

benchmarks/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ mainClassName = 'org.openjdk.jmh.Main'
2424
assemble.enabled = false
2525
archivesBaseName = 'elasticsearch-benchmarks'
2626

27-
test.enabled = false
27+
unitTest.enabled = false
2828

2929
dependencies {
3030
compile("org.elasticsearch:elasticsearch:${version}") {
@@ -53,7 +53,7 @@ forbiddenApisMain.enabled = false
5353
dependencyLicenses.enabled = false
5454
dependenciesInfo.enabled = false
5555

56-
thirdPartyAudit.excludes = [
56+
thirdPartyAudit.ignoreViolations (
5757
// these classes intentionally use JDK internal API (and this is ok since the project is maintained by Oracle employees)
5858
'org.openjdk.jmh.profile.AbstractHotspotProfiler',
5959
'org.openjdk.jmh.profile.HotspotThreadProfiler',
@@ -62,4 +62,4 @@ thirdPartyAudit.excludes = [
6262
'org.openjdk.jmh.profile.HotspotMemoryProfiler',
6363
'org.openjdk.jmh.profile.HotspotRuntimeProfiler',
6464
'org.openjdk.jmh.util.Utils'
65-
]
65+
)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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.benchmark.time;
20+
21+
import org.elasticsearch.common.joda.Joda;
22+
import org.elasticsearch.common.time.DateFormatter;
23+
import org.openjdk.jmh.annotations.Benchmark;
24+
import org.openjdk.jmh.annotations.BenchmarkMode;
25+
import org.openjdk.jmh.annotations.Fork;
26+
import org.openjdk.jmh.annotations.Measurement;
27+
import org.openjdk.jmh.annotations.Mode;
28+
import org.openjdk.jmh.annotations.OutputTimeUnit;
29+
import org.openjdk.jmh.annotations.Scope;
30+
import org.openjdk.jmh.annotations.State;
31+
import org.openjdk.jmh.annotations.Warmup;
32+
33+
import java.time.temporal.TemporalAccessor;
34+
import java.util.concurrent.TimeUnit;
35+
36+
@Fork(3)
37+
@Warmup(iterations = 10)
38+
@Measurement(iterations = 10)
39+
@BenchmarkMode(Mode.AverageTime)
40+
@OutputTimeUnit(TimeUnit.NANOSECONDS)
41+
@State(Scope.Benchmark)
42+
@SuppressWarnings("unused") //invoked by benchmarking framework
43+
public class DateFormatterBenchmark {
44+
45+
private final DateFormatter javaFormatter = DateFormatter.forPattern("8year_month_day||ordinal_date||epoch_millis");
46+
private final DateFormatter jodaFormatter = Joda.forPattern("year_month_day||ordinal_date||epoch_millis");
47+
48+
@Benchmark
49+
public TemporalAccessor parseJavaDate() {
50+
return javaFormatter.parse("1234567890");
51+
}
52+
53+
@Benchmark
54+
public TemporalAccessor parseJodaDate() {
55+
return jodaFormatter.parse("1234567890");
56+
}
57+
}
58+

build.gradle

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,9 @@ import org.elasticsearch.gradle.Version
2424
import org.elasticsearch.gradle.VersionCollection
2525
import org.elasticsearch.gradle.VersionProperties
2626
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
27-
import org.gradle.api.tasks.options.Option
28-
import org.gradle.util.GradleVersion
29-
import org.gradle.util.DistributionLocator
27+
import org.gradle.util.GradleVersion
28+
import org.gradle.util.DistributionLocator
3029
import org.gradle.plugins.ide.eclipse.model.SourceFolder
31-
import com.carrotsearch.gradle.junit4.RandomizedTestingTask
32-
33-
import java.util.function.Predicate
3430

3531
plugins {
3632
id 'com.gradle.build-scan' version '2.0.2'
@@ -433,7 +429,7 @@ tasks.idea.doLast {
433429
ideaMarker.setText('', 'UTF-8')
434430
}
435431
if (System.getProperty('idea.active') != null && ideaMarker.exists() == false) {
436-
throw new GradleException('You must run gradle idea from the root of elasticsearch before importing into IntelliJ')
432+
throw new GradleException('You must run `./gradlew idea` from the root of elasticsearch before importing into IntelliJ')
437433
}
438434

439435
// eclipse configuration

buildSrc/build.gradle

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
import java.nio.file.Files
2019
import org.gradle.util.GradleVersion
2120

2221
plugins {
@@ -179,9 +178,7 @@ if (project != rootProject) {
179178
jarHell.enabled = false
180179
thirdPartyAudit.enabled = false
181180

182-
test {
183-
include "**/*Tests.class"
184-
exclude "**/*IT.class"
181+
unitTest {
185182
// The test task is configured to runtimeJava version, but build-tools doesn't support all of them, so test
186183
// with compiler instead on the ones that are too old.
187184
if (project.runtimeJavaVersion <= JavaVersion.VERSION_1_10) {
@@ -226,6 +223,18 @@ if (project != rootProject) {
226223
integTestClass = 'org.elasticsearch.gradle.test.GradleIntegrationTestCase'
227224
}
228225

226+
testingConventions {
227+
naming.clear()
228+
naming {
229+
Tests {
230+
baseClass 'org.elasticsearch.gradle.test.GradleUnitTestCase'
231+
}
232+
IT {
233+
baseClass 'org.elasticsearch.gradle.test.GradleIntegrationTestCase'
234+
}
235+
}
236+
}
237+
229238
/*
230239
* We alread configure publication and we don't need or want this one that
231240
* comes from the java-gradle-plugin.

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

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,14 @@ import com.carrotsearch.ant.tasks.junit4.JUnit4
44
import org.gradle.api.Plugin
55
import org.gradle.api.Project
66
import org.gradle.api.Task
7-
import org.gradle.api.UnknownTaskException
8-
import org.gradle.api.plugins.JavaBasePlugin
97
import org.gradle.api.tasks.TaskContainer
10-
import org.gradle.api.tasks.TaskProvider
11-
import org.gradle.api.tasks.testing.Test
128

139
class RandomizedTestingPlugin implements Plugin<Project> {
1410

1511
void apply(Project project) {
1612
setupSeed(project)
17-
replaceTestTask(project.tasks)
13+
createUnitTestTask(project.tasks)
1814
configureAnt(project.ant)
19-
configureSanityCheck(project)
20-
}
21-
22-
private static void configureSanityCheck(Project project) {
23-
// Check the task graph to confirm tasks were indeed replaced
24-
// https://github.com/elastic/elasticsearch/issues/31324
25-
project.rootProject.getGradle().getTaskGraph().whenReady {
26-
Task test = project.getTasks().findByName("test")
27-
if (test != null && (test instanceof RandomizedTestingTask) == false) {
28-
throw new IllegalStateException("Test task was not replaced in project ${project.path}. Found ${test.getClass()}")
29-
}
30-
}
3115
}
3216

3317
/**
@@ -57,35 +41,15 @@ class RandomizedTestingPlugin implements Plugin<Project> {
5741
}
5842
}
5943

60-
static void replaceTestTask(TaskContainer tasks) {
61-
// Gradle 4.8 introduced lazy tasks, thus we deal both with the `test` task as well as it's provider
62-
// https://github.com/gradle/gradle/issues/5730#issuecomment-398822153
63-
// since we can't be sure if the task was ever realized, we remove both the provider and the task
64-
TaskProvider<Test> oldTestProvider
65-
try {
66-
oldTestProvider = tasks.named('test')
67-
} catch (UnknownTaskException unused) {
68-
// no test task, ok, user will use testing task on their own
69-
return
44+
static void createUnitTestTask(TaskContainer tasks) {
45+
// only create a unitTest task if the `test` task exists as some project don't make use of it.
46+
tasks.matching { it.name == "test" }.all {
47+
// We don't want to run any tests with the Gradle test runner since we add our own randomized runner
48+
it.enabled = false
49+
RandomizedTestingTask unitTest = tasks.create('unitTest', RandomizedTestingTask)
50+
unitTest.description = 'Runs unit tests with the randomized testing framework'
51+
it.dependsOn unitTest
7052
}
71-
Test oldTestTask = oldTestProvider.get()
72-
73-
// we still have to use replace here despite the remove above because the task container knows about the provider
74-
// by the same name
75-
RandomizedTestingTask newTestTask = tasks.replace('test', RandomizedTestingTask)
76-
newTestTask.configure{
77-
group = JavaBasePlugin.VERIFICATION_GROUP
78-
description = 'Runs unit tests with the randomized testing framework'
79-
dependsOn oldTestTask.dependsOn, 'testClasses'
80-
classpath = oldTestTask.classpath
81-
testClassesDirs = oldTestTask.project.sourceSets.test.output.classesDirs
82-
}
83-
84-
// hack so check task depends on custom test
85-
Task checkTask = tasks.getByName('check')
86-
checkTask.dependsOn.remove(oldTestProvider)
87-
checkTask.dependsOn.remove(oldTestTask)
88-
checkTask.dependsOn.add(newTestTask)
8953
}
9054

9155
static void configureAnt(AntBuilder ant) {

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

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import org.gradle.api.artifacts.ProjectDependency
4040
import org.gradle.api.artifacts.ResolvedArtifact
4141
import org.gradle.api.artifacts.dsl.RepositoryHandler
4242
import org.gradle.api.execution.TaskExecutionGraph
43+
import org.gradle.api.plugins.JavaBasePlugin
4344
import org.gradle.api.plugins.JavaPlugin
4445
import org.gradle.api.publish.maven.MavenPublication
4546
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
@@ -292,18 +293,7 @@ class BuildPlugin implements Plugin<Project> {
292293
it.standardOutput = dockerVersionOutput
293294
})
294295
final String dockerVersion = dockerVersionOutput.toString().trim()
295-
final Matcher matcher = dockerVersion =~ /Docker version (\d+\.\d+)\.\d+(?:-ce)?, build [0-9a-f]{7}/
296-
assert matcher.matches() : dockerVersion
297-
final dockerMajorMinorVersion = matcher.group(1)
298-
final String[] majorMinor = dockerMajorMinorVersion.split("\\.")
299-
if (Integer.parseInt(majorMinor[0]) < 17
300-
|| (Integer.parseInt(majorMinor[0]) == 17 && Integer.parseInt(majorMinor[1]) < 5)) {
301-
final String message = String.format(
302-
Locale.ROOT,
303-
"building Docker images requires Docker version 17.05+ due to use of multi-stage builds yet was [%s]",
304-
dockerVersion)
305-
throwDockerRequiredException(message)
306-
}
296+
checkDockerVersionRecent(dockerVersion)
307297

308298
final ByteArrayOutputStream dockerImagesErrorOutput = new ByteArrayOutputStream()
309299
// the Docker binary executes, check that we can execute a privileged command
@@ -338,6 +328,21 @@ class BuildPlugin implements Plugin<Project> {
338328
}
339329
}
340330

331+
protected static void checkDockerVersionRecent(String dockerVersion) {
332+
final Matcher matcher = dockerVersion =~ /Docker version (\d+\.\d+)\.\d+(?:-ce)?, build [0-9a-f]{7,40}/
333+
assert matcher.matches(): dockerVersion
334+
final dockerMajorMinorVersion = matcher.group(1)
335+
final String[] majorMinor = dockerMajorMinorVersion.split("\\.")
336+
if (Integer.parseInt(majorMinor[0]) < 17
337+
|| (Integer.parseInt(majorMinor[0]) == 17 && Integer.parseInt(majorMinor[1]) < 5)) {
338+
final String message = String.format(
339+
Locale.ROOT,
340+
"building Docker images requires Docker version 17.05+ due to use of multi-stage builds yet was [%s]",
341+
dockerVersion)
342+
throwDockerRequiredException(message)
343+
}
344+
}
345+
341346
private static void throwDockerRequiredException(final String message) {
342347
throw new GradleException(
343348
message + "\nyou can address this by attending to the reported issue, "
@@ -888,15 +893,22 @@ class BuildPlugin implements Plugin<Project> {
888893
parallelism System.getProperty('tests.jvms', project.rootProject.ext.defaultParallel)
889894
onNonEmptyWorkDirectory 'wipe'
890895
leaveTemporary true
896+
project.sourceSets.matching { it.name == "test" }.all { test ->
897+
task.testClassesDirs = test.output.classesDirs
898+
task.classpath = test.runtimeClasspath
899+
}
900+
group = JavaBasePlugin.VERIFICATION_GROUP
901+
dependsOn 'testClasses'
891902

892903
// Make sure all test tasks are configured properly
893904
if (name != "test") {
894905
project.tasks.matching { it.name == "test"}.all { testTask ->
895-
task.testClassesDirs = testTask.testClassesDirs
896-
task.classpath = testTask.classpath
897906
task.shouldRunAfter testTask
898907
}
899908
}
909+
if (name == "unitTest") {
910+
include("**/*Tests.class")
911+
}
900912

901913
// TODO: why are we not passing maxmemory to junit4?
902914
jvmArg '-Xmx' + System.getProperty('tests.heap.size', '512m')
@@ -986,8 +998,6 @@ class BuildPlugin implements Plugin<Project> {
986998

987999
exclude '**/*$*.class'
9881000

989-
dependsOn(project.tasks.testClasses)
990-
9911001
project.plugins.withType(ShadowPlugin).whenPluginAdded {
9921002
// Test against a shadow jar if we made one
9931003
classpath -= project.tasks.compileJava.outputs.files

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,19 @@ public class PluginBuildPlugin extends BuildPlugin {
7878
skipIntegTestInDisguise = true
7979
}
8080
}
81+
project.testingConventions {
82+
naming.clear()
83+
naming {
84+
Tests {
85+
baseClass 'org.apache.lucene.util.LuceneTestCase'
86+
}
87+
IT {
88+
baseClass 'org.elasticsearch.test.ESIntegTestCase'
89+
baseClass 'org.elasticsearch.test.rest.ESRestTestCase'
90+
baseClass 'org.elasticsearch.test.ESSingleNodeTestCase'
91+
}
92+
}
93+
}
8194
createIntegTestTask(project)
8295
createBundleTask(project)
8396
project.configurations.getByName('default').extendsFrom(project.configurations.getByName('runtime'))
@@ -101,7 +114,7 @@ public class PluginBuildPlugin extends BuildPlugin {
101114
generatePOMTask.ext.pomFileName = "${project.archivesBaseName}-client-${project.versions.elasticsearch}.pom"
102115
}
103116
} else {
104-
project.plugins.withType(MavenPublishPlugin).whenPluginAdded {
117+
if (project.plugins.hasPlugin(MavenPublishPlugin)) {
105118
project.publishing.publications.nebula(MavenPublication).artifactId(
106119
project.pluginProperties.extension.name
107120
)

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

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,17 @@ class PrecommitTasks {
9191
}
9292

9393
static Task configureTestingConventions(Project project) {
94-
project.getTasks().create("testingConventions", TestingConventionsTasks.class)
94+
TestingConventionsTasks task = project.getTasks().create("testingConventions", TestingConventionsTasks.class)
95+
task.naming {
96+
Tests {
97+
baseClass "org.apache.lucene.util.LuceneTestCase"
98+
}
99+
IT {
100+
baseClass "org.elasticsearch.test.ESIntegTestCase"
101+
baseClass 'org.elasticsearch.test.rest.ESRestTestCase'
102+
}
103+
}
104+
return task
95105
}
96106

97107
private static Task configureJarHell(Project project) {
@@ -123,8 +133,16 @@ class PrecommitTasks {
123133
project.tasks.withType(CheckForbiddenApis) {
124134
dependsOn(buildResources)
125135
targetCompatibility = project.runtimeJavaVersion >= JavaVersion.VERSION_1_9 ?
126-
project.runtimeJavaVersion.getMajorVersion() :
127-
project.runtimeJavaVersion
136+
project.runtimeJavaVersion.getMajorVersion() : project.runtimeJavaVersion
137+
if (project.runtimeJavaVersion > JavaVersion.VERSION_11) {
138+
doLast {
139+
project.logger.info(
140+
"Forbidden APIs does not support java version past 11. Will use the signatures from 11 for ",
141+
project.runtimeJavaVersion
142+
)
143+
}
144+
targetCompatibility = JavaVersion.VERSION_11.getMajorVersion()
145+
}
128146
bundledSignatures = [
129147
"jdk-unsafe", "jdk-deprecated", "jdk-non-portable", "jdk-system-out"
130148
]

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ public class RestIntegTestTask extends DefaultTask {
5555
super.dependsOn(runner)
5656
clusterInit = project.tasks.create(name: "${name}Cluster#init", dependsOn: project.testClasses)
5757
runner.dependsOn(clusterInit)
58-
runner.classpath = project.sourceSets.test.runtimeClasspath
59-
runner.testClassesDirs = project.sourceSets.test.output.classesDirs
6058
clusterConfig = project.extensions.create("${name}Cluster", ClusterConfiguration.class, project)
6159

6260
// override/add more for rest tests

0 commit comments

Comments
 (0)