Skip to content

Commit e083f5b

Browse files
committed
Merge remote-tracking branch 'es/ccr' into ccr_security
* es/ccr: (37 commits) Default to one shard (#30539) 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 Add missing dependencies on testClasses (#30527) [TEST] Mute ML test that needs updating to following ml-cpp changes Document woes between auto-expand-replicas and allocation filtering (#30531) Moved tokenizers to analysis common module (#30538) Adjust copy settings versions Mute ShrinkIndexIT suite SQL: SYS TABLES ordered according to *DBC specs (#30530) Deprecate not copy settings and explicitly disallow (#30404) [ML] Improve state persistence log message Build: Add mavenPlugin cluster configuration method (#30541) Re-enable FlushIT tests Bump Gradle heap to 2 GB (#30535) SQL: Use request flavored methods in tests (#30345) Suppress hdfsFixture if there are spaces in the path (#30302) ...
2 parents 6f969f5 + b971a81 commit e083f5b

File tree

182 files changed

+2106
-1391
lines changed

Some content is hidden

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

182 files changed

+2106
-1391
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,7 @@ class BuildPlugin implements Plugin<Project> {
744744
additionalTest.testClassesDir = test.testClassesDir
745745
additionalTest.configure(commonTestConfig(project))
746746
additionalTest.configure(config)
747+
additionalTest.dependsOn(project.tasks.testClasses)
747748
test.dependsOn(additionalTest)
748749
});
749750
return test

buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/RestTestsFromSnippetsTask.groovy

