Skip to content

Commit 8b3f218

Browse files
committed
Merge remote-tracking branch 'es/6.x' into ccr-6.x
* es/6.x: Enable skipping fetching latest for BWC builds (#29497) Add remote cluster client (#29495) Ensure flush happens on shard idle Adds SpanGapQueryBuilder in the query DSL (#28636) Fix auto-generated ID example format (#29461) Fix typo in max number of threads check docs (#29469) Add primary term to translog header (#29227) Add a helper method to get a random java.util.TimeZone (#29487) Move TimeValue into elasticsearch-core project (#29486) Fix NPE in InternalGeoCentroidTests#testReduceRandom (#29481) Build: introduce keystoreFile for cluster config (#29491) test: Index more docs, so that it is less likely the search request does not time out.
2 parents 7870029 + bb3bd10 commit 8b3f218

File tree

62 files changed

+1519
-565
lines changed

Some content is hidden

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

62 files changed

+1519
-565
lines changed

TESTING.asciidoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,13 @@ will contain your change.
498498
. Push both branches to your remote repository.
499499
. Run the tests with `./gradlew check -Dtests.bwc.remote=${remote} -Dtests.bwc.refspec.5.x=index_req_bwc_5.x`.
500500

501+
== Skip fetching latest
502+
503+
For some BWC testing scenarios, you want to use the local clone of the
504+
repository without fetching latest. For these use cases, you can set the system
505+
property `tests.bwc.git_fetch_latest` to `false` and the BWC builds will skip
506+
fetching the latest from the remote.
507+
501508
== Test coverage analysis
502509

503510
Generating test coverage reports for Elasticsearch is currently not possible through Gradle.

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ class ClusterConfiguration {
141141

142142
Map<String, String> keystoreSettings = new HashMap<>()
143143

144+
Map<String, Object> keystoreFiles = new HashMap<>()
145+
144146
// map from destination path, to source file
145147
Map<String, Object> extraConfigFiles = new HashMap<>()
146148

@@ -167,6 +169,15 @@ class ClusterConfiguration {
167169
keystoreSettings.put(name, value)
168170
}
169171

172+
/**
173+
* Adds a file to the keystore. The name is the secure setting name, and the sourceFile
174+
* is anything accepted by project.file()
175+
*/
176+
@Input
177+
void keystoreFile(String name, Object sourceFile) {
178+
keystoreFiles.put(name, sourceFile)
179+
}
180+
170181
@Input
171182
void plugin(String path) {
172183
Project pluginProject = project.project(path)

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ class ClusterFormationTasks {
180180
setup = configureWriteConfigTask(taskName(prefix, node, 'configure'), project, setup, node, seedNode)
181181
setup = configureCreateKeystoreTask(taskName(prefix, node, 'createKeystore'), project, setup, node)
182182
setup = configureAddKeystoreSettingTasks(prefix, project, setup, node)
183+
setup = configureAddKeystoreFileTasks(prefix, project, setup, node)
183184

184185
if (node.config.plugins.isEmpty() == false) {
185186
if (node.nodeVersion == VersionProperties.elasticsearch) {
@@ -327,7 +328,7 @@ class ClusterFormationTasks {
327328

328329
/** Adds a task to create keystore */
329330
static Task configureCreateKeystoreTask(String name, Project project, Task setup, NodeInfo node) {
330-
if (node.config.keystoreSettings.isEmpty()) {
331+
if (node.config.keystoreSettings.isEmpty() && node.config.keystoreFiles.isEmpty()) {
331332
return setup
332333
} else {
333334
/*
@@ -361,6 +362,37 @@ class ClusterFormationTasks {
361362
return parentTask
362363
}
363364

365+
/** Adds tasks to add files to the keystore */
366+
static Task configureAddKeystoreFileTasks(String parent, Project project, Task setup, NodeInfo node) {
367+
Map<String, Object> kvs = node.config.keystoreFiles
368+
if (kvs.isEmpty()) {
369+
return setup
370+
}
371+
Task parentTask = setup
372+
/*
373+
* We have to delay building the string as the path will not exist during configuration which will fail on Windows due to getting
374+
* the short name requiring the path to already exist.
375+
*/
376+
final Object esKeystoreUtil = "${-> node.binPath().resolve('elasticsearch-keystore').toString()}"
377+
for (Map.Entry<String, Object> entry in kvs) {
378+
String key = entry.getKey()
379+
String name = taskName(parent, node, 'addToKeystore#' + key)
380+
String srcFileName = entry.getValue()
381+
Task t = configureExecTask(name, project, parentTask, node, esKeystoreUtil, 'add-file', key, srcFileName)
382+
t.doFirst {
383+
File srcFile = project.file(srcFileName)
384+
if (srcFile.isDirectory()) {
385+
throw new GradleException("Source for keystoreFile must be a file: ${srcFile}")
386+
}
387+
if (srcFile.exists() == false) {
388+
throw new GradleException("Source file for keystoreFile does not exist: ${srcFile}")
389+
}
390+
}
391+
parentTask = t
392+
}
393+
return parentTask
394+
}
395+
364396
static Task configureExtraConfigFilesTask(String name, Project project, Task setup, NodeInfo node) {
365397
if (node.config.extraConfigFiles.isEmpty()) {
366398
return setup

distribution/bwc/build.gradle

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ subprojects {
5454

5555
final String remote = System.getProperty("tests.bwc.remote", "elastic")
5656

57+
final boolean gitFetchLatest
58+
final String gitFetchLatestProperty = System.getProperty("tests.bwc.git_fetch_latest", "true")
59+
if ("true".equals(gitFetchLatestProperty)) {
60+
gitFetchLatest = true
61+
} else if ("false".equals(gitFetchLatestProperty)) {
62+
gitFetchLatest = false
63+
} else {
64+
throw new GradleException("tests.bwc.git_fetch_latest must be [true] or [false] but was [" + gitFetchLatestProperty + "]")
65+
}
66+
5767
task createClone(type: LoggedExec) {
5868
onlyIf { checkoutDir.exists() == false }
5969
commandLine = ['git', 'clone', rootDir, checkoutDir]
@@ -83,7 +93,7 @@ subprojects {
8393
}
8494

8595
task fetchLatest(type: LoggedExec) {
86-
onlyIf { project.gradle.startParameter.isOffline() == false }
96+
onlyIf { project.gradle.startParameter.isOffline() == false && gitFetchLatest }
8797
dependsOn addRemote
8898
workingDir = checkoutDir
8999
commandLine = ['git', 'fetch', '--all']

docs/reference/docs/index_.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,14 @@ The result of the above index operation is:
229229
},
230230
"_index" : "twitter",
231231
"_type" : "_doc",
232-
"_id" : "6a8ca01c-7896-48e9-81cc-9f70661fcb32",
232+
"_id" : "W0tpsmIBdwcYyG50zbta",
233233
"_version" : 1,
234234
"_seq_no" : 0,
235235
"_primary_term" : 1,
236236
"result": "created"
237237
}
238238
--------------------------------------------------
239-
// TESTRESPONSE[s/6a8ca01c-7896-48e9-81cc-9f70661fcb32/$body._id/ s/"successful" : 2/"successful" : 1/]
239+
// TESTRESPONSE[s/W0tpsmIBdwcYyG50zbta/$body._id/ s/"successful" : 2/"successful" : 1/]
240240

241241
[float]
242242
[[index-routing]]

docs/reference/setup/bootstrap-checks.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ that the Elasticsearch process has the rights to create enough threads
114114
under normal use. This check is enforced only on Linux. If you are on
115115
Linux, to pass the maximum number of threads check, you must configure
116116
your system to allow the Elasticsearch process the ability to create at
117-
least 2048 threads. This can be done via `/etc/security/limits.conf`
117+
least 4096 threads. This can be done via `/etc/security/limits.conf`
118118
using the `nproc` setting (note that you might have to increase the
119119
limits for the `root` user too).
120120

server/src/main/java/org/elasticsearch/common/unit/TimeValue.java renamed to libs/elasticsearch-core/src/main/java/org/elasticsearch/common/unit/TimeValue.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,12 @@
1919

2020
package org.elasticsearch.common.unit;
2121

22-
import org.elasticsearch.common.xcontent.ToXContentFragment;
23-
import org.elasticsearch.common.xcontent.XContentBuilder;
24-
2522
import java.io.IOException;
2623
import java.util.Locale;
2724
import java.util.Objects;
2825
import java.util.concurrent.TimeUnit;
2926

30-
public class TimeValue implements Comparable<TimeValue>, ToXContentFragment {
27+
public class TimeValue implements Comparable<TimeValue> {
3128

3229
/** How many nano-seconds in one milli-second */
3330
public static final long NSEC_PER_MSEC = TimeUnit.NANOSECONDS.convert(1, TimeUnit.MILLISECONDS);
@@ -352,9 +349,4 @@ public int compareTo(TimeValue timeValue) {
352349
double otherValue = ((double) timeValue.duration) * timeValue.timeUnit.toNanos(1);
353350
return Double.compare(thisValue, otherValue);
354351
}
355-
356-
@Override
357-
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
358-
return builder.value(toString());
359-
}
360352
}

server/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java renamed to libs/elasticsearch-core/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,10 @@
1919

2020
package org.elasticsearch.common.unit;
2121

22-
import org.elasticsearch.common.io.stream.BytesStreamOutput;
23-
import org.elasticsearch.common.io.stream.StreamInput;
2422
import org.elasticsearch.test.ESTestCase;
2523

26-
import java.io.IOException;
2724
import java.util.concurrent.TimeUnit;
2825

29-
import static org.elasticsearch.common.unit.TimeValue.timeValueNanos;
30-
import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds;
3126
import static org.hamcrest.CoreMatchers.instanceOf;
3227
import static org.hamcrest.CoreMatchers.not;
3328
import static org.hamcrest.Matchers.containsString;
@@ -154,31 +149,6 @@ private String randomTimeUnit() {
154149
return randomFrom("nanos", "micros", "ms", "s", "m", "h", "d");
155150
}
156151

157-
private void assertEqualityAfterSerialize(TimeValue value, int expectedSize) throws IOException {
158-
BytesStreamOutput out = new BytesStreamOutput();
159-
out.writeTimeValue(value);
160-
assertEquals(expectedSize, out.size());
161-
162-
StreamInput in = out.bytes().streamInput();
163-
TimeValue inValue = in.readTimeValue();
164-
165-
assertThat(inValue, equalTo(value));
166-
assertThat(inValue.duration(), equalTo(value.duration()));
167-
assertThat(inValue.timeUnit(), equalTo(value.timeUnit()));
168-
}
169-
170-
public void testSerialize() throws Exception {
171-
assertEqualityAfterSerialize(new TimeValue(100, TimeUnit.DAYS), 3);
172-
assertEqualityAfterSerialize(timeValueNanos(-1), 2);
173-
assertEqualityAfterSerialize(timeValueNanos(1), 2);
174-
assertEqualityAfterSerialize(timeValueSeconds(30), 2);
175-
176-
final TimeValue timeValue = new TimeValue(randomIntBetween(0, 1024), randomFrom(TimeUnit.values()));
177-
BytesStreamOutput out = new BytesStreamOutput();
178-
out.writeZLong(timeValue.duration());
179-
assertEqualityAfterSerialize(timeValue, 1 + out.bytes().length());
180-
}
181-
182152
public void testFailOnUnknownUnits() {
183153
try {
184154
TimeValue.parseTimeValue("23tw", null, "test");

plugins/repository-gcs/build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ task createServiceAccountFile() {
9494

9595
integTestCluster {
9696
dependsOn createServiceAccountFile, googleCloudStorageFixture
97-
setupCommand 'create-elasticsearch-keystore', 'bin/elasticsearch-keystore', 'create'
98-
setupCommand 'add-credentials-to-elasticsearch-keystore',
99-
'bin/elasticsearch-keystore', 'add-file', 'gcs.client.integration_test.credentials_file', "${serviceAccountFile.absolutePath}"
97+
keystoreFile 'gcs.client.integration_test.credentials_file', "${serviceAccountFile.absolutePath}"
10098

10199
/* Use a closure on the string to delay evaluation until tests are executed */
102100
setting 'gcs.client.integration_test.endpoint', "http://${ -> googleCloudStorageFixture.addressAndPort }"

server/src/main/java/org/elasticsearch/client/Client.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,4 +477,14 @@ public interface Client extends ElasticsearchClient, Releasable {
477477
* issued from it.
478478
*/
479479
Client filterWithHeader(Map<String, String> headers);
480+
481+
/**
482+
* Returns a client to a remote cluster with the given cluster alias.
483+
*
484+
* @throws IllegalArgumentException if the given clusterAlias doesn't exist
485+
* @throws UnsupportedOperationException if this functionality is not available on this client.
486+
*/
487+
default Client getRemoteClusterClient(String clusterAlias) {
488+
throw new UnsupportedOperationException("this client doesn't support remote cluster connections");
489+
}
480490
}

0 commit comments

Comments
 (0)