Skip to content

Commit 2133855

Browse files
committed
Merge remote-tracking branch 'elastic/master' into opt-out-query-cache-default-distribution
* elastic/master: (213 commits) ML: Fix build after HLRC change Fix inner hits retrieval when stored fields are disabled (_none_) (elastic#33018) SQL: Show/desc commands now support table ids (elastic#33363) Mute testValidateFollowingIndexSettings HLRC: Add delete by query API (elastic#32782) [ML] The sort field on get records should default to the record_score (elastic#33358) [ML] Minor improvements to categorization Grok pattern creation (elastic#33353) [DOCS] fix a couple of typos (elastic#33356) Disable assemble task instead of removing it (elastic#33348) Simplify the return type of FieldMapper#parse. (elastic#32654) [ML] Delete forecast API (elastic#31134) (elastic#33218) Introduce private settings (elastic#33327) [Docs] Add search timeout caveats (elastic#33354) TESTS: Fix Race Condition in Temp Path Creation (elastic#33352) Fix from_range in search_after in changes snapshot (elastic#33335) TESTS+DISTR.: Fix testIndexCheckOnStartup Flake (elastic#33349) Null completion field should not throw IAE (elastic#33268) Adds code to help with IndicesRequestCacheIT failures (elastic#33313) Prevent NPE parsing the stop datafeed request. (elastic#33347) HLRC: Add ML get overall buckets API (elastic#33297) ...
2 parents 3e378b2 + ebd5eb6 commit 2133855

File tree

332 files changed

+17858
-3164
lines changed

Some content is hidden

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

332 files changed

+17858
-3164
lines changed

benchmarks/build.gradle

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ apply plugin: 'elasticsearch.build'
2121
apply plugin: 'application'
2222
mainClassName = 'org.openjdk.jmh.Main'
2323

24-
// Not published so no need to assemble
25-
tasks.remove(assemble)
26-
build.dependsOn.remove('assemble')
27-
24+
assemble.enabled = false
2825
archivesBaseName = 'elasticsearch-benchmarks'
2926

3027
test.enabled = false

build.gradle

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,12 @@
2020
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
2121
import org.apache.tools.ant.taskdefs.condition.Os
2222
import org.elasticsearch.gradle.BuildPlugin
23-
import org.elasticsearch.gradle.LoggedExec
2423
import org.elasticsearch.gradle.Version
2524
import org.elasticsearch.gradle.VersionCollection
2625
import org.elasticsearch.gradle.VersionProperties
2726
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
2827
import org.gradle.plugins.ide.eclipse.model.SourceFolder
2928

30-
import java.nio.file.Files
31-
import java.nio.file.Path
32-
3329
plugins {
3430
id 'com.gradle.build-scan' version '1.13.2'
3531
}
@@ -576,76 +572,18 @@ wrapper {
576572
}
577573
}
578574

