Skip to content

Commit 5fa2ab4

Browse files
committed
Merge branch 'master' into remove_thread_barrier
2 parents 5988b4b + 4ec3a6d commit 5fa2ab4

File tree

542 files changed

+8114
-7562
lines changed

Some content is hidden

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

542 files changed

+8114
-7562
lines changed

TESTING.asciidoc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ In order to start with a different distribution use the `-Drun.distribution` arg
4242
To for example start the open source distribution:
4343

4444
-------------------------------------
45-
./gradlew run -Drun.distribution=oss-zip
45+
./gradlew run -Drun.distribution=oss
4646
-------------------------------------
4747

4848
==== License type
@@ -631,3 +631,13 @@ inside `/etc/hosts`, e.g.:
631631
255.255.255.255 broadcasthost
632632
::1 localhost ElasticMBP.local`
633633
....
634+
635+
== Benchmarking
636+
637+
For changes that might affect the performance characteristics of Elasticsearch
638+
you should also run macrobenchmarks. We maintain a macrobenchmarking tool
639+
called https://github.com/elastic/rally[Rally]
640+
which you can use to measure the performance impact. It comes with a set of
641+
default benchmarks that we also
642+
https://elasticsearch-benchmarks.elastic.co/[run every night]. To get started,
643+
please see https://esrally.readthedocs.io/en/stable/[Rally's documentation].

benchmarks/src/main/java/org/elasticsearch/benchmark/time/DateFormatterBenchmark.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,3 @@ public TemporalAccessor parseJodaDate() {
5555
return jodaFormatter.parse("1234567890");
5656
}
5757
}
58-

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ class BuildPlugin implements Plugin<Project> {
392392
static void requireJavaHome(Task task, int version) {
393393
Project rootProject = task.project.rootProject // use root project for global accounting
394394
if (rootProject.hasProperty('requiredJavaVersions') == false) {
395-
rootProject.rootProject.ext.requiredJavaVersions = [:].withDefault{key -> return []}
395+
rootProject.rootProject.ext.requiredJavaVersions = [:]
396396
rootProject.gradle.taskGraph.whenReady { TaskExecutionGraph taskGraph ->
397397
List<String> messages = []
398398
for (entry in rootProject.requiredJavaVersions) {
@@ -415,7 +415,7 @@ class BuildPlugin implements Plugin<Project> {
415415
throw new GradleException("JAVA${version}_HOME required to run task:\n${task}")
416416
}
417417
} else {
418-
rootProject.requiredJavaVersions.get(version).add(task)
418+
rootProject.requiredJavaVersions.getOrDefault(version, []).add(task)
419419
}
420420
}
421421

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class DocsTestPlugin extends RestTestPlugin {
3434
project.pluginManager.apply('elasticsearch.standalone-rest-test')
3535
super.apply(project)
3636
// The distribution can be configured with -Dtests.distribution on the command line
37-
project.integTestCluster.distribution = System.getProperty('tests.distribution', 'zip')
37+
project.integTestCluster.distribution = System.getProperty('tests.distribution', 'default')
3838
// Docs are published separately so no need to assemble
3939
project.tasks.assemble.enabled = false
4040
Map<String, String> defaultSubstitutions = [

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ClusterConfiguration {
2929
private final Project project
3030

3131
@Input
32-
String distribution = 'zip'
32+
String distribution = 'default'
3333

3434
@Input
3535
int numNodes = 1

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

Lines changed: 22 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import org.elasticsearch.gradle.plugin.PluginPropertiesExtension
2929
import org.gradle.api.AntBuilder
3030
import org.gradle.api.DefaultTask
3131
import org.gradle.api.GradleException
32-
import org.gradle.api.InvalidUserDataException
3332
import org.gradle.api.Project
3433
import org.gradle.api.Task
3534
import org.gradle.api.artifacts.Configuration
@@ -87,7 +86,7 @@ class ClusterFormationTasks {
8786
Configuration currentDistro = project.configurations.create("${prefix}_elasticsearchDistro")
8887
Configuration bwcDistro = project.configurations.create("${prefix}_elasticsearchBwcDistro")
8988
Configuration bwcPlugins = project.configurations.create("${prefix}_elasticsearchBwcPlugins")
90-
if (System.getProperty('tests.distribution', 'oss-zip') == 'integ-test-zip') {
89+
if (System.getProperty('tests.distribution', 'oss') == 'integ-test-zip') {
9190
throw new Exception("tests.distribution=integ-test-zip is not supported")
9291
}
9392
configureDistributionDependency(project, config.distribution, currentDistro, VersionProperties.elasticsearch)
@@ -172,31 +171,31 @@ class ClusterFormationTasks {
172171

173172
/** Adds a dependency on the given distribution */
174173
static void configureDistributionDependency(Project project, String distro, Configuration configuration, String elasticsearchVersion) {
174+
// TEMP HACK
175+
// The oss docs CI build overrides the distro on the command line. This hack handles backcompat until CI is updated.
176+
if (distro.equals('oss-zip')) {
177+
distro = 'oss'
178+
}
179+
if (distro.equals('zip')) {
180+
distro = 'default'
181+
}
182+
// END TEMP HACK
183+
if (['integ-test-zip', 'oss', 'default'].contains(distro) == false) {
184+
throw new GradleException("Unknown distribution: ${distro} in project ${project.path}")
185+
}
175186
Version version = Version.fromString(elasticsearchVersion)
176187
if (version.before('6.3.0') && distro.startsWith('oss-')) {
177188
distro = distro.substring('oss-'.length())
178189
}
179-
String os = "linux"
180-
if (Os.FAMILY_WINDOWS) {
181-
os = "windows"
182-
} else if (Os.FAMILY_MAC) {
183-
os = "darwin"
184-
}
185-
String packaging = distro
186-
if (distro.contains('tar')) {
187-
packaging = 'tar.gz'\
188-
} else if (distro.contains('zip')) {
189-
packaging = 'zip'
190-
}
191-
String group = "downloads.${packaging}"
190+
String group = "downloads.zip"
192191
if (distro.equals("integ-test-zip")) {
193192
group = "org.elasticsearch.distribution.integ-test-zip"
194193
}
195194
String artifactName = 'elasticsearch'
196-
if (distro.contains('oss')) {
195+
if (distro.equals('oss') && Version.fromString(elasticsearchVersion).onOrAfter('6.3.0')) {
197196
artifactName += '-oss'
198197
}
199-
project.dependencies.add(configuration.name, "${group}:${artifactName}:${elasticsearchVersion}@${packaging}")
198+
project.dependencies.add(configuration.name, "${group}:${artifactName}:${elasticsearchVersion}@zip")
200199
}
201200

202201
/** Adds a dependency on a different version of the given plugin, which will be retrieved using gradle's dependency resolution */
@@ -319,31 +318,13 @@ class ClusterFormationTasks {
319318
elasticsearch source tree. If this is a plugin built in the elasticsearch source tree or this is a distro in
320319
the elasticsearch source tree then this should be the version of elasticsearch built by the source tree.
321320
If it isn't then Bad Things(TM) will happen. */
322-
Task extract
323-
324-
switch (node.config.distribution) {
325-
case 'integ-test-zip':
326-
case 'zip':
327-
case 'oss-zip':
328-
extract = project.tasks.create(name: name, type: Copy, dependsOn: extractDependsOn) {
329-
from {
330-
project.zipTree(configuration.singleFile)
331-
}
332-
into node.baseDir
333-
}
334-
break;
335-
case 'tar':
336-
case 'oss-tar':
337-
extract = project.tasks.create(name: name, type: Copy, dependsOn: extractDependsOn) {
338-
from {
339-
project.tarTree(project.resources.gzip(configuration.singleFile))
340-
}
341-
into node.baseDir
342-
}
343-
break;
344-
default:
345-
throw new InvalidUserDataException("Unknown distribution: ${node.config.distribution}")
321+
Task extract = project.tasks.create(name: name, type: Copy, dependsOn: extractDependsOn) {
322+
from {
323+
project.zipTree(configuration.singleFile)
324+
}
325+
into node.baseDir
346326
}
327+
347328
return extract
348329
}
349330

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

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ import org.gradle.api.Project
2929
import java.nio.file.Files
3030
import java.nio.file.Path
3131
import java.nio.file.Paths
32-
33-
import static org.elasticsearch.gradle.BuildPlugin.getJavaHome
34-
3532
/**
3633
* A container for the files and configuration associated with a single node in a test cluster.
3734
*/
@@ -125,8 +122,8 @@ class NodeInfo {
125122
baseDir = new File(project.buildDir, "cluster/${prefix} node${nodeNum}")
126123
pidFile = new File(baseDir, 'es.pid')
127124
this.nodeVersion = Version.fromString(nodeVersion)
128-
homeDir = homeDir(baseDir, config.distribution, nodeVersion)
129-
pathConf = pathConf(baseDir, config.distribution, nodeVersion)
125+
homeDir = new File(baseDir, "elasticsearch-${nodeVersion}")
126+
pathConf = new File(homeDir, 'config')
130127
if (config.dataDir != null) {
131128
dataDir = "${config.dataDir(nodeNum)}"
132129
} else {
@@ -299,41 +296,4 @@ class NodeInfo {
299296
}
300297
return dataDir
301298
}
302-
303-
/** Returns the directory elasticsearch home is contained in for the given distribution */
304-
static File homeDir(File baseDir, String distro, String nodeVersion) {
305-
String path
306-
switch (distro) {
307-
case 'integ-test-zip':
308-
case 'zip':
309-
case 'tar':
310-
case 'oss-zip':
311-
case 'oss-tar':
312-
path = "elasticsearch-${nodeVersion}"
313-
break
314-
case 'rpm':
315-
case 'deb':
316-
path = "${distro}-extracted/usr/share/elasticsearch"
317-
break
318-
default:
319-
throw new InvalidUserDataException("Unknown distribution: ${distro}")
320-
}
321-
return new File(baseDir, path)
322-
}
323-
324-
static File pathConf(File baseDir, String distro, String nodeVersion) {
325-
switch (distro) {
326-
case 'integ-test-zip':
327-
case 'zip':
328-
case 'oss-zip':
329-
case 'tar':
330-
case 'oss-tar':
331-
return new File(homeDir(baseDir, distro, nodeVersion), 'config')
332-
case 'rpm':
333-
case 'deb':
334-
return new File(baseDir, "${distro}-extracted/etc/elasticsearch")
335-
default:
336-
throw new InvalidUserDataException("Unknown distribution: ${distro}")
337-
}
338-
}
339299
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class RunTask extends DefaultTask {
1616
clusterConfig.httpPort = 9200
1717
clusterConfig.transportPort = 9300
1818
clusterConfig.daemonize = false
19-
clusterConfig.distribution = 'zip'
19+
clusterConfig.distribution = 'default'
2020
project.afterEvaluate {
2121
ClusterFormationTasks.setup(project, name, this, clusterConfig)
2222
}

buildSrc/src/main/java/org/elasticsearch/gradle/testfixtures/TestFixturesPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void apply(Project project) {
9696
if (dockerComposeSupported(project) == false) {
9797
project.getLogger().warn(
9898
"Tests for {} require docker-compose at /usr/local/bin/docker-compose or /usr/bin/docker-compose " +
99-
"but none could not be found so these will be skipped", project.getPath()
99+
"but none could be found so these will be skipped", project.getPath()
100100
);
101101
tasks.withType(getTaskClass("com.carrotsearch.gradle.junit4.RandomizedTestingTask"), task ->
102102
task.setEnabled(false)

buildSrc/version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
elasticsearch = 7.0.0
2-
lucene = 8.0.0-snapshot-a1c6e642aa
2+
lucene = 8.0.0-snapshot-83f9835
33

44
# optional dependencies
55
spatial4j = 0.7

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ public void testIndexPutSettings() throws IOException {
11771177
createIndex(index, Settings.EMPTY);
11781178

11791179
assertThat(dynamicSetting.getDefault(Settings.EMPTY), not(dynamicSettingValue));
1180-
UpdateSettingsRequest dynamicSettingRequest = new UpdateSettingsRequest();
1180+
UpdateSettingsRequest dynamicSettingRequest = new UpdateSettingsRequest(index);
11811181
dynamicSettingRequest.settings(Settings.builder().put(dynamicSettingKey, dynamicSettingValue).build());
11821182
AcknowledgedResponse response = execute(dynamicSettingRequest, highLevelClient().indices()::putSettings,
11831183
highLevelClient().indices()::putSettingsAsync);
@@ -1187,7 +1187,7 @@ public void testIndexPutSettings() throws IOException {
11871187
assertThat(indexSettingsAsMap.get(dynamicSettingKey), equalTo(String.valueOf(dynamicSettingValue)));
11881188

11891189
assertThat(staticSetting.getDefault(Settings.EMPTY), not(staticSettingValue));
1190-
UpdateSettingsRequest staticSettingRequest = new UpdateSettingsRequest();
1190+
UpdateSettingsRequest staticSettingRequest = new UpdateSettingsRequest(index);
11911191
staticSettingRequest.settings(Settings.builder().put(staticSettingKey, staticSettingValue).build());
11921192
ElasticsearchException exception = expectThrows(ElasticsearchException.class, () -> execute(staticSettingRequest,
11931193
highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync));
@@ -1207,7 +1207,7 @@ public void testIndexPutSettings() throws IOException {
12071207
assertThat(indexSettingsAsMap.get(staticSettingKey), equalTo(staticSettingValue));
12081208

12091209
assertThat(unmodifiableSetting.getDefault(Settings.EMPTY), not(unmodifiableSettingValue));
1210-
UpdateSettingsRequest unmodifiableSettingRequest = new UpdateSettingsRequest();
1210+
UpdateSettingsRequest unmodifiableSettingRequest = new UpdateSettingsRequest(index);
12111211
unmodifiableSettingRequest.settings(Settings.builder().put(unmodifiableSettingKey, unmodifiableSettingValue).build());
12121212
exception = expectThrows(ElasticsearchException.class, () -> execute(unmodifiableSettingRequest,
12131213
highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync));

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,22 @@ public void onFailure(Exception e) {
630630
public void testGetFollowStats() throws Exception {
631631
RestHighLevelClient client = highLevelClient();
632632

633+
{
634+
// Create leader index:
635+
CreateIndexRequest createIndexRequest = new CreateIndexRequest("leader");
636+
createIndexRequest.settings(Collections.singletonMap("index.soft_deletes.enabled", true));
637+
CreateIndexResponse response = client.indices().create(createIndexRequest, RequestOptions.DEFAULT);
638+
assertThat(response.isAcknowledged(), is(true));
639+
}
640+
{
641+
// Follow index, so that we can query for follow stats:
642+
PutFollowRequest putFollowRequest = new PutFollowRequest("local", "leader", "follower");
643+
PutFollowResponse putFollowResponse = client.ccr().putFollow(putFollowRequest, RequestOptions.DEFAULT);
644+
assertThat(putFollowResponse.isFollowIndexCreated(), is(true));
645+
assertThat(putFollowResponse.isFollowIndexShardsAcked(), is(true));
646+
assertThat(putFollowResponse.isIndexFollowingStarted(), is(true));
647+
}
648+
633649
// tag::ccr-get-follow-stats-request
634650
FollowStatsRequest request =
635651
new FollowStatsRequest("follower"); // <1>
@@ -671,6 +687,12 @@ public void onFailure(Exception e) {
671687
// end::ccr-get-follow-stats-execute-async
672688

673689
assertTrue(latch.await(30L, TimeUnit.SECONDS));
690+
691+
{
692+
PauseFollowRequest pauseFollowRequest = new PauseFollowRequest("follower");
693+
AcknowledgedResponse pauseFollowResponse = client.ccr().pauseFollow(pauseFollowRequest, RequestOptions.DEFAULT);
694+
assertThat(pauseFollowResponse.isAcknowledged(), is(true));
695+
}
674696
}
675697

676698
static Map<String, Object> toMap(Response response) throws IOException {

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@
1919

2020
package org.elasticsearch.client.indices;
2121

22-
import org.apache.lucene.util.LuceneTestCase.AwaitsFix;
2322
import org.elasticsearch.common.xcontent.XContentBuilder;
2423
import org.elasticsearch.common.xcontent.XContentParser;
2524
import org.elasticsearch.index.RandomCreateIndexGenerator;
2625
import org.elasticsearch.test.AbstractXContentTestCase;
2726

2827
import java.io.IOException;
28+
import java.util.Map;
2929

30-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/37654")
3130
public class PutMappingRequestTests extends AbstractXContentTestCase<PutMappingRequest> {
3231

3332
@Override
@@ -47,7 +46,10 @@ protected PutMappingRequest createTestInstance() {
4746
@Override
4847
protected PutMappingRequest doParseInstance(XContentParser parser) throws IOException {
4948
PutMappingRequest request = new PutMappingRequest();
50-
request.source(parser.map());
49+
Map<String, Object> map = parser.map();
50+
if (map.isEmpty() == false) {
51+
request.source(map);
52+
}
5153
return request;
5254
}
5355

@@ -58,11 +60,16 @@ protected boolean supportsUnknownFields() {
5860

5961
@Override
6062
protected void assertEqualInstances(PutMappingRequest expected, PutMappingRequest actual) {
61-
try (XContentParser expectedJson = createParser(expected.xContentType().xContent(), expected.source());
62-
XContentParser actualJson = createParser(actual.xContentType().xContent(), actual.source())) {
63-
assertEquals(expectedJson.mapOrdered(), actualJson.mapOrdered());
64-
} catch (IOException e) {
65-
throw new RuntimeException(e);
63+
if (actual.source() != null) {
64+
try (XContentParser expectedJson = createParser(expected.xContentType().xContent(), expected.source());
65+
XContentParser actualJson = createParser(actual.xContentType().xContent(), actual.source())) {
66+
assertEquals(expectedJson.mapOrdered(), actualJson.mapOrdered());
67+
} catch (IOException e) {
68+
throw new RuntimeException(e);
69+
}
70+
} else {
71+
// if the original `source` is null, the parsed source should be so too
72+
assertNull(expected.source());
6673
}
6774
}
6875
}

client/rest/src/main/java/org/elasticsearch/client/Response.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public HttpEntity getEntity() {
103103
private static final Pattern WARNING_HEADER_PATTERN = Pattern.compile(
104104
"299 " + // warn code
105105
"Elasticsearch-\\d+\\.\\d+\\.\\d+(?:-(?:alpha|beta|rc)\\d+)?(?:-SNAPSHOT)?-(?:[a-f0-9]{7}|Unknown) " + // warn agent
106-
"\"((?:\t| |!|[\\x23-\\x5B]|[\\x5D-\\x7E]|[\\x80-\\xFF]|\\\\|\\\\\")*)\" " + // quoted warning value, captured
106+
"\"((?:\t| |!|[\\x23-\\x5B]|[\\x5D-\\x7E]|[\\x80-\\xFF]|\\\\|\\\\\")*)\"( " + // quoted warning value, captured
107107
// quoted RFC 1123 date format
108108
"\"" + // opening quote
109109
"(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), " + // weekday
@@ -112,7 +112,7 @@ public HttpEntity getEntity() {
112112
"\\d{4} " + // 4-digit year
113113
"\\d{2}:\\d{2}:\\d{2} " + // (two-digit hour):(two-digit minute):(two-digit second)
114114
"GMT" + // GMT
115-
"\""); // closing quote
115+
"\")?"); // closing quote (optional, since an older version can still send a warn-date)
116116

117117
/**
118118
* Returns a list of all warning headers returned in the response.

distribution/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
337337
}
338338

339339
task run(type: RunTask) {
340-
distribution = System.getProperty('run.distribution', 'zip')
341-
if (distribution == 'zip') {
340+
distribution = System.getProperty('run.distribution', 'default')
341+
if (distribution == 'default') {
342342
String licenseType = System.getProperty("run.license_type", "basic")
343343
if (licenseType == 'trial') {
344344
setting 'xpack.ml.enabled', 'true'

0 commit comments

Comments
 (0)