Skip to content

Commit a6ea516

Browse files
Merge remote-tracking branch 'upstream/master' into binary-fields_doc_values
2 parents 0f5de93 + 1c1e423 commit a6ea516

File tree

408 files changed

+6744
-3431
lines changed

Some content is hidden

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

408 files changed

+6744
-3431
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*.ipr
66
*.iws
77
build-idea/
8+
# Eclipse and Intellij put there build files in "out"
89
out/
910

1011
# include shared intellij config
@@ -19,6 +20,7 @@ benchmarks/src/main/generated/*
1920
.project
2021
.classpath
2122
.settings
23+
# We don't use this any more, but we'll keep it around in gitignore for a while so we don't accidentally commit it
2224
build-eclipse/
2325

2426
# netbeans files

README.asciidoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ First of all, DON'T PANIC. It will take 5 minutes to get the gist of what Elasti
3737
* Run `bin/elasticsearch` on Linux or macOS. Run `bin\elasticsearch.bat` on Windows.
3838
* Run `curl -X GET http://localhost:9200/` to verify Elasticsearch is running.
3939

40+
For more options, see
41+
https://www.elastic.co/guide/en/elasticsearch/reference/current/starting-elasticsearch.html[Starting
42+
Elasticsearch].
43+
4044
=== Indexing
4145

4246
First, index some sample JSON documents. The first request automatically creates

build.gradle

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,13 +343,17 @@ allprojects {
343343
}
344344

345345
plugins.withType(JavaBasePlugin) {
346-
eclipse.classpath.defaultOutputDir = file('build-eclipse')
347346
eclipse.classpath.file.whenMerged { classpath ->
348-
// give each source folder a unique corresponding output folder
347+
/*
348+
* give each source folder a unique corresponding output folder
349+
* outside of the usual `build` folder. We can't put the build
350+
* in the usual build folder because eclipse becomes *very* sad
351+
* if we delete it. Which `gradlew clean` does all the time.
352+
*/
349353
int i = 0;
350354
classpath.entries.findAll { it instanceof SourceFolder }.each { folder ->
351355
i++;
352-
folder.output = "build-eclipse/" + i
356+
folder.output = 'out/eclipse/' + i
353357
}
354358

355359
// Starting with Gradle 6.7 test dependencies are not exposed by eclipse

