Skip to content

Commit 0a7fdf8

Browse files
committed
Merge branch '6.x' into ccr-6.x
* 6.x: Fix double semicolon in import statement [TEST] Fix minor random bug from #30794 Enabling testing against an external cluster (#30885) SQL: Remove the last remaining server dependencies from jdbc (#30771) Add public key header/footer (#30877) Include size of snapshot in snapshot metadata (#29602) QA: Test template creation during rolling restart (#30850) REST high-level client: add put ingest pipeline API (#30793) Do not serialize basic license exp in x-pack info (#30848) [docs] explainer for java packaging tests (#30825) Verify signatures on official plugins (#30800) [DOCS] Document index name limitations (#30826) [Docs] Add reindex.remote.whitelist example (#30828)
2 parents 0b22392 + efb62db commit 0a7fdf8

File tree

83 files changed

+2231
-1020
lines changed

Some content is hidden

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

83 files changed

+2231
-1020
lines changed

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

+39-23
Original file line numberDiff line numberDiff line change
@@ -70,31 +70,44 @@ public class RestIntegTestTask extends DefaultTask {
7070
runner.parallelism = '1'
7171
runner.include('**/*IT.class')
7272
runner.systemProperty('tests.rest.load_packaged', 'false')
73-
// we pass all nodes to the rest cluster to allow the clients to round-robin between them
74-
// this is more realistic than just talking to a single node
75-
runner.systemProperty('tests.rest.cluster', "${-> nodes.collect{it.httpUri()}.join(",")}")
76-
runner.systemProperty('tests.config.dir', "${-> nodes[0].pathConf}")
77-
// TODO: our "client" qa tests currently use the rest-test plugin. instead they should have their own plugin
78-
// that sets up the test cluster and passes this transport uri instead of http uri. Until then, we pass
79-
// both as separate sysprops
80-
runner.systemProperty('tests.cluster', "${-> nodes[0].transportUri()}")
81-
82-
// dump errors and warnings from cluster log on failure
83-
TaskExecutionAdapter logDumpListener = new TaskExecutionAdapter() {
84-
@Override
85-
void afterExecute(Task task, TaskState state) {
86-
if (state.failure != null) {
87-
for (NodeInfo nodeInfo : nodes) {
88-
printLogExcerpt(nodeInfo)
73+
74+
if (System.getProperty("tests.rest.cluster") == null) {
75+
if (System.getProperty("tests.cluster") != null) {
76+
throw new IllegalArgumentException("tests.rest.cluster and tests.cluster must both be null or non-null")
77+
}
78+
// we pass all nodes to the rest cluster to allow the clients to round-robin between them
79+
// this is more realistic than just talking to a single node
80+
runner.systemProperty('tests.rest.cluster', "${-> nodes.collect{it.httpUri()}.join(",")}")
81+
runner.systemProperty('tests.config.dir', "${-> nodes[0].pathConf}")
82+
// TODO: our "client" qa tests currently use the rest-test plugin. instead they should have their own plugin
83+
// that sets up the test cluster and passes this transport uri instead of http uri. Until then, we pass
84+
// both as separate sysprops
85+
runner.systemProperty('tests.cluster', "${-> nodes[0].transportUri()}")
86+
87+
// dump errors and warnings from cluster log on failure
88+
TaskExecutionAdapter logDumpListener = new TaskExecutionAdapter() {
89+
@Override
90+
void afterExecute(Task task, TaskState state) {
91+
if (state.failure != null) {
92+
for (NodeInfo nodeInfo : nodes) {
93+
printLogExcerpt(nodeInfo)
94+
}
8995
}
9096
}
9197
}
92-
}
93-
runner.doFirst {
94-
project.gradle.addListener(logDumpListener)
95-
}
96-
runner.doLast {
97-
project.gradle.removeListener(logDumpListener)
98+
runner.doFirst {
99+
project.gradle.addListener(logDumpListener)
100+
}
101+
runner.doLast {
102+
project.gradle.removeListener(logDumpListener)
103+
}
104+
} else {
105+
if (System.getProperty("tests.cluster") == null) {
106+
throw new IllegalArgumentException("tests.rest.cluster and tests.cluster must both be null or non-null")
107+
}
108+
// an external cluster was specified and all responsibility for cluster configuration is taken by the user
109+
runner.systemProperty('tests.rest.cluster', System.getProperty("tests.rest.cluster"))
110+
runner.systemProperty('test.cluster', System.getProperty("tests.cluster"))
98111
}
99112

100113
// copy the rest spec/tests into the test resources
@@ -109,7 +122,10 @@ public class RestIntegTestTask extends DefaultTask {
109122
clusterInit.enabled = false
110123
return // no need to add cluster formation tasks if the task won't run!
111124
}
112-
nodes = ClusterFormationTasks.setup(project, "${name}Cluster", runner, clusterConfig)
125+
// only create the cluster if needed as otherwise an external cluster to use was specified
126+
if (System.getProperty("tests.rest.cluster") == null) {
127+
nodes = ClusterFormationTasks.setup(project, "${name}Cluster", runner, clusterConfig)
128+
}
113129
super.dependsOn(runner.finalizedBy)
114130
}
115131
}

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

+24
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse;
2626
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
2727
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse;
28+
import org.elasticsearch.action.ingest.PutPipelineRequest;
29+
import org.elasticsearch.action.ingest.PutPipelineResponse;
2830

2931
import java.io.IOException;
3032

@@ -87,4 +89,26 @@ public void listTasksAsync(ListTasksRequest request, ActionListener<ListTasksRes
8789
restHighLevelClient.performRequestAsyncAndParseEntity(request, RequestConverters::listTasks, ListTasksResponse::fromXContent,
8890
listener, emptySet(), headers);
8991
}
92+
93+
/**
94+
* Add a pipeline or update an existing pipeline in the cluster
95+
* <p>
96+
* See
97+
* <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/put-pipeline-api.html"> Put Pipeline API on elastic.co</a>
98+
*/
99+
public PutPipelineResponse putPipeline(PutPipelineRequest request, Header... headers) throws IOException {
100+
return restHighLevelClient.performRequestAndParseEntity( request, RequestConverters::putPipeline,
101+
PutPipelineResponse::fromXContent, emptySet(), headers);
102+
}
103+
104+
/**
105+
* Asynchronously add a pipeline or update an existing pipeline in the cluster
106+
* <p>
107+
* See
108+
* <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/put-pipeline-api.html"> Put Pipeline API on elastic.co</a>
109+
*/
110+
public void putPipelineAsync(PutPipelineRequest request, ActionListener<PutPipelineResponse> listener, Header... headers) {
111+
restHighLevelClient.performRequestAsyncAndParseEntity( request, RequestConverters::putPipeline,
112+
PutPipelineResponse::fromXContent, listener, emptySet(), headers);
113+
}
90114
}

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

+16
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import org.elasticsearch.action.get.GetRequest;
5959
import org.elasticsearch.action.get.MultiGetRequest;
6060
import org.elasticsearch.action.index.IndexRequest;
61+
import org.elasticsearch.action.ingest.PutPipelineRequest;
6162
import org.elasticsearch.action.search.ClearScrollRequest;
6263
import org.elasticsearch.action.search.MultiSearchRequest;
6364
import org.elasticsearch.action.search.SearchRequest;
@@ -620,6 +621,21 @@ static Request clusterPutSettings(ClusterUpdateSettingsRequest clusterUpdateSett
620621
return request;
621622
}
622623

624+
static Request putPipeline(PutPipelineRequest putPipelineRequest) throws IOException {
625+
String endpoint = new EndpointBuilder()
626+
.addPathPartAsIs("_ingest/pipeline")
627+
.addPathPart(putPipelineRequest.getId())
628+
.build();
629+
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
630+
631+
Params parameters = new Params(request);
632+
parameters.withTimeout(putPipelineRequest.timeout());
633+
parameters.withMasterTimeout(putPipelineRequest.masterNodeTimeout());
634+
635+
request.setEntity(createEntity(putPipelineRequest, REQUEST_BODY_CONTENT_TYPE));
636+
return request;
637+
}
638+
623639
static Request listTasks(ListTasksRequest listTaskRequest) {
624640
if (listTaskRequest.getTaskId() != null && listTaskRequest.getTaskId().isSet()) {
625641
throw new IllegalArgumentException("TaskId cannot be used for list tasks request");

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

+42
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,17 @@
2525
import org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup;
2626
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
2727
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse;
28+
import org.elasticsearch.action.ingest.PutPipelineRequest;
29+
import org.elasticsearch.action.ingest.PutPipelineResponse;
2830
import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider;
31+
import org.elasticsearch.common.bytes.BytesReference;
2932
import org.elasticsearch.common.settings.Settings;
3033
import org.elasticsearch.common.unit.ByteSizeUnit;
34+
import org.elasticsearch.common.xcontent.XContentBuilder;
3135
import org.elasticsearch.common.xcontent.XContentType;
3236
import org.elasticsearch.common.xcontent.support.XContentMapValues;
3337
import org.elasticsearch.indices.recovery.RecoverySettings;
38+
import org.elasticsearch.ingest.Pipeline;
3439
import org.elasticsearch.rest.RestStatus;
3540
import org.elasticsearch.tasks.TaskInfo;
3641

@@ -136,4 +141,41 @@ public void testListTasks() throws IOException {
136141
}
137142
assertTrue("List tasks were not found", listTasksFound);
138143
}
144+
145+
public void testPutPipeline() throws IOException {
146+
String id = "some_pipeline_id";
147+
XContentType xContentType = randomFrom(XContentType.values());
148+
XContentBuilder pipelineBuilder = XContentBuilder.builder(xContentType.xContent());
149+
pipelineBuilder.startObject();
150+
{
151+
pipelineBuilder.field(Pipeline.DESCRIPTION_KEY, "some random set of processors");
152+
pipelineBuilder.startArray(Pipeline.PROCESSORS_KEY);
153+
{
154+
pipelineBuilder.startObject().startObject("set");
155+
{
156+
pipelineBuilder
157+
.field("field", "foo")
158+
.field("value", "bar");
159+
}
160+
pipelineBuilder.endObject().endObject();
161+
pipelineBuilder.startObject().startObject("convert");
162+
{
163+
pipelineBuilder
164+
.field("field", "rank")
165+
.field("type", "integer");
166+
}
167+
pipelineBuilder.endObject().endObject();
168+
}
169+
pipelineBuilder.endArray();
170+
}
171+
pipelineBuilder.endObject();
172+
PutPipelineRequest request = new PutPipelineRequest(
173+
id,
174+
BytesReference.bytes(pipelineBuilder),
175+
pipelineBuilder.contentType());
176+
177+
PutPipelineResponse putPipelineResponse =
178+
execute(request, highLevelClient().cluster()::putPipeline, highLevelClient().cluster()::putPipelineAsync);
179+
assertTrue(putPipelineResponse.isAcknowledged());
180+
}
139181
}

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

+23
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
import org.elasticsearch.action.get.GetRequest;
6262
import org.elasticsearch.action.get.MultiGetRequest;
6363
import org.elasticsearch.action.index.IndexRequest;
64+
import org.elasticsearch.action.ingest.PutPipelineRequest;
6465
import org.elasticsearch.action.search.ClearScrollRequest;
6566
import org.elasticsearch.action.search.MultiSearchRequest;
6667
import org.elasticsearch.action.search.SearchRequest;
@@ -91,6 +92,7 @@
9192
import org.elasticsearch.common.xcontent.XContentHelper;
9293
import org.elasticsearch.common.xcontent.XContentParser;
9394
import org.elasticsearch.common.xcontent.XContentType;
95+
import org.elasticsearch.common.xcontent.json.JsonXContent;
9496
import org.elasticsearch.index.RandomCreateIndexGenerator;
9597
import org.elasticsearch.index.VersionType;
9698
import org.elasticsearch.index.query.TermQueryBuilder;
@@ -119,6 +121,7 @@
119121

120122
import java.io.IOException;
121123
import java.io.InputStream;
124+
import java.nio.charset.StandardCharsets;
122125
import java.nio.file.Path;
123126
import java.util.ArrayList;
124127
import java.util.Arrays;
@@ -1434,6 +1437,26 @@ public void testClusterPutSettings() throws IOException {
14341437
assertEquals(expectedParams, expectedRequest.getParameters());
14351438
}
14361439

1440+
public void testPutPipeline() throws IOException {
1441+
String pipelineId = "some_pipeline_id";
1442+
PutPipelineRequest request = new PutPipelineRequest(
1443+
"some_pipeline_id",
1444+
new BytesArray("{}".getBytes(StandardCharsets.UTF_8)),
1445+
XContentType.JSON
1446+
);
1447+
Map<String, String> expectedParams = new HashMap<>();
1448+
setRandomMasterTimeout(request, expectedParams);
1449+
setRandomTimeout(request::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams);
1450+
1451+
Request expectedRequest = RequestConverters.putPipeline(request);
1452+
StringJoiner endpoint = new StringJoiner("/", "/", "");
1453+
endpoint.add("_ingest/pipeline");
1454+
endpoint.add(pipelineId);
1455+
assertEquals(endpoint.toString(), expectedRequest.getEndpoint());
1456+
assertEquals(HttpPut.METHOD_NAME, expectedRequest.getMethod());
1457+
assertEquals(expectedParams, expectedRequest.getParameters());
1458+
}
1459+
14371460
public void testRollover() throws IOException {
14381461
RolloverRequest rolloverRequest = new RolloverRequest(randomAlphaOfLengthBetween(3, 10),
14391462
randomBoolean() ? null : randomAlphaOfLengthBetween(3, 10));

0 commit comments

Comments
 (0)