579-
static void assertLinesInFile(final Path path, final List<String> expectedLines) {
580-
final List<String> actualLines = Files.readAllLines(path)
581-
int line = 0
582-
for (final String expectedLine : expectedLines) {
583-
final String actualLine = actualLines.get(line)
584-
if (expectedLine != actualLine) {
585-
throw new GradleException("expected line [${line + 1}] in [${path}] to be [${expectedLine}] but was [${actualLine}]")
586-
}
587-
line++
588-
}
589-
}
590-
591-
/*
592-
* Check that all generated JARs have our NOTICE.txt and an appropriate
593-
* LICENSE.txt in them. We configurate this in gradle but we'd like to
594-
* be extra paranoid.
595-
*/
596-
subprojects { project ->
597-
project.tasks.withType(Jar).whenTaskAdded { jarTask ->
598-
final Task extract = project.task("extract${jarTask.name.capitalize()}", type: LoggedExec) {
599-
dependsOn jarTask
600-
ext.destination = project.buildDir.toPath().resolve("jar-extracted/${jarTask.name}")
601-
commandLine "${->new File(rootProject.compilerJavaHome, 'bin/jar')}",
602-
'xf', "${-> jarTask.outputs.files.singleFile}", 'META-INF/LICENSE.txt', 'META-INF/NOTICE.txt'
603-
workingDir destination
604-
onlyIf {jarTask.enabled}
605-
doFirst {
606-
project.delete(destination)
607-
Files.createDirectories(destination)
608-
}
609-
}
610-
611-
final Task checkNotice = project.task("verify${jarTask.name.capitalize()}Notice") {
612-
dependsOn extract
613-
onlyIf {jarTask.enabled}
614-
doLast {
615-
final List<String> noticeLines = Files.readAllLines(project.noticeFile.toPath())
616-
final Path noticePath = extract.destination.resolve('META-INF/NOTICE.txt')
617-
assertLinesInFile(noticePath, noticeLines)
618-
}
619-
}
620-
project.check.dependsOn checkNotice
621-
622-
final Task checkLicense = project.task("verify${jarTask.name.capitalize()}License") {
623-
dependsOn extract
624-
onlyIf {jarTask.enabled}
625-
doLast {
626-
final List<String> licenseLines = Files.readAllLines(project.licenseFile.toPath())
627-
final Path licensePath = extract.destination.resolve('META-INF/LICENSE.txt')
628-
assertLinesInFile(licensePath, licenseLines)
629-
}
630-
}
631-
project.check.dependsOn checkLicense
632-
}
633-
}
634-
635575
/* Remove assemble/dependenciesInfo on all qa projects because we don't need to publish
636576
* artifacts for them. */
637577
gradle.projectsEvaluated {
638578
subprojects {
639579
if (project.path.startsWith(':qa')) {
640580
Task assemble = project.tasks.findByName('assemble')
641581
if (assemble) {
642-
project.tasks.remove(assemble)
643-
project.build.dependsOn.remove('assemble')
582+
assemble.enabled = false
644583
}
645584
Task dependenciesInfo = project.tasks.findByName('dependenciesInfo')
646585
if (dependenciesInfo) {
647-
project.tasks.remove(dependenciesInfo)
648-
project.precommit.dependsOn.remove('dependenciesInfo')
586+
dependenciesInfo.enabled = false
649587
}
650588
}
651589
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import org.gradle.util.GradleVersion
5656
import java.nio.charset.StandardCharsets
5757
import java.time.ZoneOffset
5858
import java.time.ZonedDateTime
59+
5960
/**
6061
* Encapsulates build configuration for elasticsearch projects.
6162
*/
@@ -546,7 +547,7 @@ class BuildPlugin implements Plugin<Project> {
546547
}
547548
// build poms with assemble (if the assemble task exists)
548549
Task assemble = project.tasks.findByName('assemble')
549-
if (assemble) {
550+
if (assemble && assemble.enabled) {
550551
assemble.dependsOn(generatePOMTask)
551552
}
552553
}
@@ -739,6 +740,7 @@ class BuildPlugin implements Plugin<Project> {
739740
}
740741
from(project.noticeFile.parent) {
741742
include project.noticeFile.name
743+
rename { 'NOTICE.txt' }
742744
}
743745
}
744746
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ public class DocsTestPlugin extends RestTestPlugin {
3535
// The distribution can be configured with -Dtests.distribution on the command line
3636
project.integTestCluster.distribution = System.getProperty('tests.distribution', 'zip')
3737
// Docs are published separately so no need to assemble
38-
project.tasks.remove(project.assemble)
39-
project.build.dependsOn.remove('assemble')
38+
project.tasks.assemble.enabled = false
4039
Map<String, String> defaultSubstitutions = [
4140
/* These match up with the asciidoc syntax for substitutions but
4241
* the values may differ. In particular {version} needs to resolve

buildSrc/src/main/resources/checkstyle_suppressions.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,6 @@
539539
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]mapper[/\\]DocumentMapperMergeTests.java" checks="LineLength" />
540540
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]mapper[/\\]DocumentParserTests.java" checks="LineLength" />
541541
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]mapper[/\\]DynamicMappingTests.java" checks="LineLength" />
542-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]mapper[/\\]ExternalFieldMapperTests.java" checks="LineLength" />
543542
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]mapper[/\\]ExternalMapper.java" checks="LineLength" />
544543
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]mapper[/\\]ExternalMetadataMapper.java" checks="LineLength" />
545544
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]mapper[/\\]FieldNamesFieldMapperTests.java" checks="LineLength" />
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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;
20+
21+
import org.apache.commons.io.IOUtils;
22+
import org.elasticsearch.gradle.test.GradleIntegrationTestCase;
23+
import org.gradle.testkit.runner.BuildResult;
24+
25+
import java.io.File;
26+
import java.io.IOException;
27+
import java.io.InputStream;
28+
import java.nio.charset.StandardCharsets;
29+
import java.util.zip.ZipEntry;
30+
import java.util.zip.ZipFile;
31+
32+
public class BuildPluginIT extends GradleIntegrationTestCase {
33+
34+
public void testPluginCanBeApplied() {
35+
BuildResult result = getGradleRunner("elasticsearch.build")
36+
.withArguments("hello", "-s")
37+
.build();
38+
assertTaskSuccessful(result, ":hello");
39+
assertOutputContains("build plugin can be applied");
40+
}
41+
42+
public void testCheckTask() {
43+
BuildResult result = getGradleRunner("elasticsearch.build")
44+
.withArguments("check", "assemble", "-s", "-Dlocal.repo.path=" + getLocalTestRepoPath())
45+
.build();
46+
assertTaskSuccessful(result, ":check");
47+
}
48+
49+
public void testLicenseAndNotice() throws IOException {
50+
BuildResult result = getGradleRunner("elasticsearch.build")
51+
.withArguments("clean", "assemble", "-s", "-Dlocal.repo.path=" + getLocalTestRepoPath())
52+
.build();
53+
54+
assertTaskSuccessful(result, ":assemble");
55+
56+
assertBuildFileExists(result, "elasticsearch.build", "distributions/elasticsearch.build.jar");
57+
58+
try (ZipFile zipFile = new ZipFile(new File(
59+
getBuildDir("elasticsearch.build"), "distributions/elasticsearch.build.jar"
60+
))) {
61+
ZipEntry licenseEntry = zipFile.getEntry("META-INF/LICENSE.txt");
62+
ZipEntry noticeEntry = zipFile.getEntry("META-INF/NOTICE.txt");
63+
assertNotNull("Jar does not have META-INF/LICENSE.txt", licenseEntry);
64+
assertNotNull("Jar does not have META-INF/NOTICE.txt", noticeEntry);
65+
try (
66+
InputStream license = zipFile.getInputStream(licenseEntry);
67+
InputStream notice = zipFile.getInputStream(noticeEntry)
68+
) {
69+
assertEquals("this is a test license file", IOUtils.toString(license, StandardCharsets.UTF_8.name()));
70+
assertEquals("this is a test notice file", IOUtils.toString(notice, StandardCharsets.UTF_8.name()));
71+
}
72+
}
73+
}
74+
75+
76+
}

buildSrc/src/test/java/org/elasticsearch/gradle/precommit/NamingConventionsTaskIT.java

Lines changed: 36 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,74 +2,57 @@
22

33
import org.elasticsearch.gradle.test.GradleIntegrationTestCase;
44
import org.gradle.testkit.runner.BuildResult;
5-
import org.gradle.testkit.runner.GradleRunner;
6-
import org.gradle.testkit.runner.TaskOutcome;
75

86
import java.util.Arrays;
7+
import java.util.HashSet;
98

109
public class NamingConventionsTaskIT extends GradleIntegrationTestCase {
1110

12-
public void testPluginCanBeApplied() {
13-
BuildResult result = GradleRunner.create()
14-
.withProjectDir(getProjectDir("namingConventionsSelfTest"))
15-
.withArguments("hello", "-s", "-PcheckForTestsInMain=false")
16-
.withPluginClasspath()
17-
.build();
18-
19-
assertEquals(TaskOutcome.SUCCESS, result.task(":hello").getOutcome());
20-
String output = result.getOutput();
21-
assertTrue(output, output.contains("build plugin can be applied"));
22-
}
23-
2411
public void testNameCheckFailsAsItShould() {
25-
BuildResult result = GradleRunner.create()
26-
.withProjectDir(getProjectDir("namingConventionsSelfTest"))
12+
BuildResult result = getGradleRunner("namingConventionsSelfTest")
2713
.withArguments("namingConventions", "-s", "-PcheckForTestsInMain=false")
28-
.withPluginClasspath()
2914
.buildAndFail();
3015

31-
assertNotNull("task did not run", result.task(":namingConventions"));
32-
assertEquals(TaskOutcome.FAILED, result.task(":namingConventions").getOutcome());
33-
String output = result.getOutput();
34-
for (String line : Arrays.asList(
35-
"Found inner classes that are tests, which are excluded from the test runner:",
36-
"* org.elasticsearch.test.NamingConventionsCheckInMainIT$InternalInvalidTests",
37-
"Classes ending with [Tests] must subclass [UnitTestCase]:",
38-
"* org.elasticsearch.test.NamingConventionsCheckInMainTests",
39-
"* org.elasticsearch.test.NamingConventionsCheckInMainIT",
40-
"Not all subclasses of UnitTestCase match the naming convention. Concrete classes must end with [Tests]:",
41-
"* org.elasticsearch.test.WrongName")) {
42-
assertTrue(
43-
"expected: '" + line + "' but it was not found in the output:\n" + output,
44-
output.contains(line)
45-
);
46-
}
16+
assertTaskFailed(result, ":namingConventions");
17+
assertOutputContains(
18+
result.getOutput(),
19+
// TODO: java9 Set.of
20+
new HashSet<>(
21+
Arrays.asList(
22+
"Not all subclasses of UnitTestCase match the naming convention. Concrete classes must end with [Tests]:",
23+
"* org.elasticsearch.test.WrongName",
24+
"Found inner classes that are tests, which are excluded from the test runner:",
25+
"* org.elasticsearch.test.NamingConventionsCheckInMainIT$InternalInvalidTests",
26+
"Classes ending with [Tests] must subclass [UnitTestCase]:",
27+
"* org.elasticsearch.test.NamingConventionsCheckInMainTests",
28+
"* org.elasticsearch.test.NamingConventionsCheckInMainIT"
29+
)
30+
)
31+
);
4732
}
4833

4934
public void testNameCheckFailsAsItShouldWithMain() {
50-
BuildResult result = GradleRunner.create()
51-
.withProjectDir(getProjectDir("namingConventionsSelfTest"))
35+
BuildResult result = getGradleRunner("namingConventionsSelfTest")
5236
.withArguments("namingConventions", "-s", "-PcheckForTestsInMain=true")
53-
.withPluginClasspath()
5437
.buildAndFail();
5538

56-
assertNotNull("task did not run", result.task(":namingConventions"));
57-
assertEquals(TaskOutcome.FAILED, result.task(":namingConventions").getOutcome());
58-
59-
String output = result.getOutput();
60-
for (String line : Arrays.asList(
61-
"Classes ending with [Tests] or [IT] or extending [UnitTestCase] must be in src/test/java:",
62-
"* org.elasticsearch.test.NamingConventionsCheckBadClasses$DummyInterfaceTests",
63-
"* org.elasticsearch.test.NamingConventionsCheckBadClasses$DummyAbstractTests",
64-
"* org.elasticsearch.test.NamingConventionsCheckBadClasses$InnerTests",
65-
"* org.elasticsearch.test.NamingConventionsCheckBadClasses$NotImplementingTests",
66-
"* org.elasticsearch.test.NamingConventionsCheckBadClasses$WrongNameTheSecond",
67-
"* org.elasticsearch.test.NamingConventionsCheckBadClasses$WrongName")) {
68-
assertTrue(
69-
"expected: '" + line + "' but it was not found in the output:\n"+output,
70-
output.contains(line)
71-
);
72-
}
39+
assertTaskFailed(result, ":namingConventions");
40+
assertOutputContains(
41+
result.getOutput(),
42+
// TODO: java9 Set.of
43+
new HashSet<>(
44+
Arrays.asList(
45+
"Classes ending with [Tests] or [IT] or extending [UnitTestCase] must be in src/test/java:",
46+
"* org.elasticsearch.test.NamingConventionsCheckBadClasses$DummyInterfaceTests",
47+
"* org.elasticsearch.test.NamingConventionsCheckBadClasses$DummyInterfaceTests",
48+
"* org.elasticsearch.test.NamingConventionsCheckBadClasses$DummyAbstractTests",
49+
"* org.elasticsearch.test.NamingConventionsCheckBadClasses$InnerTests",
50+
"* org.elasticsearch.test.NamingConventionsCheckBadClasses$NotImplementingTests",
51+
"* org.elasticsearch.test.NamingConventionsCheckBadClasses$WrongNameTheSecond",
52+
"* org.elasticsearch.test.NamingConventionsCheckBadClasses$WrongName"
53+
)
54+
)
55+
);
7356
}
7457

7558
}

buildSrc/src/test/java/org/elasticsearch/gradle/test/GradleIntegrationTestCase.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.nio.file.Path;
1111
import java.util.List;
1212
import java.util.Objects;
13+
import java.util.Set;
1314
import java.util.stream.Collectors;
1415
import java.util.stream.Stream;
1516

@@ -47,6 +48,12 @@ protected void assertOutputContains(String output, String... lines) {
4748
}
4849
}
4950

51+
protected void assertOutputContains(String output, Set<String> lines) {
52+
for (String line : lines) {
53+
assertOutputContains(output, line);
54+
}
55+
}
56+
5057
protected void assertOutputContains(String output, String line) {
5158
assertTrue(
5259
"Expected the following line in output:\n\n" + line + "\n\nOutput is:\n" + output,
@@ -82,7 +89,7 @@ private void assertTaskOutcome(BuildResult result, String taskName, TaskOutcome
8289
"\n\nOutput is:\n" + result.getOutput());
8390
}
8491
assertEquals(
85-
"Expected task to be successful but it was: " + task.getOutcome() +
92+
"Expected task `" + taskName +"` to be successful but it was: " + task.getOutcome() +
8693
taskOutcome + "\n\nOutput is:\n" + result.getOutput() ,
8794
taskOutcome,
8895
task.getOutcome()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
this is a test license file
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
this is a test notice file

0 commit comments

Comments
 (0)