Skip to content

Commit bf4454b

Browse files
committed
Merge branch 'master' into 2018-12-11-no-master-block-integration-tests
2 parents 6d21b38 + 797f985 commit bf4454b

File tree

138 files changed

+1707
-803
lines changed

Some content is hidden

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

138 files changed

+1707
-803
lines changed

buildSrc/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ dependencies {
9595
}
9696
minimumRuntimeCompile "junit:junit:${props.getProperty('junit')}"
9797
minimumRuntimeCompile localGroovy()
98+
minimumRuntimeCompile gradleApi()
9899
}
99100
jar {
100101
from sourceSets.minimumRuntime.output

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

Lines changed: 50 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import org.gradle.util.GradleVersion
5757
import java.nio.charset.StandardCharsets
5858
import java.time.ZoneOffset
5959
import java.time.ZonedDateTime
60+
import java.util.regex.Matcher
6061

6162
/**
6263
* Encapsulates build configuration for elasticsearch projects.
@@ -265,56 +266,68 @@ class BuildPlugin implements Plugin<Project> {
265266
rootProject.rootProject.ext.buildDocker = buildDocker
266267
rootProject.rootProject.ext.requiresDocker = []
267268
rootProject.gradle.taskGraph.whenReady { TaskExecutionGraph taskGraph ->
268-
int exitCode
269-
String dockerErrorOutput
270-
if (dockerBinary == null) {
271-
exitCode = -1
272-
dockerErrorOutput = null
273-
} else {
274-
// the Docker binary executes, check that we can execute a privileged command
275-
final ByteArrayOutputStream output = new ByteArrayOutputStream()
276-
final ExecResult result = LoggedExec.exec(rootProject, { ExecSpec it ->
277-
it.commandLine dockerBinary, "images"
278-
it.errorOutput = output
279-
it.ignoreExitValue = true
280-
})
281-
if (result.exitValue == 0) {
282-
return
283-
}
284-
exitCode = result.exitValue
285-
dockerErrorOutput = output.toString()
286-
}
287269
final List<String> tasks =
288270
((List<Task>)rootProject.requiresDocker).findAll { taskGraph.hasTask(it) }.collect { " ${it.path}".toString()}
289271
if (tasks.isEmpty() == false) {
290272
/*
291273
* There are tasks in the task graph that require Docker. Now we are failing because either the Docker binary does not
292274
* exist or because execution of a privileged Docker command failed.
293275
*/
294-
String message
295276
if (dockerBinary == null) {
296-
message = String.format(
277+
final String message = String.format(
297278
Locale.ROOT,
298279
"Docker (checked [%s]) is required to run the following task%s: \n%s",
299280
maybeDockerBinaries.join(","),
300281
tasks.size() > 1 ? "s" : "",
301282
tasks.join('\n'))
302-
} else {
303-
assert exitCode > 0 && dockerErrorOutput != null
304-
message = String.format(
283+
throwDockerRequiredException(message)
284+
}
285+
286+
// we use a multi-stage Docker build, check the Docker version since 17.05
287+
final ByteArrayOutputStream dockerVersionOutput = new ByteArrayOutputStream()
288+
LoggedExec.exec(
289+
rootProject,
290+
{ ExecSpec it ->
291+
it.commandLine = [dockerBinary, '--version']
292+
it.standardOutput = dockerVersionOutput
293+
})
294+
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+
}
307+
308+
final ByteArrayOutputStream dockerImagesErrorOutput = new ByteArrayOutputStream()
309+
// the Docker binary executes, check that we can execute a privileged command
310+
final ExecResult dockerImagesResult = LoggedExec.exec(
311+
rootProject,
312+
{ ExecSpec it ->
313+
it.commandLine = [dockerBinary, "images"]
314+
it.errorOutput = dockerImagesErrorOutput
315+
it.ignoreExitValue = true
316+
})
317+
318+
if (dockerImagesResult.exitValue != 0) {
319+
final String message = String.format(
305320
Locale.ROOT,
306321
"a problem occurred running Docker from [%s] yet it is required to run the following task%s: \n%s\n" +
307322
"the problem is that Docker exited with exit code [%d] with standard error output [%s]",
308323
dockerBinary,
309324
tasks.size() > 1 ? "s" : "",
310325
tasks.join('\n'),
311-
exitCode,
312-
dockerErrorOutput.trim())
326+
dockerImagesResult.exitValue,
327+
dockerImagesErrorOutput.toString().trim())
328+
throwDockerRequiredException(message)
313329
}
314-
throw new GradleException(
315-
message + "\nyou can address this by attending to the reported issue, "
316-
+ "removing the offending tasks from being executed, "
317-
+ "or by passing -Dbuild.docker=false")
330+
318331
}
319332
}
320333
}
@@ -325,6 +338,13 @@ class BuildPlugin implements Plugin<Project> {
325338
}
326339
}
327340

