Skip to content

Commit 1325c25

Browse files
committed
Merge branch '6.x' into ccr-6.x
* 6.x: Unmute IndexUpgradeIT tests Forbid expensive query parts in ranking evaluation (#30151) Docs: Update HighLevelRestClient migration docs (#30544) Clients: Switch to new performRequest (#30543) [TEST] Fix typo in MovAvgIT test [TEST] Mute ML test that needs updating to following ml-cpp changes Moved tokenizers to analysis common module (#30538) Document woes between auto-expand-replicas and allocation filtering (#30531) [ML] Hide internal Job update options from the REST API (#30537) Deprecate not copy settings and explicitly disallow (#30404) Mute ShrinkIndexIT suite SQL: SYS TABLES ordered according to *DBC specs (#30530) [ML] Improve state persistence log message Build: Add mavenPlugin cluster configuration method (#30541) Re-enable FlushIT tests Bump Gradle heap to 2 GB (#30535) Bump Gradle heap to 1792m (#30484) SQL: Use request flavored methods in tests (#30345) Suppress hdfsFixture if there are spaces in the path (#30302) Delete temporary blobs before creating index file (#30528) Watcher: Remove TriggerEngine.getJobCount() (#30395) Use simpler write-once semantics for FS repository (#30435) Use simpler write-once semantics for HDFS repository (#30439) SQL: Improve correctness of SYS COLUMNS & TYPES (#30418) Mute two tests in FlushIT with @AwaitsFix. Fix incorrect template name in test case Build: Remove legacy bwc files from xpack (#30485) Security: Simplify security index listeners (#30466) Mute SharedClusterSnapshotRestoreIT#testSnapshotSucceedsAfterSnapshotFailure with @AwaitsFix. Add proper longitude validation in geo_polygon_query (#30497) Mute UnicastZenPingTests#testSimplePings with @AwaitsFix. Security: cleanup code in file stores (#30348) Security: fix TokenMetaData equals and hashcode (#30347) Mute two tests from SmokeTestWatcherWithSecurityClientYamlTestSuiteIT. Fix incorrect merged entry in changelog SQL: Improve compatibility with MS query (#30516) SQL: Fix parsing of dates with milliseconds (#30419)
2 parents 4785696 + 0359b55 commit 1325c25

File tree

185 files changed

+2251
-1882
lines changed

Some content is hidden

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

185 files changed

+2251
-1882
lines changed

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class ClusterConfiguration {
147147
// map from destination path, to source file
148148
Map<String, Object> extraConfigFiles = new HashMap<>()
149149

150-
LinkedHashMap<String, Project> plugins = new LinkedHashMap<>()
150+
LinkedHashMap<String, Object> plugins = new LinkedHashMap<>()
151151

152152
List<Project> modules = new ArrayList<>()
153153

@@ -185,6 +185,11 @@ class ClusterConfiguration {
185185
plugins.put(pluginProject.name, pluginProject)
186186
}
187187

188+
@Input
189+
void mavenPlugin(String name, String mavenCoords) {
190+
plugins.put(name, mavenCoords)
191+
}
192+
188193
/** Add a module to the cluster. The project must be an esplugin and have a single zip default artifact. */
189194
@Input
190195
void module(Project moduleProject) {

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

+61-42
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ class ClusterFormationTasks {
9999
// from mirrors using gradles built-in mechanism etc.
100100

101101
configureDistributionDependency(project, config.distribution, bwcDistro, config.bwcVersion)
102-
for (Map.Entry<String, Project> entry : config.plugins.entrySet()) {
103-
configureBwcPluginDependency("${prefix}_elasticsearchBwcPlugins", project, entry.getValue(), bwcPlugins, config.bwcVersion)
102+
for (Map.Entry<String, Object> entry : config.plugins.entrySet()) {
103+
configureBwcPluginDependency(project, entry.getValue(), bwcPlugins, config.bwcVersion)
104104
}
105105
bwcDistro.resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS)
106106
bwcPlugins.resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS)
@@ -150,10 +150,15 @@ class ClusterFormationTasks {
150150
}
151151

152152
/** Adds a dependency on a different version of the given plugin, which will be retrieved using gradle's dependency resolution */
153-
static void configureBwcPluginDependency(String name, Project project, Project pluginProject, Configuration configuration, Version elasticsearchVersion) {
154-
verifyProjectHasBuildPlugin(name, elasticsearchVersion, project, pluginProject)
155-
final String pluginName = findPluginName(pluginProject)
156-
project.dependencies.add(configuration.name, "org.elasticsearch.plugin:${pluginName}:${elasticsearchVersion}@zip")
153+
static void configureBwcPluginDependency(Project project, Object plugin, Configuration configuration, Version elasticsearchVersion) {
154+
if (plugin instanceof Project) {
155+
Project pluginProject = (Project)plugin
156+
verifyProjectHasBuildPlugin(configuration.name, elasticsearchVersion, project, pluginProject)
157+
final String pluginName = findPluginName(pluginProject)
158+
project.dependencies.add(configuration.name, "org.elasticsearch.plugin:${pluginName}:${elasticsearchVersion}@zip")
159+
} else {
160+
project.dependencies.add(configuration.name, "${plugin}@zip")
161+
}
157162
}
158163

159164
/**
@@ -210,9 +215,9 @@ class ClusterFormationTasks {
210215
}
211216

212217
// install plugins
213-
for (Map.Entry<String, Project> plugin : node.config.plugins.entrySet()) {
214-
String actionName = pluginTaskName('install', plugin.getKey(), 'Plugin')
215-
setup = configureInstallPluginTask(taskName(prefix, node, actionName), project, setup, node, plugin.getValue(), prefix)
218+
for (String pluginName : node.config.plugins.keySet()) {
219+
String actionName = pluginTaskName('install', pluginName, 'Plugin')
220+
setup = configureInstallPluginTask(taskName(prefix, node, actionName), project, setup, node, pluginName, prefix)
216221
}
217222

218223
// sets up any extra config files that need to be copied over to the ES instance;
@@ -448,31 +453,40 @@ class ClusterFormationTasks {
448453
Copy copyPlugins = project.tasks.create(name: name, type: Copy, dependsOn: setup)
449454

450455
List<FileCollection> pluginFiles = []
451-
for (Map.Entry<String, Project> plugin : node.config.plugins.entrySet()) {
456+
for (Map.Entry<String, Object> plugin : node.config.plugins.entrySet()) {
452457

453-
Project pluginProject = plugin.getValue()
454-
verifyProjectHasBuildPlugin(name, node.nodeVersion, project, pluginProject)
455-
String configurationName = pluginConfigurationName(prefix, pluginProject)
458+
String configurationName = pluginConfigurationName(prefix, plugin.key)
456459
Configuration configuration = project.configurations.findByName(configurationName)
457460
if (configuration == null) {
458461
configuration = project.configurations.create(configurationName)
459462
}
460-
project.dependencies.add(configurationName, project.dependencies.project(path: pluginProject.path, configuration: 'zip'))
461-
setup.dependsOn(pluginProject.tasks.bundlePlugin)
462-
463-
// also allow rest tests to use the rest spec from the plugin
464-
String copyRestSpecTaskName = pluginTaskName('copy', plugin.getKey(), 'PluginRestSpec')
465-
Copy copyRestSpec = project.tasks.findByName(copyRestSpecTaskName)
466-
for (File resourceDir : pluginProject.sourceSets.test.resources.srcDirs) {
467-
File restApiDir = new File(resourceDir, 'rest-api-spec/api')
468-
if (restApiDir.exists() == false) continue
469-
if (copyRestSpec == null) {
470-
copyRestSpec = project.tasks.create(name: copyRestSpecTaskName, type: Copy)
471-
copyPlugins.dependsOn(copyRestSpec)
472-
copyRestSpec.into(project.sourceSets.test.output.resourcesDir)
463+
464+
if (plugin.getValue() instanceof Project) {
465+
Project pluginProject = plugin.getValue()
466+
verifyProjectHasBuildPlugin(name, node.nodeVersion, project, pluginProject)
467+
468+
project.dependencies.add(configurationName, project.dependencies.project(path: pluginProject.path, configuration: 'zip'))
469+
setup.dependsOn(pluginProject.tasks.bundlePlugin)
470+
471+
// also allow rest tests to use the rest spec from the plugin
472+
String copyRestSpecTaskName = pluginTaskName('copy', plugin.getKey(), 'PluginRestSpec')
473+
Copy copyRestSpec = project.tasks.findByName(copyRestSpecTaskName)
474+
for (File resourceDir : pluginProject.sourceSets.test.resources.srcDirs) {
475+
File restApiDir = new File(resourceDir, 'rest-api-spec/api')
476+
if (restApiDir.exists() == false) continue
477+
if (copyRestSpec == null) {
478+
copyRestSpec = project.tasks.create(name: copyRestSpecTaskName, type: Copy)
479+
copyPlugins.dependsOn(copyRestSpec)
480+
copyRestSpec.into(project.sourceSets.test.output.resourcesDir)
481+
}
482+
copyRestSpec.from(resourceDir).include('rest-api-spec/api/**')
473483
}
474-
copyRestSpec.from(resourceDir).include('rest-api-spec/api/**')
484+
} else {
485+
project.dependencies.add(configurationName, "${plugin.getValue()}@zip")
475486
}
487+
488+
489+
476490
pluginFiles.add(configuration)
477491
}
478492

@@ -481,32 +495,37 @@ class ClusterFormationTasks {
481495
return copyPlugins
482496
}
483497

484-
private static String pluginConfigurationName(final String prefix, final Project project) {
485-
return "_plugin_${prefix}_${project.path}".replace(':', '_')
498+
private static String pluginConfigurationName(final String prefix, final String name) {
499+
return "_plugin_${prefix}_${name}".replace(':', '_')
486500
}
487501

488-
private static String pluginBwcConfigurationName(final String prefix, final Project project) {
489-
return "_plugin_bwc_${prefix}_${project.path}".replace(':', '_')
502+
private static String pluginBwcConfigurationName(final String prefix, final String name) {
503+
return "_plugin_bwc_${prefix}_${name}".replace(':', '_')
490504
}
491505

492506
/** Configures task to copy a plugin based on a zip file resolved using dependencies for an older version */
493507
static Task configureCopyBwcPluginsTask(String name, Project project, Task setup, NodeInfo node, String prefix) {
494508
Configuration bwcPlugins = project.configurations.getByName("${prefix}_elasticsearchBwcPlugins")
495-
for (Map.Entry<String, Project> plugin : node.config.plugins.entrySet()) {
496-
Project pluginProject = plugin.getValue()
497-
verifyProjectHasBuildPlugin(name, node.nodeVersion, project, pluginProject)
498-
String configurationName = pluginBwcConfigurationName(prefix, pluginProject)
509+
for (Map.Entry<String, Object> plugin : node.config.plugins.entrySet()) {
510+
String configurationName = pluginBwcConfigurationName(prefix, plugin.key)
499511
Configuration configuration = project.configurations.findByName(configurationName)
500512
if (configuration == null) {
501513
configuration = project.configurations.create(configurationName)
502514
}
503515

504-
final String depName = findPluginName(pluginProject)
516+
if (plugin.getValue() instanceof Project) {
517+
Project pluginProject = plugin.getValue()
518+
verifyProjectHasBuildPlugin(name, node.nodeVersion, project, pluginProject)
505519

506-
Dependency dep = bwcPlugins.dependencies.find {
507-
it.name == depName
520+
final String depName = findPluginName(pluginProject)
521+
522+
Dependency dep = bwcPlugins.dependencies.find {
523+
it.name == depName
524+
}
525+
configuration.dependencies.add(dep)
526+
} else {
527+
project.dependencies.add(configurationName, "${plugin.getValue()}@zip")
508528
}
509-
configuration.dependencies.add(dep)
510529
}
511530

512531
Copy copyPlugins = project.tasks.create(name: name, type: Copy, dependsOn: setup) {
@@ -531,12 +550,12 @@ class ClusterFormationTasks {
531550
return installModule
532551
}
533552

534-
static Task configureInstallPluginTask(String name, Project project, Task setup, NodeInfo node, Project plugin, String prefix) {
553+
static Task configureInstallPluginTask(String name, Project project, Task setup, NodeInfo node, String pluginName, String prefix) {
535554
final FileCollection pluginZip;
536555
if (node.nodeVersion != VersionProperties.elasticsearch) {
537-
pluginZip = project.configurations.getByName(pluginBwcConfigurationName(prefix, plugin))
556+
pluginZip = project.configurations.getByName(pluginBwcConfigurationName(prefix, pluginName))
538557
} else {
539-
pluginZip = project.configurations.getByName(pluginConfigurationName(prefix, plugin))
558+
pluginZip = project.configurations.getByName(pluginConfigurationName(prefix, pluginName))
540559
}
541560
// delay reading the file location until execution time by wrapping in a closure within a GString
542561
final Object file = "${-> new File(node.pluginsTmpDir, pluginZip.singleFile.getName()).toURI().toURL().toString()}"

client/benchmark/src/main/java/org/elasticsearch/client/benchmark/rest/RestClientBenchmark.java

+7-13
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,19 @@
1818
*/
1919
package org.elasticsearch.client.benchmark.rest;
2020

21-
import org.apache.http.HttpEntity;
2221
import org.apache.http.HttpHeaders;
2322
import org.apache.http.HttpHost;
2423
import org.apache.http.HttpStatus;
25-
import org.apache.http.client.config.RequestConfig;
26-
import org.apache.http.conn.ConnectionKeepAliveStrategy;
27-
import org.apache.http.entity.ContentType;
28-
import org.apache.http.entity.StringEntity;
29-
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
3024
import org.apache.http.message.BasicHeader;
31-
import org.apache.http.nio.entity.NStringEntity;
3225
import org.elasticsearch.ElasticsearchException;
26+
import org.elasticsearch.client.Request;
3327
import org.elasticsearch.client.Response;
3428
import org.elasticsearch.client.RestClient;
35-
import org.elasticsearch.client.RestClientBuilder;
3629
import org.elasticsearch.client.benchmark.AbstractBenchmark;
3730
import org.elasticsearch.client.benchmark.ops.bulk.BulkRequestExecutor;
3831
import org.elasticsearch.client.benchmark.ops.search.SearchRequestExecutor;
3932

4033
import java.io.IOException;
41-
import java.nio.charset.StandardCharsets;
4234
import java.util.Collections;
4335
import java.util.List;
4436
import java.util.Locale;
@@ -86,9 +78,10 @@ public boolean bulkIndex(List<String> bulkData) {
8678
bulkRequestBody.append(bulkItem);
8779
bulkRequestBody.append("\n");
8880
}
89-
HttpEntity entity = new NStringEntity(bulkRequestBody.toString(), ContentType.APPLICATION_JSON);
81+
Request request = new Request("POST", "/geonames/type/_noop_bulk");
82+
request.setJsonEntity(bulkRequestBody.toString());
9083
try {
91-
Response response = client.performRequest("POST", "/geonames/type/_noop_bulk", Collections.emptyMap(), entity);
84+
Response response = client.performRequest(request);
9285
return response.getStatusLine().getStatusCode() == HttpStatus.SC_OK;
9386
} catch (Exception e) {
9487
throw new ElasticsearchException(e);
@@ -107,9 +100,10 @@ private RestSearchRequestExecutor(RestClient client, String indexName) {
107100

108101
@Override
109102
public boolean search(String source) {
110-
HttpEntity searchBody = new NStringEntity(source, StandardCharsets.UTF_8);
103+
Request request = new Request("GET", endpoint);
104+
request.setJsonEntity(source);
111105
try {
112-
Response response = client.performRequest("GET", endpoint, Collections.emptyMap(), searchBody);
106+
Response response = client.performRequest(request);
113107
return response.getStatusLine().getStatusCode() == HttpStatus.SC_OK;
114108
} catch (IOException e) {
115109
throw new ElasticsearchException(e);

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

+4-6
Original file line numberDiff line numberDiff line change
@@ -194,18 +194,16 @@ public void testBulkProcessorWaitOnClose() throws Exception {
194194
}
195195

196196
public void testBulkProcessorConcurrentRequestsReadOnlyIndex() throws Exception {
197-
198-
String createIndexBody = "{\n" +
197+
Request request = new Request("PUT", "/test-ro");
198+
request.setJsonEntity("{\n" +
199199
" \"settings\" : {\n" +
200200
" \"index\" : {\n" +
201201
" \"blocks.write\" : true\n" +
202202
" }\n" +
203203
" }\n" +
204204
" \n" +
205-
"}";
206-
207-
NStringEntity entity = new NStringEntity(createIndexBody, ContentType.APPLICATION_JSON);
208-
Response response = client().performRequest("PUT", "/test-ro", Collections.emptyMap(), entity);
205+
"}");
206+
Response response = client().performRequest(request);
209207
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
210208

211209
int bulkActions = randomIntBetween(10, 100);

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

+18-25
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919

2020
package org.elasticsearch.client;
2121

22-
import org.apache.http.client.methods.HttpPut;
23-
import org.apache.http.entity.ContentType;
24-
import org.apache.http.entity.StringEntity;
2522
import org.elasticsearch.ElasticsearchException;
2623
import org.elasticsearch.ElasticsearchStatusException;
2724
import org.elasticsearch.action.DocWriteRequest;
@@ -39,6 +36,7 @@
3936
import org.elasticsearch.action.get.MultiGetResponse;
4037
import org.elasticsearch.action.index.IndexRequest;
4138
import org.elasticsearch.action.index.IndexResponse;
39+
import org.elasticsearch.action.support.WriteRequest.RefreshPolicy;
4240
import org.elasticsearch.action.update.UpdateRequest;
4341
import org.elasticsearch.action.update.UpdateResponse;
4442
import org.elasticsearch.common.Strings;
@@ -147,11 +145,10 @@ public void testExists() throws IOException {
147145
GetRequest getRequest = new GetRequest("index", "type", "id");
148146
assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync));
149147
}
150-
String document = "{\"field1\":\"value1\",\"field2\":\"value2\"}";
151-
StringEntity stringEntity = new StringEntity(document, ContentType.APPLICATION_JSON);
152-
Response response = client().performRequest(HttpPut.METHOD_NAME, "/index/type/id", Collections.singletonMap("refresh", "wait_for"),
153-
stringEntity);
154-
assertEquals(201, response.getStatusLine().getStatusCode());
148+
IndexRequest index = new IndexRequest("index", "type", "id");
149+
index.source("{\"field1\":\"value1\",\"field2\":\"value2\"}", XContentType.JSON);
150+
index.setRefreshPolicy(RefreshPolicy.IMMEDIATE);
151+
highLevelClient().index(index);
155152
{
156153
GetRequest getRequest = new GetRequest("index", "type", "id");
157154
assertTrue(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync));
@@ -175,12 +172,11 @@ public void testGet() throws IOException {
175172
assertEquals("Elasticsearch exception [type=index_not_found_exception, reason=no such index]", exception.getMessage());
176173
assertEquals("index", exception.getMetadata("es.index").get(0));
177174
}
178-
175+
IndexRequest index = new IndexRequest("index", "type", "id");
179176
String document = "{\"field1\":\"value1\",\"field2\":\"value2\"}";
180-
StringEntity stringEntity = new StringEntity(document, ContentType.APPLICATION_JSON);
181-
Response response = client().performRequest(HttpPut.METHOD_NAME, "/index/type/id", Collections.singletonMap("refresh", "wait_for"),
182-
stringEntity);
183-
assertEquals(201, response.getStatusLine().getStatusCode());
177+
index.source(document, XContentType.JSON);
178+
index.setRefreshPolicy(RefreshPolicy.IMMEDIATE);
179+
highLevelClient().index(index);
184180
{
185181
GetRequest getRequest = new GetRequest("index", "type", "id").version(2);
186182
ElasticsearchException exception = expectThrows(ElasticsearchException.class,
@@ -271,18 +267,15 @@ public void testMultiGet() throws IOException {
271267
assertEquals("Elasticsearch exception [type=index_not_found_exception, reason=no such index]",
272268
response.getResponses()[1].getFailure().getFailure().getMessage());
273269
}
274-
275-
String document = "{\"field\":\"value1\"}";
276-
StringEntity stringEntity = new StringEntity(document, ContentType.APPLICATION_JSON);
277-
Response r = client().performRequest(HttpPut.METHOD_NAME, "/index/type/id1", Collections.singletonMap("refresh", "true"),
278-
stringEntity);
279-
assertEquals(201, r.getStatusLine().getStatusCode());
280-
281-
document = "{\"field\":\"value2\"}";
282-
stringEntity = new StringEntity(document, ContentType.APPLICATION_JSON);
283-
r = client().performRequest(HttpPut.METHOD_NAME, "/index/type/id2", Collections.singletonMap("refresh", "true"), stringEntity);
284-
assertEquals(201, r.getStatusLine().getStatusCode());
285-
270+
BulkRequest bulk = new BulkRequest();
271+
bulk.setRefreshPolicy(RefreshPolicy.IMMEDIATE);
272+
IndexRequest index = new IndexRequest("index", "type", "id1");
273+
index.source("{\"field\":\"value1\"}", XContentType.JSON);
274+
bulk.add(index);
275+
index = new IndexRequest("index", "type", "id2");
276+
index.source("{\"field\":\"value2\"}", XContentType.JSON);
277+
bulk.add(index);
278+
highLevelClient().bulk(bulk);
286279
{
287280
MultiGetRequest multiGetRequest = new MultiGetRequest();
288281
multiGetRequest.add("index", "type", "id1");

0 commit comments

Comments
 (0)