Skip to content

Commit b1f5d36

Browse files
committed
Merge branch 'master' into ccr
* master: [TEST] Mute SlackMessageTests.testTemplateRender Docs: Explain closing the high level client [ML] Re-enable memory limit integration tests (#31328) [test] disable packaging tests for suse boxes Add nio transport to security plugin (#31942) XContentTests : Insert random fields at random positions (#30867) Force execution of fetch tasks (#31974) Fix unreachable error condition in AmazonS3Fixture (#32005) Tests: Fix SearchFieldsIT.testDocValueFields (#31995) Add Expected Reciprocal Rank metric (#31891) [ML] Get ForecastRequestStats doc in RestoreModelSnapshotIT (#31973) SQL: Add support for single parameter text manipulating functions (#31874) [ML] Ensure immutability of MlMetadata (#31957) Tests: Mute SearchFieldsIT.testDocValueFields() muted tests due to #31940 Work around reported problem in eclipse (#31960) Move build integration tests out of :buildSrc project (#31961) Tests: Remove use of joda time in some tests (#31922) [Test] Reactive 3rd party tests on CI (#31919) SQL: Support for escape sequences (#31884) SQL: HAVING clause should accept only aggregates (#31872) Docs: fix typo in datehistogram (#31972) Switch url repository rest tests to new style requests (#31944) Switch reindex tests to new style requests (#31941) Docs: Added note about cloud service to installation and getting started [DOCS] Removes alternative docker pull example (#31934) Add Snapshots Status API to High Level Rest Client (#31515) ingest: date_index_name processor template resolution (#31841) Test: fix null failure in watcher test (#31968) Switch test framework to new style requests (#31939) Switch low level rest tests to new style Requests (#31938) Switch high level rest tests to new style requests (#31937) [ML] Mute test failing due to Java 11 date time format parsing bug (#31899) [TEST] Mute SlackMessageTests.testTemplateRender Fix assertIngestDocument wrongfully passing (#31913) Remove unused reference to filePermissionsCache (#31923) rolling upgrade should use a replica to prevent relocations while running a scroll HLREST: Bundle the x-pack protocol project (#31904) Increase logging level for testStressMaybeFlush Added lenient flag for synonym token filter (#31484) [X-Pack] Beats centralized management: security role + licensing (#30520) HLRest: Move xPackInfo() to xPack().info() (#31905) Docs: add security delete role to api call table (#31907) [test] port archive distribution packaging tests (#31314) Watcher: Slack message empty text (#31596) [ML] Mute failing DetectionRulesIT.testCondition() test Fix broken NaN check in MovingFunctions#stdDev() (#31888) Date: Add DateFormatters class that uses java.time (#31856) [ML] Switch native QA tests to a 3 node cluster (#31757) Change trappy float comparison (#31889) Fix building AD URL from domain name (#31849) Add opaque_id to audit logging (#31878) re-enable backcompat tests add support for is_write_index in put-alias body parsing (#31674) Improve release notes script (#31833) [DOCS] Fix broken link in painless example Handle missing values in painless (#30975) Remove the ability to index or query context suggestions without context (#31007) Ingest: Enable Templated Fieldnames in Rename (#31690) [Docs] Fix typo in the Rollup API Quick Reference (#31855) Ingest: Add ignore_missing option to RemoveProc (#31693) Add template config for Beat state to X-Pack Monitoring (#31809) Watcher: Add ssl.trust email account setting (#31684) Remove link to oss-MSI (#31844) Painless: Restructure Definition/Whitelist (#31879) HLREST: Add x-pack-info API (#31870)
2 parents 4d18017 + 332c134 commit b1f5d36

File tree

343 files changed

+14038
-4606
lines changed

Some content is hidden

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

343 files changed

+14038
-4606
lines changed

build.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,9 @@ allprojects {
435435
if (isEclipse) {
436436
// set this so generated dirs will be relative to eclipse build
437437
project.buildDir = eclipseBuild
438+
// Work around https://docs.gradle.org/current/userguide/java_gradle_plugin.html confusing Eclipse by the metadata
439+
// it adds to the classpath
440+
project.file("$buildDir/pluginUnderTestMetadata").mkdirs()
438441
}
439442
eclipse.classpath.file.whenMerged { classpath ->
440443
// give each source folder a unique corresponding output folder

buildSrc/build.gradle

+16
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ if (project == rootProject) {
128128
}
129129
mavenCentral()
130130
}
131+
test {
132+
include "**/*Tests.class"
133+
exclude "**/*IT.class"
134+
}
131135
}
132136

133137
/*****************************************************************************
@@ -152,6 +156,18 @@ if (project != rootProject) {
152156
jarHell.enabled = false
153157
thirdPartyAudit.enabled = false
154158

159+
// tests can't be run with randomized test runner
160+
// it's fine as we run them as part of :buildSrc
161+
test.enabled = false
162+
task integTest(type: Test) {
163+
exclude "**/*Tests.class"
164+
include "**/*IT.class"
165+
testClassesDirs = sourceSets.test.output.classesDirs
166+
classpath = sourceSets.test.runtimeClasspath
167+
inputs.dir(file("src/testKit"))
168+
}
169+
check.dependsOn(integTest)
170+
155171
// TODO: re-enable once randomizedtesting gradle code is published and removed from here
156172
licenseHeaders.enabled = false
157173

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