341+
private static void throwDockerRequiredException(final String message) {
342+
throw new GradleException(
343+
message + "\nyou can address this by attending to the reported issue, "
344+
+ "removing the offending tasks from being executed, "
345+
+ "or by passing -Dbuild.docker=false")
346+
}
347+
328348
private static String findCompilerJavaHome() {
329349
String compilerJavaHome = System.getenv('JAVA_HOME')
330350
final String compilerJavaProperty = System.getProperty('compiler.java')

client/rest-high-level/src/test/java/org/elasticsearch/client/ESRestHighLevelClientTestCase.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,22 @@ protected static RestHighLevelClient highLevelClient() {
7575
*/
7676
protected static <Req, Resp> Resp execute(Req request, SyncMethod<Req, Resp> syncMethod,
7777
AsyncMethod<Req, Resp> asyncMethod) throws IOException {
78+
return execute(request, syncMethod, asyncMethod, RequestOptions.DEFAULT);
79+
}
80+
81+
/**
82+
* Executes the provided request using either the sync method or its async variant, both provided as functions
83+
*/
84+
protected static <Req, Resp> Resp execute(Req request, SyncMethod<Req, Resp> syncMethod,
85+
AsyncMethod<Req, Resp> asyncMethod, RequestOptions options) throws IOException {
7886
if (randomBoolean()) {
79-
return syncMethod.execute(request, RequestOptions.DEFAULT);
87+
return syncMethod.execute(request, options);
8088
} else {
8189
PlainActionFuture<Resp> future = PlainActionFuture.newFuture();
82-
asyncMethod.execute(request, RequestOptions.DEFAULT, future);
90+
asyncMethod.execute(request, options, future);
8391
return future.actionGet();
8492
}
85-
}
93+
}
8694

8795
/**
8896
* Executes the provided request using either the sync method or its async

client/rest-high-level/src/test/java/org/elasticsearch/client/SearchIT.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,14 @@ public void testCountAllIndicesNoQuery() throws IOException {
12541254
CountRequest countRequest = new CountRequest();
12551255
CountResponse countResponse = execute(countRequest, highLevelClient()::count, highLevelClient()::countAsync);
12561256
assertCountHeader(countResponse);
1257+
// add logging to get more info about why https://github.com/elastic/elasticsearch/issues/35644 is failing
1258+
// TODO remove this once #35644 is fixed
1259+
if (countResponse.getCount() != 12) {
1260+
SearchRequest searchRequest = new SearchRequest();
1261+
searchRequest.source(new SearchSourceBuilder().size(20));
1262+
SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync);
1263+
logger.info("Unexpected hit count, was expecting 12 hits but got: " + searchResponse.toString());
1264+
}
12571265
assertEquals(12, countResponse.getCount());
12581266
}
12591267

docs/java-api/docs/update-by-query.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ This API doesn't allow you to move the documents it touches, just modify their
8888
source. This is intentional! We've made no provisions for removing the document
8989
from its original location.
9090

91-
You can also perform these operations on multiple indices and types at once, similar to the search API:
91+
You can also perform these operations on multiple indices at once, similar to the search API:
9292

9393
["source","java",subs="attributes,callouts,macros"]
9494
--------------------------------------------------

docs/reference/release-notes.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
This section summarizes the changes in each release.
88

9+
* <<release-notes-7.0.0-alpha2>>
910
* <<release-notes-7.0.0-alpha1>>
1011

1112
--
1213

14+
include::release-notes/7.0.0-alpha2.asciidoc[]
1315
include::release-notes/7.0.0-alpha1.asciidoc[]

docs/reference/release-notes/7.0.0-alpha1.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[[release-notes-7.0.0-alpha1]]
2-
== 7.0.0-alpha1 release notes
2+
== {es} version 7.0.0-alpha1
33

44
The changes listed below have been released for the first time in Elasticsearch 7.0.0-alpha1.
55

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[[release-notes-7.0.0-alpha2]]
2+
== {es} version 7.0.0-alpha2
3+
4+
coming[7.0.0-alpha2]

modules/lang-painless/src/main/java/org/elasticsearch/painless/AnalyzerCaster.java

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,37 @@ public static PainlessCast getLegalCast(Location location, Class<?> actual, Clas
4141

4242
if (actual == def.class) {
4343
if (expected == boolean.class) {
44-
return PainlessCast.unboxTargetType(def.class, Boolean.class, explicit, boolean.class);
44+
return PainlessCast.originalTypetoTargetType(def.class, boolean.class, explicit);
4545
} else if (expected == byte.class) {
46-
return PainlessCast.unboxTargetType(def.class, Byte.class, explicit, byte.class);
46+
return PainlessCast.originalTypetoTargetType(def.class, byte.class, explicit);
4747
} else if (expected == short.class) {
48-
return PainlessCast.unboxTargetType(def.class, Short.class, explicit, short.class);
48+
return PainlessCast.originalTypetoTargetType(def.class, short.class, explicit);
4949
} else if (expected == char.class) {
50-
return PainlessCast.unboxTargetType(def.class, Character.class, explicit, char.class);
50+
return PainlessCast.originalTypetoTargetType(def.class, char.class, explicit);
5151
} else if (expected == int.class) {
52-
return PainlessCast.unboxTargetType(def.class, Integer.class, explicit, int.class);
52+
return PainlessCast.originalTypetoTargetType(def.class, int.class, explicit);
5353
} else if (expected == long.class) {
54-
return PainlessCast.unboxTargetType(def.class, Long.class, explicit, long.class);
54+
return PainlessCast.originalTypetoTargetType(def.class, long.class, explicit);
5555
} else if (expected == float.class) {
56-
return PainlessCast.unboxTargetType(def.class, Float.class, explicit, float.class);
56+
return PainlessCast.originalTypetoTargetType(def.class, float.class, explicit);
5757
} else if (expected == double.class) {
58-
return PainlessCast.unboxTargetType(def.class, Double.class, explicit, double.class);
58+
return PainlessCast.originalTypetoTargetType(def.class, double.class, explicit);
59+
} else if (expected == Boolean.class) {
60+
return PainlessCast.originalTypetoTargetType(def.class, Boolean.class, explicit);
61+
} else if (expected == Byte.class) {
62+
return PainlessCast.originalTypetoTargetType(def.class, Byte.class, explicit);
63+
} else if (expected == Short.class) {
64+
return PainlessCast.originalTypetoTargetType(def.class, Short.class, explicit);
65+
} else if (expected == Character.class) {
66+
return PainlessCast.originalTypetoTargetType(def.class, Character.class, explicit);
67+
} else if (expected == Integer.class) {
68+
return PainlessCast.originalTypetoTargetType(def.class, Integer.class, explicit);
69+
} else if (expected == Long.class) {
70+
return PainlessCast.originalTypetoTargetType(def.class, Long.class, explicit);
71+
} else if (expected == Float.class) {
72+
return PainlessCast.originalTypetoTargetType(def.class, Float.class, explicit);
73+
} else if (expected == Double.class) {
74+
return PainlessCast.originalTypetoTargetType(def.class, Double.class, explicit);
5975
}
6076
} else if (actual == Object.class) {
6177
if (expected == byte.class && explicit && internal) {

0 commit comments

Comments
 (0)