Skip to content

Commit 05e6559

Browse files
Merge remote-tracking branch 'elastic/master' into replace-agg-script-context
2 parents 145e11f + 042424b commit 05e6559

File tree

216 files changed

+4130
-1638
lines changed

Some content is hidden

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

216 files changed

+4130
-1638
lines changed

buildSrc/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ plugins {
2525

2626
group = 'org.elasticsearch.gradle'
2727

28-
if (GradleVersion.current() < GradleVersion.version('3.3')) {
29-
throw new GradleException('Gradle 3.3+ is required to build elasticsearch')
28+
if (GradleVersion.current() < GradleVersion.version('4.9')) {
29+
throw new GradleException('Gradle 4.9+ is required to build elasticsearch')
3030
}
3131

3232
if (JavaVersion.current() < JavaVersion.VERSION_1_8) {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ class BuildPlugin implements Plugin<Project> {
6767
+ 'elasticearch.standalone-rest-test, and elasticsearch.build '
6868
+ 'are mutually exclusive')
6969
}
70+
if (GradleVersion.current() < GradleVersion.version('4.9')) {
71+
throw new GradleException('Gradle 4.9+ is required to use elasticsearch.build plugin')
72+
}
7073
project.pluginManager.apply('java')
7174
project.pluginManager.apply('carrotsearch.randomized-testing')
7275
// these plugins add lots of info to our jars
@@ -750,7 +753,6 @@ class BuildPlugin implements Plugin<Project> {
750753
systemProperty 'tests.task', path
751754
systemProperty 'tests.security.manager', 'true'
752755
systemProperty 'jna.nosys', 'true'
753-
systemProperty 'es.scripting.exception_for_missing_value', 'true'
754756
// TODO: remove setting logging level via system property
755757
systemProperty 'tests.logger.level', 'WARN'
756758
for (Map.Entry<String, String> property : System.properties.entrySet()) {

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

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ public class PluginBuildPlugin extends BuildPlugin {
7575
// and generate a different pom for the zip
7676
addClientJarPomGeneration(project)
7777
addClientJarTask(project)
78-
} else {
79-
// no client plugin, so use the pom file from nebula, without jar, for the zip
80-
project.ext.set("nebulaPublish.maven.jar", false)
8178
}
79+
// while the jar isn't normally published, we still at least build a pom of deps
80+
// in case it is published, for instance when other plugins extend this plugin
81+
configureJarPom(project)
8282

8383
project.integTestCluster.dependsOn(project.bundlePlugin)
8484
project.tasks.run.dependsOn(project.bundlePlugin)
@@ -94,7 +94,6 @@ public class PluginBuildPlugin extends BuildPlugin {
9494
}
9595

9696
if (isModule == false || isXPackModule) {
97-
addZipPomGeneration(project)
9897
addNoticeGeneration(project)
9998
}
10099

@@ -239,36 +238,15 @@ public class PluginBuildPlugin extends BuildPlugin {
239238
}
240239
}
241240

242-
/** Adds a task to generate a pom file for the zip distribution. */
243-
public static void addZipPomGeneration(Project project) {
241+
/** Configure the pom for the main jar of this plugin */
242+
protected static void configureJarPom(Project project) {
244243
project.plugins.apply(ScmInfoPlugin.class)
245244
project.plugins.apply(MavenPublishPlugin.class)
246245

247246
project.publishing {
248247
publications {
249-
zip(MavenPublication) {
250-
artifact project.bundlePlugin
251-
}
252-
/* HUGE HACK: the underlying maven publication library refuses to deploy any attached artifacts
253-
* when the packaging type is set to 'pom'. But Sonatype's OSS repositories require source files
254-
* for artifacts that are of type 'zip'. We already publish the source and javadoc for Elasticsearch
255-
* under the various other subprojects. So here we create another publication using the same
256-
* name that has the "real" pom, and rely on the fact that gradle will execute the publish tasks
257-
* in alphabetical order. This lets us publish the zip file and even though the pom says the
258-
* type is 'pom' instead of 'zip'. We cannot setup a dependency between the tasks because the
259-
* publishing tasks are created *extremely* late in the configuration phase, so that we cannot get
260-
* ahold of the actual task. Furthermore, this entire hack only exists so we can make publishing to
261-
* maven local work, since we publish to maven central externally. */
262-
zipReal(MavenPublication) {
263-
artifactId = project.pluginProperties.extension.name
264-
pom.withXml { XmlProvider xml ->
265-
Node root = xml.asNode()
266-
root.appendNode('name', project.pluginProperties.extension.name)
267-
root.appendNode('description', project.pluginProperties.extension.description)
268-
root.appendNode('url', urlFromOrigin(project.scminfo.origin))
269-
Node scmNode = root.appendNode('scm')
270-
scmNode.appendNode('url', project.scminfo.origin)
271-
}
248+
nebula(MavenPublication) {
249+
artifactId project.pluginProperties.extension.name
272250
}
273251
}
274252
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ class ClusterConfiguration {
142142
// there are cases when value depends on task that is not executed yet on configuration stage
143143
Map<String, Object> systemProperties = new HashMap<>()
144144

145+
Map<String, Object> environmentVariables = new HashMap<>()
146+
145147
Map<String, Object> settings = new HashMap<>()
146148

147149
Map<String, String> keystoreSettings = new HashMap<>()
@@ -164,6 +166,11 @@ class ClusterConfiguration {
164166
systemProperties.put(property, value)
165167
}
166168

169+
@Input
170+
void environment(String variable, Object value) {
171+
environmentVariables.put(variable, value)
172+
}
173+
167174
@Input
168175
void setting(String name, Object value) {
169176
settings.put(name, value)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ class NodeInfo {
181181

182182
args.addAll("-E", "node.portsfile=true")
183183
env = [:]
184+
env.putAll(config.environmentVariables)
184185
for (Map.Entry<String, String> property : System.properties.entrySet()) {
185186
if (property.key.startsWith('tests.es.')) {
186187
args.add("-E")

client/rest-high-level/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,7 @@ forbiddenApisMain {
7070
signaturesURLs += [PrecommitTasks.getResource('/forbidden/http-signatures.txt')]
7171
signaturesURLs += [file('src/main/resources/forbidden/rest-high-level-signatures.txt').toURI().toURL()]
7272
}
73+
74+
integTestCluster {
75+
setting 'xpack.license.self_generated.type', 'trial'
76+
}

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
import org.elasticsearch.index.VersionType;
107107
import org.elasticsearch.index.rankeval.RankEvalRequest;
108108
import org.elasticsearch.protocol.xpack.XPackInfoRequest;
109+
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
109110
import org.elasticsearch.protocol.xpack.XPackUsageRequest;
110111
import org.elasticsearch.rest.action.search.RestSearchAction;
111112
import org.elasticsearch.script.mustache.MultiSearchTemplateRequest;
@@ -1097,6 +1098,25 @@ static Request xPackInfo(XPackInfoRequest infoRequest) {
10971098
return request;
10981099
}
10991100

1101+
static Request xPackWatcherPutWatch(PutWatchRequest putWatchRequest) {
1102+
String endpoint = new EndpointBuilder()
1103+
.addPathPartAsIs("_xpack")
1104+
.addPathPartAsIs("watcher")
1105+
.addPathPartAsIs("watch")
1106+
.addPathPart(putWatchRequest.getId())
1107+
.build();
1108+
1109+
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
1110+
Params params = new Params(request).withVersion(putWatchRequest.getVersion());
1111+
if (putWatchRequest.isActive() == false) {
1112+
params.putParam("active", "false");
1113+
}
1114+
ContentType contentType = createContentType(putWatchRequest.xContentType());
1115+
BytesReference source = putWatchRequest.getSource();
1116+
request.setEntity(new ByteArrayEntity(source.toBytesRef().bytes, 0, source.length(), contentType));
1117+
return request;
1118+
}
1119+
11001120
static Request xpackUsage(XPackUsageRequest usageRequest) {
11011121
Request request = new Request(HttpGet.METHOD_NAME, "/_xpack/usage");
11021122
Params parameters = new Params(request);
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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.client;
20+
21+
import org.elasticsearch.action.ActionListener;
22+
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
23+
import org.elasticsearch.protocol.xpack.watcher.PutWatchResponse;
24+
25+
import java.io.IOException;
26+
27+
import static java.util.Collections.emptySet;
28+
29+
public final class WatcherClient {
30+
31+
private final RestHighLevelClient restHighLevelClient;
32+
33+
WatcherClient(RestHighLevelClient restHighLevelClient) {
34+
this.restHighLevelClient = restHighLevelClient;
35+
}
36+
37+
/**
38+
* Put a watch into the cluster
39+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-watch.html">
40+
* the docs</a> for more.
41+
* @param request the request
42+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
43+
* @return the response
44+
* @throws IOException in case there is a problem sending the request or parsing back the response
45+
*/
46+
public PutWatchResponse putWatch(PutWatchRequest request, RequestOptions options) throws IOException {
47+
return restHighLevelClient.performRequestAndParseEntity(request, RequestConverters::xPackWatcherPutWatch, options,
48+
PutWatchResponse::fromXContent, emptySet());
49+
}
50+
51+
/**
52+
* Asynchronously put a watch into the cluster
53+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-watch.html">
54+
* the docs</a> for more.
55+
* @param request the request
56+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
57+
* @param listener the listener to be notified upon request completion
58+
*/
59+
public void putWatchAsync(PutWatchRequest request, RequestOptions options,
60+
ActionListener<PutWatchResponse> listener) {
61+
restHighLevelClient.performRequestAsyncAndParseEntity(request, RequestConverters::xPackWatcherPutWatch, options,
62+
PutWatchResponse::fromXContent, listener, emptySet());
63+
}
64+
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,17 @@
3939
* X-Pack APIs on elastic.co</a> for more information.
4040
*/
4141
public final class XPackClient {
42+
4243
private final RestHighLevelClient restHighLevelClient;
44+
private final WatcherClient watcherClient;
4345

4446
XPackClient(RestHighLevelClient restHighLevelClient) {
4547
this.restHighLevelClient = restHighLevelClient;
48+
this.watcherClient = new WatcherClient(restHighLevelClient);
49+
}
50+
51+
public WatcherClient watcher() {
52+
return watcherClient;
4653
}
4754

4855
/**

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ public void testXPackInfo() throws IOException {
6666

6767
assertEquals(mainResponse.getBuild().shortHash(), info.getBuildInfo().getHash());
6868

69-
assertEquals("basic", info.getLicenseInfo().getType());
70-
assertEquals("basic", info.getLicenseInfo().getMode());
69+
assertEquals("trial", info.getLicenseInfo().getType());
70+
assertEquals("trial", info.getLicenseInfo().getMode());
7171
assertEquals(LicenseStatus.ACTIVE, info.getLicenseInfo().getStatus());
7272

7373
FeatureSet graph = info.getFeatureSetsInfo().getFeatureSets().get("graph");
7474
assertNotNull(graph.description());
75-
assertFalse(graph.available());
75+
assertTrue(graph.available());
7676
assertTrue(graph.enabled());
7777
assertNull(graph.nativeCodeInfo());
7878
FeatureSet monitoring = info.getFeatureSetsInfo().getFeatureSets().get("monitoring");
@@ -82,7 +82,7 @@ public void testXPackInfo() throws IOException {
8282
assertNull(monitoring.nativeCodeInfo());
8383
FeatureSet ml = info.getFeatureSetsInfo().getFeatureSets().get("ml");
8484
assertNotNull(ml.description());
85-
assertFalse(ml.available());
85+
assertTrue(ml.available());
8686
assertTrue(ml.enabled());
8787
assertEquals(mainResponse.getVersion().toString(),
8888
ml.nativeCodeInfo().get("version").toString().replace("-SNAPSHOT", ""));

0 commit comments

Comments
 (0)