+1
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ class BuildPlugin implements Plugin<Project> {
691691
systemProperty 'tests.task', path
692692
systemProperty 'tests.security.manager', 'true'
693693
systemProperty 'jna.nosys', 'true'
694+
systemProperty 'es.scripting.exception_for_missing_value', 'true'
694695
// TODO: remove setting logging level via system property
695696
systemProperty 'tests.logger.level', 'WARN'
696697
for (Map.Entry<String, String> property : System.properties.entrySet()) {

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy

+18-4
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,11 @@ class VagrantTestPlugin implements Plugin<Project> {
526526
project.gradle.removeListener(batsPackagingReproListener)
527527
}
528528
if (project.extensions.esvagrant.boxes.contains(box)) {
529-
packagingTest.dependsOn(batsPackagingTest)
529+
// these tests are temporarily disabled for suse boxes while we debug an issue
530+
// https://github.com/elastic/elasticsearch/issues/30295
531+
if (box.equals("opensuse-42") == false && box.equals("sles-12") == false) {
532+
packagingTest.dependsOn(batsPackagingTest)
533+
}
530534
}
531535
}
532536

@@ -546,9 +550,15 @@ class VagrantTestPlugin implements Plugin<Project> {
546550
javaPackagingTest.command = 'ssh'
547551
javaPackagingTest.args = ['--command', 'sudo bash "$PACKAGING_TESTS/run-tests.sh"']
548552
} else {
553+
// powershell sessions run over winrm always run as administrator, whether --elevated is passed or not. however
554+
// remote sessions have some restrictions on what they can do, such as impersonating another user (or the same user
555+
// without administrator elevation), which we need to do for these tests. passing --elevated runs the session
556+
// as a scheduled job locally on the vm as a true administrator to get around this limitation
557+
//
558+
// https://github.com/hashicorp/vagrant/blob/9c299a2a357fcf87f356bb9d56e18a037a53d138/plugins/communicators/winrm/communicator.rb#L195-L225
559+
// https://devops-collective-inc.gitbooks.io/secrets-of-powershell-remoting/content/manuscript/accessing-remote-computers.html
549560
javaPackagingTest.command = 'winrm'
550-
// winrm commands run as administrator
551-
javaPackagingTest.args = ['--command', 'powershell -File "$Env:PACKAGING_TESTS/run-tests.ps1"']
561+
javaPackagingTest.args = ['--elevated', '--command', 'powershell -File "$Env:PACKAGING_TESTS/run-tests.ps1"']
552562
}
553563

554564
TaskExecutionAdapter javaPackagingReproListener = createReproListener(project, javaPackagingTest.path)
@@ -559,7 +569,11 @@ class VagrantTestPlugin implements Plugin<Project> {
559569
project.gradle.removeListener(javaPackagingReproListener)
560570
}
561571
if (project.extensions.esvagrant.boxes.contains(box)) {
562-
packagingTest.dependsOn(javaPackagingTest)
572+
// these tests are temporarily disabled for suse boxes while we debug an issue
573+
// https://github.com/elastic/elasticsearch/issues/30295
574+
if (box.equals("opensuse-42") == false && box.equals("sles-12") == false) {
575+
packagingTest.dependsOn(javaPackagingTest)
576+
}
563577
}
564578

565579
/*

client/rest-high-level/build.gradle

+111-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import org.elasticsearch.gradle.precommit.PrecommitTasks
2-
31
/*
42
* Licensed to Elasticsearch under one or more contributor
53
* license agreements. See the NOTICE file distributed with
@@ -18,29 +16,86 @@ import org.elasticsearch.gradle.precommit.PrecommitTasks
1816
* specific language governing permissions and limitations
1917
* under the License.
2018
*/
19+
20+
import org.elasticsearch.gradle.precommit.PrecommitTasks
21+
import org.gradle.api.XmlProvider
22+
import org.gradle.api.publish.maven.MavenPublication
23+
24+
buildscript {
25+
repositories {
26+
maven {
27+
url 'https://plugins.gradle.org/m2/'
28+
}
29+
}
30+
dependencies {
31+
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
32+
}
33+
}
34+
2135
apply plugin: 'elasticsearch.build'
2236
apply plugin: 'elasticsearch.rest-test'
2337
apply plugin: 'nebula.maven-base-publish'
2438
apply plugin: 'nebula.maven-scm'
39+
apply plugin: 'com.github.johnrengelman.shadow'
2540

2641
group = 'org.elasticsearch.client'
2742
archivesBaseName = 'elasticsearch-rest-high-level-client'
2843

2944
publishing {
30-
publications {
31-
nebula {
32-
artifactId = archivesBaseName
45+
publications {
46+
nebula(MavenPublication) {
47+
artifact shadowJar
48+
artifactId = archivesBaseName
49+
/*
50+
* Configure the pom to include the "shadow" as compile dependencies
51+
* because that is how we're using them but remove all other dependencies
52+
* because they've been shaded into the jar.
53+
*/
54+
pom.withXml { XmlProvider xml ->
55+
Node root = xml.asNode()
56+
root.remove(root.dependencies)
57+
Node dependenciesNode = root.appendNode('dependencies')
58+
project.configurations.shadow.allDependencies.each {
59+
if (false == it instanceof SelfResolvingDependency) {
60+
Node dependencyNode = dependenciesNode.appendNode('dependency')
61+
dependencyNode.appendNode('groupId', it.group)
62+
dependencyNode.appendNode('artifactId', it.name)
63+
dependencyNode.appendNode('version', it.version)
64+
dependencyNode.appendNode('scope', 'compile')
65+
}
3366
}
67+
}
3468
}
69+
}
70+
}
71+
72+
/*
73+
* We need somewhere to configure dependencies that we don't wish to shade
74+
* into the high level REST client. The shadow plugin creates a "shadow"
75+
* configuration which is *almost* exactly that. It is never bundled into
76+
* the shaded jar but is used for main source compilation. Unfortunately,
77+
* by default it is not used for *test* source compilation and isn't used
78+
* in tests at all. This change makes it available for test compilation.
79+
* A change below makes it available for testing.
80+
*/
81+
sourceSets {
82+
test {
83+
compileClasspath += configurations.shadow
84+
}
3585
}
3686

3787
dependencies {
38-
compile "org.elasticsearch:elasticsearch:${version}"
39-
compile "org.elasticsearch.client:elasticsearch-rest-client:${version}"
40-
compile "org.elasticsearch.plugin:parent-join-client:${version}"
41-
compile "org.elasticsearch.plugin:aggs-matrix-stats-client:${version}"
42-
compile "org.elasticsearch.plugin:rank-eval-client:${version}"
43-
compile "org.elasticsearch.plugin:lang-mustache-client:${version}"
88+
/*
89+
* Everything in the "shadow" configuration is *not* copied into the
90+
* shadowJar.
91+
*/
92+
shadow "org.elasticsearch:elasticsearch:${version}"
93+
shadow "org.elasticsearch.client:elasticsearch-rest-client:${version}"
94+
shadow "org.elasticsearch.plugin:parent-join-client:${version}"
95+
shadow "org.elasticsearch.plugin:aggs-matrix-stats-client:${version}"
96+
shadow "org.elasticsearch.plugin:rank-eval-client:${version}"
97+
shadow "org.elasticsearch.plugin:lang-mustache-client:${version}"
98+
compile project(':x-pack:protocol')
4499

45100
testCompile "org.elasticsearch.client:test:${version}"
46101
testCompile "org.elasticsearch.test:framework:${version}"
@@ -63,3 +118,48 @@ forbiddenApisMain {
63118
signaturesURLs += [PrecommitTasks.getResource('/forbidden/http-signatures.txt')]
64119
signaturesURLs += [file('src/main/resources/forbidden/rest-high-level-signatures.txt').toURI().toURL()]
65120
}
121+
122+
shadowJar {
123+
classifier = null
124+
mergeServiceFiles()
125+
}
126+
127+
// We don't need normal jar, we use shadow jar instead
128+
jar.enabled = false
129+
assemble.dependsOn shadowJar
130+
131+
javadoc {
132+
/*
133+
* Bundle all of the javadoc from all of the shaded projects into this one
134+
* so we don't *have* to publish javadoc for all of the "client" jars.
135+
*/
136+
configurations.compile.dependencies.all { Dependency dep ->
137+
Project p = dependencyToProject(dep)
138+
if (p != null) {
139+
evaluationDependsOn(p.path)
140+
source += p.sourceSets.main.allJava
141+
}
142+
}
143+
}
144+
145+
/*
146+
* Use the jar for testing so we have tests of the bundled jar.
147+
* Use the "shadow" configuration for testing because we need things
148+
* in it.
149+
*/
150+
test {
151+
classpath -= compileJava.outputs.files
152+
classpath -= configurations.compile
153+
classpath -= configurations.runtime
154+
classpath += configurations.shadow
155+
classpath += shadowJar.outputs.files
156+
dependsOn shadowJar
157+
}
158+
integTestRunner {
159+
classpath -= compileJava.outputs.files
160+
classpath -= configurations.compile
161+
classpath -= configurations.runtime
162+
classpath += configurations.shadow
163+
classpath += shadowJar.outputs.files
164+
dependsOn shadowJar
165+
}

client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java

+38-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptRequest;
4444
import org.elasticsearch.action.admin.cluster.storedscripts.GetStoredScriptRequest;
4545
import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest;
46+
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotsStatusRequest;
4647
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest;
4748
import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest;
4849
import org.elasticsearch.action.admin.indices.analyze.AnalyzeRequest;
@@ -104,6 +105,7 @@
104105
import org.elasticsearch.common.xcontent.XContentType;
105106
import org.elasticsearch.index.VersionType;
106107
import org.elasticsearch.index.rankeval.RankEvalRequest;
108+
import org.elasticsearch.protocol.xpack.XPackInfoRequest;
107109
import org.elasticsearch.rest.action.search.RestSearchAction;
108110
import org.elasticsearch.script.mustache.MultiSearchTemplateRequest;
109111
import org.elasticsearch.script.mustache.SearchTemplateRequest;
@@ -115,8 +117,10 @@
115117
import java.net.URI;
116118
import java.net.URISyntaxException;
117119
import java.nio.charset.Charset;
120+
import java.util.EnumSet;
118121
import java.util.Locale;
119122
import java.util.StringJoiner;
123+
import java.util.stream.Collectors;
120124

121125
final class RequestConverters {
122126
static final XContentType REQUEST_BODY_CONTENT_TYPE = XContentType.JSON;
@@ -960,6 +964,20 @@ static Request getSnapshots(GetSnapshotsRequest getSnapshotsRequest) {
960964
return request;
961965
}
962966

967+
static Request snapshotsStatus(SnapshotsStatusRequest snapshotsStatusRequest) {
968+
String endpoint = new EndpointBuilder().addPathPartAsIs("_snapshot")
969+
.addPathPart(snapshotsStatusRequest.repository())
970+
.addCommaSeparatedPathParts(snapshotsStatusRequest.snapshots())
971+
.addPathPartAsIs("_status")
972+
.build();
973+
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
974+
975+
Params parameters = new Params(request);
976+
parameters.withMasterTimeout(snapshotsStatusRequest.masterNodeTimeout());
977+
parameters.withIgnoreUnavailable(snapshotsStatusRequest.ignoreUnavailable());
978+
return request;
979+
}
980+
963981
static Request deleteSnapshot(DeleteSnapshotRequest deleteSnapshotRequest) {
964982
String endpoint = new EndpointBuilder().addPathPartAsIs("_snapshot")
965983
.addPathPart(deleteSnapshotRequest.repository())
@@ -1065,6 +1083,19 @@ static Request deleteScript(DeleteStoredScriptRequest deleteStoredScriptRequest)
10651083
return request;
10661084
}
10671085

1086+
static Request xPackInfo(XPackInfoRequest infoRequest) {
1087+
Request request = new Request(HttpGet.METHOD_NAME, "/_xpack");
1088+
if (false == infoRequest.isVerbose()) {
1089+
request.addParameter("human", "false");
1090+
}
1091+
if (false == infoRequest.getCategories().equals(EnumSet.allOf(XPackInfoRequest.Category.class))) {
1092+
request.addParameter("categories", infoRequest.getCategories().stream()
1093+
.map(c -> c.toString().toLowerCase(Locale.ROOT))
1094+
.collect(Collectors.joining(",")));
1095+
}
1096+
return request;
1097+
}
1098+
10681099
private static HttpEntity createEntity(ToXContent toXContent, XContentType xContentType) throws IOException {
10691100
BytesRef source = XContentHelper.toXContent(toXContent, xContentType, false).toBytesRef();
10701101
return new ByteArrayEntity(source.bytes, source.offset, source.length, createContentType(xContentType));
@@ -1246,7 +1277,7 @@ Params withWaitForActiveShards(ActiveShardCount activeShardCount, ActiveShardCou
12461277
}
12471278

12481279
Params withIndicesOptions(IndicesOptions indicesOptions) {
1249-
putParam("ignore_unavailable", Boolean.toString(indicesOptions.ignoreUnavailable()));
1280+
withIgnoreUnavailable(indicesOptions.ignoreUnavailable());
12501281
putParam("allow_no_indices", Boolean.toString(indicesOptions.allowNoIndices()));
12511282
String expandWildcards;
12521283
if (indicesOptions.expandWildcardsOpen() == false && indicesOptions.expandWildcardsClosed() == false) {
@@ -1265,6 +1296,12 @@ Params withIndicesOptions(IndicesOptions indicesOptions) {
12651296
return this;
12661297
}
12671298

1299+
Params withIgnoreUnavailable(boolean ignoreUnavailable) {
1300+
// Always explicitly place the ignore_unavailable value.
1301+
putParam("ignore_unavailable", Boolean.toString(ignoreUnavailable));
1302+
return this;
1303+
}
1304+
12681305
Params withHuman(boolean human) {
12691306
if (human) {
12701307
putParam("human", Boolean.toString(human));

client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java

+19-5
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ public class RestHighLevelClient implements Closeable {
202202
private final IngestClient ingestClient = new IngestClient(this);
203203
private final SnapshotClient snapshotClient = new SnapshotClient(this);
204204
private final TasksClient tasksClient = new TasksClient(this);
205+
private final XPackClient xPackClient = new XPackClient(this);
205206

206207
/**
207208
* Creates a {@link RestHighLevelClient} given the low level {@link RestClientBuilder} that allows to build the
@@ -292,6 +293,19 @@ public final TasksClient tasks() {
292293
return tasksClient;
293294
}
294295

296+
/**
297+
* A wrapper for the {@link RestHighLevelClient} that provides methods for
298+
* accessing the Elastic Licensed X-Pack APIs that are shipped with the
299+
* default distribution of Elasticsearch. All of these APIs will 404 if run
300+
* against the OSS distribution of Elasticsearch.
301+
* <p>
302+
* See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/xpack-api.html">
303+
* X-Pack APIs on elastic.co</a> for more information.
304+
*/
305+
public final XPackClient xpack() {
306+
return xPackClient;
307+
}
308+
295309
/**
296310
* Executes a bulk request using the Bulk API.
297311
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html">Bulk API on elastic.co</a>
@@ -668,7 +682,7 @@ public final RankEvalResponse rankEval(RankEvalRequest rankEvalRequest, RequestO
668682
emptySet());
669683
}
670684

671-
685+
672686
/**
673687
* Executes a request using the Multi Search Template API.
674688
*
@@ -678,9 +692,9 @@ public final RankEvalResponse rankEval(RankEvalRequest rankEvalRequest, RequestO
678692
public final MultiSearchTemplateResponse multiSearchTemplate(MultiSearchTemplateRequest multiSearchTemplateRequest,
679693
RequestOptions options) throws IOException {
680694
return performRequestAndParseEntity(multiSearchTemplateRequest, RequestConverters::multiSearchTemplate,
681-
options, MultiSearchTemplateResponse::fromXContext, emptySet());
682-
}
683-
695+
options, MultiSearchTemplateResponse::fromXContext, emptySet());
696+
}
697+
684698
/**
685699
* Asynchronously executes a request using the Multi Search Template API
686700
*
@@ -692,7 +706,7 @@ public final void multiSearchTemplateAsync(MultiSearchTemplateRequest multiSearc
692706
ActionListener<MultiSearchTemplateResponse> listener) {
693707
performRequestAsyncAndParseEntity(multiSearchTemplateRequest, RequestConverters::multiSearchTemplate,
694708
options, MultiSearchTemplateResponse::fromXContext, listener, emptySet());
695-
}
709+
}
696710

697711
/**
698712
* Asynchronously executes a request using the Ranking Evaluation API.

0 commit comments

Comments
 (0)