Skip to content

Commit ac75968

Browse files
committed
Merge remote-tracking branch 'elastic/master' into ccr
* elastic/master: (46 commits) NETWORKING: Make RemoteClusterConn. Lazy Resolve DNS (#32764) [DOCS] Splits the users API documentation into multiple pages (#32825) [DOCS] Splits the token APIs into separate pages (#32865) [DOCS] Creates redirects for role management APIs page Bypassing failing test PainlessDomainSplitIT#testHRDSplit (#32966) TEST: Mute testRetentionPolicyChangeDuringRecovery [DOCS] Fixes more broken links to role management APIs [Docs] Tweaks and fixes to rollup docs [DOCS] Fixes links to role management APIs [ML][TEST] Fix BasicRenormalizationIT after adding multibucket feature [DOCS] Splits the roles API documentation into multiple pages (#32794) [TEST] Run pre 6.4 nodes in non-FIPS JVMs (#32901) Make Geo Context Mapping Parsing More Strict (#32821) [ML] fix updating opened jobs scheduled events (#31651) (#32881) Scripted metric aggregations: add deprecation warning and system property to control legacy params (#31597) Tests: Fix timezone conversion in DateTimeUnitTests Enable FIPS140LicenseBootstrapCheck (#32903) Fix InternalAutoDateHistogram reproducible failure (#32723) Remove assertion in testDocStats on deletedDocs counter (#32914) HLRC: Move ML request converters into their own class (#32906) ...
2 parents 4475f88 + f82bb64 commit ac75968

File tree

169 files changed

+3104
-1663
lines changed

Some content is hidden

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

169 files changed

+3104
-1663
lines changed

build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,15 @@ subprojects {
8787
}
8888
}
8989
}
90+
repositories {
91+
maven {
92+
name = 'localTest'
93+
url = "${rootProject.buildDir}/local-test-repo"
94+
}
95+
}
9096
}
9197
}
98+
9299
plugins.withType(BuildPlugin).whenPluginAdded {
93100
project.licenseFile = project.rootProject.file('licenses/APACHE-LICENSE-2.0.txt')
94101
project.noticeFile = project.rootProject.file('NOTICE.txt')
@@ -228,6 +235,7 @@ subprojects {
228235
"org.elasticsearch.client:elasticsearch-rest-high-level-client:${version}": ':client:rest-high-level',
229236
"org.elasticsearch.client:test:${version}": ':client:test',
230237
"org.elasticsearch.client:transport:${version}": ':client:transport',
238+
"org.elasticsearch.plugin:elasticsearch-scripting-painless-spi:${version}": ':modules:lang-painless:spi',
231239
"org.elasticsearch.test:framework:${version}": ':test:framework',
232240
"org.elasticsearch.distribution.integ-test-zip:elasticsearch:${version}": ':distribution:archives:integ-test-zip',
233241
"org.elasticsearch.distribution.zip:elasticsearch:${version}": ':distribution:archives:zip',

buildSrc/build.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,24 @@ if (project != rootProject) {
162162
// it's fine as we run them as part of :buildSrc
163163
test.enabled = false
164164
task integTest(type: Test) {
165+
// integration test requires the local testing repo for example plugin builds
166+
dependsOn project.rootProject.allprojects.collect {
167+
it.tasks.matching { it.name == 'publishNebulaPublicationToLocalTestRepository'}
168+
}
165169
exclude "**/*Tests.class"
166170
include "**/*IT.class"
167171
testClassesDirs = sourceSets.test.output.classesDirs
168172
classpath = sourceSets.test.runtimeClasspath
169173
inputs.dir(file("src/testKit"))
174+
// tell BuildExamplePluginsIT where to find the example plugins
175+
systemProperty (
176+
'test.build-tools.plugin.examples',
177+
files(
178+
project(':example-plugins').subprojects.collect { it.projectDir }
179+
).asPath,
180+
)
181+
systemProperty 'test.local-test-repo-path', "${rootProject.buildDir}/local-test-repo"
182+
systemProperty 'test.lucene-snapshot-revision', (versions.lucene =~ /\w+-snapshot-([a-z0-9]+)/)[0][1]
170183
}
171184
check.dependsOn(integTest)
172185

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ class BuildPlugin implements Plugin<Project> {
554554
project.publishing {
555555
publications {
556556
nebula(MavenPublication) {
557-
artifact project.tasks.shadowJar
557+
artifacts = [ project.tasks.shadowJar ]
558558
artifactId = project.archivesBaseName
559559
/*
560560
* Configure the pom to include the "shadow" as compile dependencies
@@ -584,7 +584,6 @@ class BuildPlugin implements Plugin<Project> {
584584
}
585585
}
586586
}
587-
588587
}
589588

590589
/** Adds compiler settings to the project */
@@ -799,6 +798,8 @@ class BuildPlugin implements Plugin<Project> {
799798
systemProperty 'tests.task', path
800799
systemProperty 'tests.security.manager', 'true'
801800
systemProperty 'jna.nosys', 'true'
801+
// TODO: remove this deprecation compatibility setting for 7.0
802+
systemProperty 'es.aggregations.enable_scripted_metric_agg_param', 'false'
802803
systemProperty 'compiler.java', project.ext.compilerJavaVersion.getMajorVersion()
803804
if (project.ext.inFipsJvm) {
804805
systemProperty 'runtime.java', project.ext.runtimeJavaVersion.getMajorVersion() + "FIPS"

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import org.elasticsearch.gradle.NoticeTask
2525
import org.elasticsearch.gradle.test.RestIntegTestTask
2626
import org.elasticsearch.gradle.test.RunTask
2727
import org.gradle.api.InvalidUserDataException
28-
import org.gradle.api.JavaVersion
2928
import org.gradle.api.Project
3029
import org.gradle.api.Task
3130
import org.gradle.api.XmlProvider
@@ -39,7 +38,6 @@ import java.nio.file.Path
3938
import java.nio.file.StandardCopyOption
4039
import java.util.regex.Matcher
4140
import java.util.regex.Pattern
42-
4341
/**
4442
* Encapsulates build configuration for an Elasticsearch plugin.
4543
*/

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

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package org.elasticsearch.gradle.plugin
2020

2121
import org.gradle.api.Project
2222
import org.gradle.api.tasks.Input
23+
import org.gradle.api.tasks.InputFile
2324

2425
/**
2526
* A container for plugin properties that will be written to the plugin descriptor, for easy
@@ -55,18 +56,39 @@ class PluginPropertiesExtension {
5556
boolean requiresKeystore = false
5657

5758
/** A license file that should be included in the built plugin zip. */
58-
@Input
59-
File licenseFile = null
59+
private File licenseFile = null
6060

6161
/**
6262
* A notice file that should be included in the built plugin zip. This will be
6363
* extended with notices from the {@code licenses/} directory.
6464
*/
65-
@Input
66-
File noticeFile = null
65+
private File noticeFile = null
66+
67+
Project project = null
6768

6869
PluginPropertiesExtension(Project project) {
6970
name = project.name
7071
version = project.version
72+
this.project = project
73+
}
74+
75+
@InputFile
76+
File getLicenseFile() {
77+
return licenseFile
78+
}
79+
80+
void setLicenseFile(File licenseFile) {
81+
project.ext.licenseFile = licenseFile
82+
this.licenseFile = licenseFile
83+
}
84+
85+
@InputFile
86+
File getNoticeFile() {
87+
return noticeFile
88+
}
89+
90+
void setNoticeFile(File noticeFile) {
91+
project.ext.noticeFile = noticeFile
92+
this.noticeFile = noticeFile
7193
}
7294
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import org.gradle.api.InvalidUserDataException
2323
import org.gradle.api.Task
2424
import org.gradle.api.tasks.Copy
2525
import org.gradle.api.tasks.OutputFile
26-
2726
/**
2827
* Creates a plugin descriptor.
2928
*/

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ class NodeInfo {
177177
javaVersion = 8
178178
} else if (nodeVersion.onOrAfter("6.2.0") && nodeVersion.before("6.3.0")) {
179179
javaVersion = 9
180+
} else if (project.inFipsJvm && nodeVersion.onOrAfter("6.3.0") && nodeVersion.before("6.4.0")) {
181+
/*
182+
* Elasticsearch versions before 6.4.0 cannot be run in a FIPS-140 JVM. If we're running
183+
* bwc tests in a FIPS-140 JVM, ensure that the pre v6.4.0 nodes use a Java 10 JVM instead.
184+
*/
185+
javaVersion = 10
180186
}
181187

182188
args.addAll("-E", "node.portsfile=true")

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import org.gradle.api.provider.Provider
3131
import org.gradle.api.tasks.Copy
3232
import org.gradle.api.tasks.Input
3333
import org.gradle.api.tasks.TaskState
34+
import org.gradle.plugins.ide.idea.IdeaPlugin
3435

3536
import java.nio.charset.StandardCharsets
3637
import java.nio.file.Files
@@ -243,10 +244,12 @@ public class RestIntegTestTask extends DefaultTask {
243244
}
244245
}
245246
}
246-
project.idea {
247-
module {
248-
if (scopes.TEST != null) {
249-
scopes.TEST.plus.add(project.configurations.restSpec)
247+
if (project.plugins.hasPlugin(IdeaPlugin)) {
248+
project.idea {
249+
module {
250+
if (scopes.TEST != null) {
251+
scopes.TEST.plus.add(project.configurations.restSpec)
252+
}
250253
}
251254
}
252255
}
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
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 com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
22+
import org.apache.commons.io.FileUtils;
23+
import org.elasticsearch.gradle.test.GradleIntegrationTestCase;
24+
import org.gradle.testkit.runner.GradleRunner;
25+
import org.junit.BeforeClass;
26+
import org.junit.Rule;
27+
import org.junit.rules.TemporaryFolder;
28+
29+
import java.io.File;
30+
import java.io.IOException;
31+
import java.nio.charset.StandardCharsets;
32+
import java.nio.file.Files;
33+
import java.nio.file.Path;
34+
import java.nio.file.StandardOpenOption;
35+
import java.util.Arrays;
36+
import java.util.Collections;
37+
import java.util.List;
38+
import java.util.Objects;
39+
import java.util.stream.Collectors;
40+
41+
public class BuildExamplePluginsIT extends GradleIntegrationTestCase {
42+
43+
private static List<File> EXAMPLE_PLUGINS = Collections.unmodifiableList(
44+
Arrays.stream(
45+
Objects.requireNonNull(System.getProperty("test.build-tools.plugin.examples"))
46+
.split(File.pathSeparator)
47+
).map(File::new).collect(Collectors.toList())
48+
);
49+
50+
@Rule
51+
public TemporaryFolder tmpDir = new TemporaryFolder();
52+
53+
public final File examplePlugin;
54+
55+
public BuildExamplePluginsIT(File examplePlugin) {
56+
this.examplePlugin = examplePlugin;
57+
}
58+
59+
@BeforeClass
60+
public static void assertProjectsExist() {
61+
assertEquals(
62+
EXAMPLE_PLUGINS,
63+
EXAMPLE_PLUGINS.stream().filter(File::exists).collect(Collectors.toList())
64+
);
65+
}
66+
67+
@ParametersFactory
68+
public static Iterable<Object[]> parameters() {
69+
return EXAMPLE_PLUGINS
70+
.stream()
71+
.map(each -> new Object[] {each})
72+
.collect(Collectors.toList());
73+
}
74+
75+
public void testCurrentExamplePlugin() throws IOException {
76+
FileUtils.copyDirectory(examplePlugin, tmpDir.getRoot());
77+
// just get rid of deprecation warnings
78+
Files.write(
79+
getTempPath("settings.gradle"),
80+
"enableFeaturePreview('STABLE_PUBLISHING')\n".getBytes(StandardCharsets.UTF_8)
81+
);
82+
83+
adaptBuildScriptForTest();
84+
85+
Files.write(
86+
tmpDir.newFile("NOTICE.txt").toPath(),
87+
"dummy test notice".getBytes(StandardCharsets.UTF_8)
88+
);
89+
90+
GradleRunner.create()
91+
.withProjectDir(tmpDir.getRoot())
92+
.withArguments("clean", "check", "-s", "-i", "--warning-mode=all", "--scan")
93+
.withPluginClasspath()
94+
.build();
95+
}
96+
97+
private void adaptBuildScriptForTest() throws IOException {
98+
// Add the local repo as a build script URL so we can pull in build-tools and apply the plugin under test
99+
// + is ok because we have no other repo and just want to pick up latest
100+
writeBuildScript(
101+
"buildscript {\n" +
102+
" repositories {\n" +
103+
" maven {\n" +
104+
" url = '" + getLocalTestRepoPath() + "'\n" +
105+
" }\n" +
106+
" }\n" +
107+
" dependencies {\n" +
108+
" classpath \"org.elasticsearch.gradle:build-tools:+\"\n" +
109+
" }\n" +
110+
"}\n"
111+
);
112+
// get the original file
113+
Files.readAllLines(getTempPath("build.gradle"), StandardCharsets.UTF_8)
114+
.stream()
115+
.map(line -> line + "\n")
116+
.forEach(this::writeBuildScript);
117+
// Add a repositories section to be able to resolve dependencies
118+
String luceneSnapshotRepo = "";
119+
String luceneSnapshotRevision = System.getProperty("test.lucene-snapshot-revision");
120+
if (luceneSnapshotRepo != null) {
121+
luceneSnapshotRepo = " maven {\n" +
122+
" url \"http://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/" + luceneSnapshotRevision + "\"\n" +
123+
" }\n";
124+
}
125+
writeBuildScript("\n" +
126+
"repositories {\n" +
127+
" maven {\n" +
128+
" url \"" + getLocalTestRepoPath() + "\"\n" +
129+
" }\n" +
130+
luceneSnapshotRepo +
131+
"}\n"
132+
);
133+
Files.delete(getTempPath("build.gradle"));
134+
Files.move(getTempPath("build.gradle.new"), getTempPath("build.gradle"));
135+
System.err.print("Generated build script is:");
136+
Files.readAllLines(getTempPath("build.gradle")).forEach(System.err::println);
137+
}
138+
139+
private Path getTempPath(String fileName) {
140+
return new File(tmpDir.getRoot(), fileName).toPath();
141+
}
142+
143+
private Path writeBuildScript(String script) {
144+
try {
145+
Path path = getTempPath("build.gradle.new");
146+
return Files.write(
147+
path,
148+
script.getBytes(StandardCharsets.UTF_8),
149+
Files.exists(path) ? StandardOpenOption.APPEND : StandardOpenOption.CREATE_NEW
150+
);
151+
} catch (IOException e) {
152+
throw new RuntimeException(e);
153+
}
154+
}
155+
156+
private String getLocalTestRepoPath() {
157+
String property = System.getProperty("test.local-test-repo-path");
158+
Objects.requireNonNull(property, "test.local-test-repo-path not passed to tests");
159+
File file = new File(property);
160+
assertTrue("Expected " + property + " to exist, but it did not!", file.exists());
161+
return file.getAbsolutePath();
162+
}
163+
164+
}

0 commit comments

Comments
 (0)