buildSrc/src/integTest/groovy/org/elasticsearch/gradle/JdkDownloadPluginFuncTest.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {
3232
private static final String ADOPT_JDK_VERSION_11 = "11.0.10+9"
3333
private static final String ADOPT_JDK_VERSION_15 = "15.0.2+7"
3434
private static final String OPEN_JDK_VERSION = "12.0.1+99@123456789123456789123456789abcde"
35-
private static final String AZUL_AARCH_VERSION = "15.0.1+99@123456789123456789123456789abcde"
35+
private static final String AZUL_AARCH_VERSION = "16.0.1+99@123456789123456789123456789abcde"
3636
private static final Pattern JDK_HOME_LOGLINE = Pattern.compile("JDK HOME: (.*)");
3737

3838
@Unroll
@@ -215,7 +215,7 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {
215215
} else if (vendor.equals(VENDOR_AZUL)) {
216216
final String module = isMac(platform) ? "macosx" : platform;
217217
// we only test zulu 15 darwin aarch64 for now
218-
return "/zulu${module.equals('linux') ? '-embedded' : ''}/bin/zulu15.29.15-ca-jdk15.0.2-${module}_${arch}.tar.gz";
218+
return "/zulu${module.equals('linux') ? '-embedded' : ''}/bin/zulu16.28.11-ca-jdk16.0.0-${module}_${arch}.tar.gz";
219219
}
220220
}
221221

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

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,20 @@ class RestTestsFromSnippetsTask extends SnippetsTask {
3131
*/
3232
private static final List BAD_LANGUAGES = ['json', 'javascript']
3333

34+
/**
35+
* Test setups defined in the build instead of the docs so they can be
36+
* shared between many doc files.
37+
*/
3438
@Input
3539
Map<String, String> setups = new HashMap()
3640

41+
/**
42+
* Test teardowns defined in the build instead of the docs so they can be
43+
* shared between many doc files.
44+
*/
45+
@Input
46+
Map<String, String> teardowns = new HashMap()
47+
3748
/**
3849
* A list of files that contain snippets that *probably* should be
3950
* converted to `// CONSOLE` but have yet to be converted. If a file is in
@@ -281,19 +292,40 @@ class RestTestsFromSnippetsTask extends SnippetsTask {
281292
}
282293

283294
body(test, false)
295+
296+
if (test.teardown != null) {
297+
teardown(test)
298+
}
284299
}
285300

286301
private void setup(final Snippet snippet) {
287302
// insert a setup defined outside of the docs
288-
for (final String setupName : snippet.setup.split(',')) {
289-
final String setup = setups[setupName]
303+
for (final String name : snippet.setup.split(',')) {
304+
final String setup = setups[name]
290305
if (setup == null) {
291-
throw new InvalidUserDataException("Couldn't find setup for $snippet")
306+
throw new InvalidUserDataException(
307+
"Couldn't find named setup $name for $snippet"
308+
)
292309
}
310+
current.println("# Named setup ${name}")
293311
current.println(setup)
294312
}
295313
}
296314

315+
private void teardown(final Snippet snippet) {
316+
// insert a teardown defined outside of the docs
317+
for (final String name : snippet.teardown.split(',')) {
318+
final String teardown = teardowns[name]
319+
if (teardown == null) {
320+
throw new InvalidUserDataException(
321+
"Couldn't find named teardown $name for $snippet"
322+
)
323+
}
324+
current.println("# Named teardown ${name}")
325+
current.println(teardown)
326+
}
327+
}
328+
297329
private void response(Snippet response) {
298330
if (null == response.skip) {
299331
current.println(" - match: ")

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ class SnippetsTask extends DefaultTask {
3232
private static final String CATCH = /catch:\s*((?:\/[^\/]+\/)|[^ \]]+)/
3333
private static final String SKIP = /skip:([^\]]+)/
3434
private static final String SETUP = /setup:([^ \]]+)/
35+
private static final String TEARDOWN = /teardown:([^ \]]+)/
3536
private static final String WARNING = /warning:(.+)/
3637
private static final String NON_JSON = /(non_json)/
3738
private static final String TEST_SYNTAX =
38-
/(?:$CATCH|$SUBSTITUTION|$SKIP|(continued)|$SETUP|$WARNING|(skip_shard_failures)) ?/
39+
/(?:$CATCH|$SUBSTITUTION|$SKIP|(continued)|$SETUP|$TEARDOWN|$WARNING|(skip_shard_failures)) ?/
3940

4041
/**
4142
* Action to take on each snippet. Called with a single parameter, an
@@ -226,10 +227,14 @@ class SnippetsTask extends DefaultTask {
226227
return
227228
}
228229
if (it.group(7) != null) {
229-
snippet.warnings.add(it.group(7))
230+
snippet.teardown = it.group(7)
230231
return
231232
}
232233
if (it.group(8) != null) {
234+
snippet.warnings.add(it.group(8))
235+
return
236+
}
237+
if (it.group(9) != null) {
233238
snippet.skipShardsFailures = true
234239
return
235240
}
@@ -341,6 +346,7 @@ class SnippetsTask extends DefaultTask {
341346
String language = null
342347
String catchPart = null
343348
String setup = null
349+
String teardown = null
344350
boolean curl
345351
List warnings = new ArrayList()
346352
boolean skipShardsFailures = false
@@ -372,6 +378,9 @@ class SnippetsTask extends DefaultTask {
372378
if (setup) {
373379
result += "[setup:$setup]"
374380
}
381+
if (teardown) {
382+
result += "[teardown:$teardown]"
383+
}
375384
for (String warning in warnings) {
376385
result += "[warning:$warning]"
377386
}

buildSrc/src/main/java/org/elasticsearch/gradle/DockerBase.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,27 @@
1212
* This class models the different Docker base images that are used to build Docker distributions of Elasticsearch.
1313
*/
1414
public enum DockerBase {
15-
CENTOS("centos:8"),
15+
CENTOS("centos:8", ""),
16+
1617
// "latest" here is intentional, since the image name specifies "8"
17-
UBI("docker.elastic.co/ubi8/ubi-minimal:latest"),
18+
UBI("docker.elastic.co/ubi8/ubi-minimal:latest", "-ubi8"),
19+
1820
// The Iron Bank base image is UBI (albeit hardened), but we are required to parameterize the Docker build
19-
IRON_BANK("${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG}");
21+
IRON_BANK("${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG}", "-ironbank");
2022

2123
private final String image;
24+
private final String suffix;
2225

23-
DockerBase(String image) {
26+
DockerBase(String image, String suffix) {
2427
this.image = image;
28+
this.suffix = suffix;
2529
}
2630

2731
public String getImage() {
2832
return image;
2933
}
34+
35+
public String getSuffix() {
36+
return suffix;
37+
}
3038
}

buildSrc/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ public enum Type {
4242
DEB,
4343
DOCKER,
4444
// This is a different flavour of Docker image
45-
DOCKER_UBI;
45+
DOCKER_UBI,
46+
// Like UBI, but a little different.
47+
DOCKER_IRON_BANK;
4648

4749
@Override
4850
public String toString() {
@@ -54,13 +56,26 @@ public boolean shouldExtract() {
5456
case DEB:
5557
case DOCKER:
5658
case DOCKER_UBI:
59+
case DOCKER_IRON_BANK:
5760
case RPM:
5861
return false;
5962

6063
default:
6164
return true;
6265
}
6366
}
67+
68+
public boolean isDocker() {
69+
switch (this) {
70+
case DOCKER:
71+
case DOCKER_UBI:
72+
case DOCKER_IRON_BANK:
73+
return true;
74+
75+
default:
76+
return false;
77+
}
78+
}
6479
}
6580

6681
// package private to tests can use
@@ -141,8 +156,7 @@ public boolean getBundledJdk() {
141156
}
142157

143158
public boolean isDocker() {
144-
final Type type = this.type.get();
145-
return type == Type.DOCKER || type == Type.DOCKER_UBI;
159+
return this.type.get().isDocker();
146160
}
147161

148162
public void setBundledJdk(Boolean bundledJdk) {
@@ -194,6 +208,7 @@ public Configuration getExtracted() {
194208
case DEB:
195209
case DOCKER:
196210
case DOCKER_UBI:
211+
case DOCKER_IRON_BANK:
197212
case RPM:
198213
throw new UnsupportedOperationException(
199214
"distribution type [" + getType() + "] for " + "elasticsearch distribution [" + name + "] cannot be extracted"

buildSrc/src/main/java/org/elasticsearch/gradle/JdkDownloadPlugin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ private void setupRepository(Project project, Jdk jdk) {
133133
// The following is an absolute hack until AdoptOpenJdk provides Apple aarch64 builds
134134
String zuluPathSuffix = jdk.getPlatform().equals("linux") ? "-embedded" : "";
135135
switch (jdk.getMajor()) {
136-
case "15":
136+
case "16":
137137
artifactPattern = "zulu"
138138
+ zuluPathSuffix
139139
+ "/bin/zulu"
140140
+ jdk.getMajor()
141-
+ ".29.15-ca-jdk15.0.2-"
141+
+ ".28.11-ca-jdk16.0.0-"
142142
+ azulPlatform(jdk)
143143
+ "_[classifier].[ext]";
144144
break;

buildSrc/src/main/java/org/elasticsearch/gradle/docker/DockerBuildTask.java

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
import org.gradle.api.file.RegularFileProperty;
1515
import org.gradle.api.logging.Logger;
1616
import org.gradle.api.logging.Logging;
17+
import org.gradle.api.model.ObjectFactory;
1718
import org.gradle.api.provider.ListProperty;
19+
import org.gradle.api.provider.MapProperty;
1820
import org.gradle.api.provider.Property;
1921
import org.gradle.api.tasks.Input;
2022
import org.gradle.api.tasks.InputDirectory;
@@ -35,17 +37,22 @@ public class DockerBuildTask extends DefaultTask {
3537
private static final Logger LOGGER = Logging.getLogger(DockerBuildTask.class);
3638

3739
private final WorkerExecutor workerExecutor;
38-
private final RegularFileProperty markerFile = getProject().getObjects().fileProperty();
39-
private final DirectoryProperty dockerContext = getProject().getObjects().directoryProperty();
40+
private final RegularFileProperty markerFile;
41+
private final DirectoryProperty dockerContext;
4042

4143
private String[] tags;
4244
private boolean pull = true;
4345
private boolean noCache = true;
4446
private String[] baseImages;
47+
private MapProperty<String, String> buildArgs;
4548

4649
@Inject
47-
public DockerBuildTask(WorkerExecutor workerExecutor) {
50+
public DockerBuildTask(WorkerExecutor workerExecutor, ObjectFactory objectFactory) {
4851
this.workerExecutor = workerExecutor;
52+
this.markerFile = objectFactory.fileProperty();
53+
this.dockerContext = objectFactory.directoryProperty();
54+
this.buildArgs = objectFactory.mapProperty(String.class, String.class);
55+
4956
this.markerFile.set(getProject().getLayout().getBuildDirectory().file("markers/" + this.getName() + ".marker"));
5057
}
5158

@@ -57,7 +64,8 @@ public void build() {
5764
params.getTags().set(Arrays.asList(tags));
5865
params.getPull().set(pull);
5966
params.getNoCache().set(noCache);
60-
params.getBaseImages().set(baseImages);
67+
params.getBaseImages().set(Arrays.asList(baseImages));
68+
params.getBuildArgs().set(buildArgs);
6169
});
6270
}
6371

@@ -103,6 +111,15 @@ public void setBaseImages(String[] baseImages) {
103111
this.baseImages = baseImages;
104112
}
105113

114+
@Input
115+
public MapProperty<String, String> getBuildArgs() {
116+
return buildArgs;
117+
}
118+
119+
public void setBuildArgs(MapProperty<String, String> buildArgs) {
120+
this.buildArgs = buildArgs;
121+
}
122+
106123
@OutputFile
107124
public RegularFileProperty getMarkerFile() {
108125
return markerFile;
@@ -147,9 +164,7 @@ public void execute() {
147164
final Parameters parameters = getParameters();
148165

149166
if (parameters.getPull().get()) {
150-
for (String baseImage : parameters.getBaseImages().get()) {
151-
pullBaseImage(baseImage);
152-
}
167+
parameters.getBaseImages().get().forEach(this::pullBaseImage);
153168
}
154169

155170
LoggedExec.exec(execOperations, spec -> {
@@ -162,6 +177,8 @@ public void execute() {
162177
}
163178

164179
parameters.getTags().get().forEach(tag -> spec.args("--tag", tag));
180+
181+
parameters.getBuildArgs().get().forEach((k, v) -> spec.args("--build-arg", k + "=" + v));
165182
});
166183

167184
try {
@@ -183,6 +200,8 @@ interface Parameters extends WorkParameters {
183200

184201
Property<Boolean> getNoCache();
185202

186-
Property<String[]> getBaseImages();
203+
ListProperty<String> getBaseImages();
204+
205+
MapProperty<String, String> getBuildArgs();
187206
}
188207
}

0 commit comments

Comments
 (0)