+1
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
225225
* warning every time. */
226226
current.println(" - skip:")
227227
current.println(" features: ")
228+
current.println(" - default_shards")
228229
current.println(" - stash_in_key")
229230
current.println(" - stash_in_path")
230231
current.println(" - stash_path_replace")

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;
@@ -444,31 +449,40 @@ class ClusterFormationTasks {
444449
Copy copyPlugins = project.tasks.create(name: name, type: Copy, dependsOn: setup)
445450

446451
List<FileCollection> pluginFiles = []
447-
for (Map.Entry<String, Project> plugin : node.config.plugins.entrySet()) {
452+
for (Map.Entry<String, Object> plugin : node.config.plugins.entrySet()) {
448453

449-
Project pluginProject = plugin.getValue()
450-
verifyProjectHasBuildPlugin(name, node.nodeVersion, project, pluginProject)
451-
String configurationName = pluginConfigurationName(prefix, pluginProject)
454+
String configurationName = pluginConfigurationName(prefix, plugin.key)
452455
Configuration configuration = project.configurations.findByName(configurationName)
453456
if (configuration == null) {
454457
configuration = project.configurations.create(configurationName)
455458
}
456-
project.dependencies.add(configurationName, project.dependencies.project(path: pluginProject.path, configuration: 'zip'))
457-
setup.dependsOn(pluginProject.tasks.bundlePlugin)
458-
459-
// also allow rest tests to use the rest spec from the plugin
460-
String copyRestSpecTaskName = pluginTaskName('copy', plugin.getKey(), 'PluginRestSpec')
461-
Copy copyRestSpec = project.tasks.findByName(copyRestSpecTaskName)
462-
for (File resourceDir : pluginProject.sourceSets.test.resources.srcDirs) {
463-
File restApiDir = new File(resourceDir, 'rest-api-spec/api')
464-
if (restApiDir.exists() == false) continue
465-
if (copyRestSpec == null) {
466-
copyRestSpec = project.tasks.create(name: copyRestSpecTaskName, type: Copy)
467-
copyPlugins.dependsOn(copyRestSpec)
468-
copyRestSpec.into(project.sourceSets.test.output.resourcesDir)
459+
460+
if (plugin.getValue() instanceof Project) {
461+
Project pluginProject = plugin.getValue()
462+
verifyProjectHasBuildPlugin(name, node.nodeVersion, project, pluginProject)
463+
464+
project.dependencies.add(configurationName, project.dependencies.project(path: pluginProject.path, configuration: 'zip'))
465+
setup.dependsOn(pluginProject.tasks.bundlePlugin)
466+
467+
// also allow rest tests to use the rest spec from the plugin
468+
String copyRestSpecTaskName = pluginTaskName('copy', plugin.getKey(), 'PluginRestSpec')
469+
Copy copyRestSpec = project.tasks.findByName(copyRestSpecTaskName)
470+
for (File resourceDir : pluginProject.sourceSets.test.resources.srcDirs) {
471+
File restApiDir = new File(resourceDir, 'rest-api-spec/api')
472+
if (restApiDir.exists() == false) continue
473+
if (copyRestSpec == null) {
474+
copyRestSpec = project.tasks.create(name: copyRestSpecTaskName, type: Copy)
475+
copyPlugins.dependsOn(copyRestSpec)
476+
copyRestSpec.into(project.sourceSets.test.output.resourcesDir)
477+
}
478+
copyRestSpec.from(resourceDir).include('rest-api-spec/api/**')
469479
}
470-
copyRestSpec.from(resourceDir).include('rest-api-spec/api/**')
480+
} else {
481+
project.dependencies.add(configurationName, "${plugin.getValue()}@zip")
471482
}
483+
484+
485+
472486
pluginFiles.add(configuration)
473487
}
474488

@@ -477,32 +491,37 @@ class ClusterFormationTasks {
477491
return copyPlugins
478492
}
479493

480-
private static String pluginConfigurationName(final String prefix, final Project project) {
481-
return "_plugin_${prefix}_${project.path}".replace(':', '_')
494+
private static String pluginConfigurationName(final String prefix, final String name) {
495+
return "_plugin_${prefix}_${name}".replace(':', '_')
482496
}
483497

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

488502
/** Configures task to copy a plugin based on a zip file resolved using dependencies for an older version */
489503
static Task configureCopyBwcPluginsTask(String name, Project project, Task setup, NodeInfo node, String prefix) {
490504
Configuration bwcPlugins = project.configurations.getByName("${prefix}_elasticsearchBwcPlugins")
491-
for (Map.Entry<String, Project> plugin : node.config.plugins.entrySet()) {
492-
Project pluginProject = plugin.getValue()
493-
verifyProjectHasBuildPlugin(name, node.nodeVersion, project, pluginProject)
494-
String configurationName = pluginBwcConfigurationName(prefix, pluginProject)
505+
for (Map.Entry<String, Object> plugin : node.config.plugins.entrySet()) {
506+
String configurationName = pluginBwcConfigurationName(prefix, plugin.key)
495507
Configuration configuration = project.configurations.findByName(configurationName)
496508
if (configuration == null) {
497509
configuration = project.configurations.create(configurationName)
498510
}
499511

500-
final String depName = findPluginName(pluginProject)
512+
if (plugin.getValue() instanceof Project) {
513+
Project pluginProject = plugin.getValue()
514+
verifyProjectHasBuildPlugin(name, node.nodeVersion, project, pluginProject)
501515

502-
Dependency dep = bwcPlugins.dependencies.find {
503-
it.name == depName
516+
final String depName = findPluginName(pluginProject)
517+
518+
Dependency dep = bwcPlugins.dependencies.find {
519+
it.name == depName
520+
}
521+
configuration.dependencies.add(dep)
522+
} else {
523+
project.dependencies.add(configurationName, "${plugin.getValue()}@zip")
504524
}
505-
configuration.dependencies.add(dep)
506525
}
507526

508527
Copy copyPlugins = project.tasks.create(name: name, type: Copy, dependsOn: setup) {
@@ -527,12 +546,12 @@ class ClusterFormationTasks {
527546
return installModule
528547
}
529548

530-
static Task configureInstallPluginTask(String name, Project project, Task setup, NodeInfo node, Project plugin, String prefix) {
549+
static Task configureInstallPluginTask(String name, Project project, Task setup, NodeInfo node, String pluginName, String prefix) {
531550
final FileCollection pluginZip;
532551
if (node.nodeVersion != VersionProperties.elasticsearch) {
533-
pluginZip = project.configurations.getByName(pluginBwcConfigurationName(prefix, plugin))
552+
pluginZip = project.configurations.getByName(pluginBwcConfigurationName(prefix, pluginName))
534553
} else {
535-
pluginZip = project.configurations.getByName(pluginConfigurationName(prefix, plugin))
554+
pluginZip = project.configurations.getByName(pluginConfigurationName(prefix, pluginName))
536555
}
537556
// delay reading the file location until execution time by wrapping in a closure within a GString
538557
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)