Skip to content

Commit a8a5551

Browse files
committed
Merge branch 'master' into refresh-without-lock
2 parents 449b463 + 7e6199e commit a8a5551

File tree

263 files changed

+2771
-2059
lines changed

Some content is hidden

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

263 files changed

+2771
-2059
lines changed

.ci/bwcVersions

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ BWC_VERSION:
1010
- "7.3.2"
1111
- "7.4.0"
1212
- "7.4.1"
13+
- "7.4.2"
1314
- "7.5.0"
1415
- "7.6.0"
1516
- "8.0.0"

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,8 @@ class BuildPlugin implements Plugin<Project> {
827827
} else {
828828
nonInputProperties.systemProperty('runtime.java', "${-> (ext.get('runtimeJavaVersion') as JavaVersion).getMajorVersion()}")
829829
}
830+
//TODO remove once jvm.options are added to test system properties
831+
test.systemProperty ('java.locale.providers','SPI,COMPAT')
830832
}
831833

832834
test.jvmArgumentProviders.add(nonInputProperties)
@@ -861,8 +863,6 @@ class BuildPlugin implements Plugin<Project> {
861863
'tests.security.manager': 'true',
862864
'jna.nosys': 'true'
863865

864-
//TODO remove once jvm.options are added to test system properties
865-
test.systemProperty ('java.locale.providers','SPI,COMPAT')
866866

867867
// ignore changing test seed when build is passed -Dignore.tests.seed for cacheability experimentation
868868
if (System.getProperty('ignore.tests.seed') != null) {

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

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
2424
import org.elasticsearch.gradle.tool.Boilerplate
2525
import org.elasticsearch.gradle.tool.ClasspathUtils
2626
import org.gradle.api.DefaultTask
27-
import org.gradle.api.JavaVersion
2827
import org.gradle.api.Task
2928
import org.gradle.api.file.FileCopyDetails
3029
import org.gradle.api.tasks.Copy

client/rest-high-level/build.gradle

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.elasticsearch.gradle.test.RestIntegTestTask
2+
13
/*
24
* Licensed to Elasticsearch under one or more contributor
35
* license agreements. See the NOTICE file distributed with
@@ -106,11 +108,22 @@ File nodeTrustStore = file("./testnode.jks")
106108
File pkiTrustCert = file("./src/test/resources/org/elasticsearch/client/security/delegate_pki/testRootCA.crt")
107109

108110
integTest.runner {
111+
systemProperty 'tests.rest.async', 'false'
109112
systemProperty 'tests.rest.cluster.username', System.getProperty('tests.rest.cluster.username', 'test_user')
110113
systemProperty 'tests.rest.cluster.password', System.getProperty('tests.rest.cluster.password', 'test-password')
111114
}
112115

113-
testClusters.integTest {
116+
RestIntegTestTask asyncIntegTest = tasks.create("asyncIntegTest", RestIntegTestTask) {
117+
runner {
118+
systemProperty 'tests.rest.async', 'true'
119+
systemProperty 'tests.rest.cluster.username', System.getProperty('tests.rest.cluster.username', 'test_user')
120+
systemProperty 'tests.rest.cluster.password', System.getProperty('tests.rest.cluster.password', 'test-password')
121+
}
122+
}
123+
124+
check.dependsOn(asyncIntegTest)
125+
126+
testClusters.all {
114127
testDistribution = 'DEFAULT'
115128
systemProperty 'es.scripting.update.ctx_in_params', 'false'
116129
setting 'reindex.remote.whitelist', '[ "[::1]:*", "127.0.0.1:*" ]'
@@ -130,10 +143,10 @@ testClusters.integTest {
130143
setting 'indices.lifecycle.poll_interval', '1000ms'
131144
keystore 'xpack.security.transport.ssl.truststore.secure_password', 'testnode'
132145
extraConfigFile 'roles.yml', file('roles.yml')
133-
user username: System.getProperty('tests.rest.cluster.username', 'test_user'),
134-
password: System.getProperty('tests.rest.cluster.password', 'test-password'),
135-
role: System.getProperty('tests.rest.cluster.role', 'admin')
136-
user username: 'admin_user', password: 'admin-password'
146+
user username: System.getProperty('tests.rest.cluster.username', 'test_user'),
147+
password: System.getProperty('tests.rest.cluster.password', 'test-password'),
148+
role: System.getProperty('tests.rest.cluster.role', 'admin')
149+
user username: 'admin_user', password: 'admin-password'
137150

138151
extraConfigFile nodeCert.name, nodeCert
139152
extraConfigFile nodeTrustStore.name, nodeTrustStore

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

-70
This file was deleted.

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.elasticsearch.action.search.SearchResponse;
2727
import org.elasticsearch.action.support.PlainActionFuture;
2828
import org.elasticsearch.client.indices.CreateIndexRequest;
29+
import org.elasticsearch.common.Booleans;
2930
import org.elasticsearch.common.bytes.BytesReference;
3031
import org.elasticsearch.common.settings.Settings;
3132
import org.elasticsearch.common.util.concurrent.ThreadContext;
@@ -52,6 +53,7 @@
5253
public abstract class ESRestHighLevelClientTestCase extends ESRestTestCase {
5354

5455
private static RestHighLevelClient restHighLevelClient;
56+
private static boolean async = Booleans.parseBoolean(System.getProperty("tests.rest.async", "false"));
5557

5658
@Before
5759
public void initHighLevelClient() throws IOException {
@@ -78,20 +80,20 @@ protected static <Req, Resp> Resp execute(Req request, SyncMethod<Req, Resp> syn
7880
AsyncMethod<Req, Resp> asyncMethod) throws IOException {
7981
return execute(request, syncMethod, asyncMethod, RequestOptions.DEFAULT);
8082
}
81-
83+
8284
/**
8385
* Executes the provided request using either the sync method or its async variant, both provided as functions
8486
*/
8587
protected static <Req, Resp> Resp execute(Req request, SyncMethod<Req, Resp> syncMethod,
8688
AsyncMethod<Req, Resp> asyncMethod, RequestOptions options) throws IOException {
87-
if (randomBoolean()) {
89+
if (async == false) {
8890
return syncMethod.execute(request, options);
8991
} else {
9092
PlainActionFuture<Resp> future = PlainActionFuture.newFuture();
9193
asyncMethod.execute(request, options, future);
9294
return future.actionGet();
9395
}
94-
}
96+
}
9597

9698
/**
9799
* Executes the provided request using either the sync method or its async
@@ -100,7 +102,7 @@ protected static <Req, Resp> Resp execute(Req request, SyncMethod<Req, Resp> syn
100102
*/
101103
protected static <Resp> Resp execute(SyncMethodNoRequest<Resp> syncMethodNoRequest, AsyncMethodNoRequest<Resp> asyncMethodNoRequest,
102104
RequestOptions requestOptions) throws IOException {
103-
if (randomBoolean()) {
105+
if (async == false) {
104106
return syncMethodNoRequest.execute(requestOptions);
105107
} else {
106108
PlainActionFuture<Resp> future = PlainActionFuture.newFuture();

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public void testGetLicense() throws Exception {
194194
//end::get-license-response
195195

196196
assertThat(currentLicense, containsString("trial"));
197-
assertThat(currentLicense, containsString("integTest"));
197+
assertThat(currentLicense, containsString("ntegTest"));
198198
}
199199
{
200200
GetLicenseRequest request = new GetLicenseRequest();
@@ -233,7 +233,7 @@ public void onFailure(Exception e) {
233233
String currentLicense = response.getLicenseDefinition();
234234
assertThat(currentLicense, startsWith("{"));
235235
assertThat(currentLicense, containsString("trial"));
236-
assertThat(currentLicense, containsString("integTest"));
236+
assertThat(currentLicense, containsString("ntegTest"));
237237
assertThat(currentLicense, endsWith("}"));
238238
}
239239
}

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

+1
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ public void testGetUsers() throws Exception {
203203
// 9 users are expected to be returned
204204
// test_users (3): user1, user2, user3
205205
// system_users (6): elastic, beats_system, apm_system, logstash_system, kibana, remote_monitoring_user
206+
logger.info(users);
206207
assertThat(users.size(), equalTo(9));
207208
}
208209

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import org.elasticsearch.client.indices.CreateIndexRequest;
4949
import org.elasticsearch.cluster.SnapshotsInProgress;
5050
import org.elasticsearch.cluster.metadata.RepositoryMetaData;
51+
import org.elasticsearch.common.Booleans;
5152
import org.elasticsearch.common.settings.Settings;
5253
import org.elasticsearch.common.unit.TimeValue;
5354
import org.elasticsearch.common.xcontent.XContentType;
@@ -457,7 +458,12 @@ public void testSnapshotVerifyRepository() throws IOException {
457458
List<VerifyRepositoryResponse.NodeView> repositoryMetaDataResponse = response.getNodes();
458459
// end::verify-repository-response
459460
assertThat(1, equalTo(repositoryMetaDataResponse.size()));
460-
assertThat("integTest-0", equalTo(repositoryMetaDataResponse.get(0).getName()));
461+
final boolean async = Booleans.parseBoolean(System.getProperty("tests.rest.async", "false"));
462+
if (async) {
463+
assertThat("asyncIntegTest-0", equalTo(repositoryMetaDataResponse.get(0).getName()));
464+
} else {
465+
assertThat("integTest-0", equalTo(repositoryMetaDataResponse.get(0).getName()));
466+
}
461467
}
462468

463469
public void testSnapshotVerifyRepositoryAsync() throws InterruptedException {

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

+17-69
Original file line numberDiff line numberDiff line change
@@ -18,48 +18,23 @@
1818
*/
1919
package org.elasticsearch.client.license;
2020

21-
import org.elasticsearch.client.AbstractHlrcWriteableXContentTestCase;
22-
import org.elasticsearch.common.io.stream.Writeable;
21+
import org.elasticsearch.client.AbstractResponseTestCase;
2322
import org.elasticsearch.common.xcontent.XContentParser;
24-
import org.elasticsearch.protocol.xpack.license.LicensesStatus;
23+
import org.elasticsearch.common.xcontent.XContentType;
2524

2625
import java.io.IOException;
26+
import java.util.Arrays;
2727
import java.util.Collections;
2828
import java.util.HashMap;
2929
import java.util.Map;
30-
import java.util.function.Function;
31-
import java.util.function.Predicate;
3230

33-
public class PutLicenseResponseTests extends AbstractHlrcWriteableXContentTestCase<
34-
org.elasticsearch.protocol.xpack.license.PutLicenseResponse, PutLicenseResponse> {
35-
36-
@Override
37-
public org.elasticsearch.client.license.PutLicenseResponse doHlrcParseInstance(XContentParser parser) throws IOException {
38-
return org.elasticsearch.client.license.PutLicenseResponse.fromXContent(parser);
39-
}
40-
41-
@Override
42-
public org.elasticsearch.protocol.xpack.license.PutLicenseResponse convertHlrcToInternal(
43-
org.elasticsearch.client.license.PutLicenseResponse instance) {
44-
return new org.elasticsearch.protocol.xpack.license.PutLicenseResponse(instance.isAcknowledged(),
45-
org.elasticsearch.protocol.xpack.license.LicensesStatus.valueOf(instance.status().name()),
46-
instance.acknowledgeHeader(), instance.acknowledgeMessages());
47-
}
48-
49-
@Override
50-
protected boolean supportsUnknownFields() {
51-
return true;
52-
}
31+
import static org.hamcrest.Matchers.equalTo;
5332

54-
@Override
55-
protected Predicate<String> getRandomFieldsExcludeFilter() {
56-
// The structure of the response is such that unknown fields inside acknowledge cannot be supported since they
57-
// are treated as messages from new services
58-
return p -> p.startsWith("acknowledge");
59-
}
33+
public class PutLicenseResponseTests extends AbstractResponseTestCase<
34+
org.elasticsearch.protocol.xpack.license.PutLicenseResponse, PutLicenseResponse> {
6035

6136
@Override
62-
protected org.elasticsearch.protocol.xpack.license.PutLicenseResponse createTestInstance() {
37+
protected org.elasticsearch.protocol.xpack.license.PutLicenseResponse createServerTestInstance(XContentType xContentType) {
6338
boolean acknowledged = randomBoolean();
6439
org.elasticsearch.protocol.xpack.license.LicensesStatus status =
6540
randomFrom(org.elasticsearch.protocol.xpack.license.LicensesStatus.VALID,
@@ -97,45 +72,18 @@ private static Map<String, String[]> randomAckMessages() {
9772
}
9873

9974
@Override
100-
protected Writeable.Reader<org.elasticsearch.protocol.xpack.license.PutLicenseResponse> instanceReader() {
101-
return org.elasticsearch.protocol.xpack.license.PutLicenseResponse::new;
75+
protected PutLicenseResponse doParseToClientInstance(XContentParser parser) throws IOException {
76+
return PutLicenseResponse.fromXContent(parser);
10277
}
10378

10479
@Override
105-
protected org.elasticsearch.protocol.xpack.license.PutLicenseResponse mutateInstance(
106-
org.elasticsearch.protocol.xpack.license.PutLicenseResponse response) {
107-
@SuppressWarnings("unchecked")
108-
Function<org.elasticsearch.protocol.xpack.license.PutLicenseResponse,
109-
org.elasticsearch.protocol.xpack.license.PutLicenseResponse> mutator = randomFrom(
110-
r -> new org.elasticsearch.protocol.xpack.license.PutLicenseResponse(
111-
r.isAcknowledged() == false,
112-
r.status(),
113-
r.acknowledgeHeader(),
114-
r.acknowledgeMessages()),
115-
r -> new org.elasticsearch.protocol.xpack.license.PutLicenseResponse(
116-
r.isAcknowledged(),
117-
mutateStatus(r.status()),
118-
r.acknowledgeHeader(),
119-
r.acknowledgeMessages()),
120-
r -> {
121-
if (r.acknowledgeMessages().isEmpty()) {
122-
return new org.elasticsearch.protocol.xpack.license.PutLicenseResponse(
123-
r.isAcknowledged(),
124-
r.status(),
125-
randomAlphaOfLength(10),
126-
randomAckMessages()
127-
);
128-
} else {
129-
return new org.elasticsearch.protocol.xpack.license.PutLicenseResponse(r.isAcknowledged(), r.status());
130-
}
131-
}
132-
133-
);
134-
return mutator.apply(response);
135-
}
136-
137-
private org.elasticsearch.protocol.xpack.license.LicensesStatus mutateStatus(
138-
org.elasticsearch.protocol.xpack.license.LicensesStatus status) {
139-
return randomValueOtherThan(status, () -> randomFrom(LicensesStatus.values()));
80+
protected void assertInstances(org.elasticsearch.protocol.xpack.license.PutLicenseResponse serverTestInstance,
81+
PutLicenseResponse clientInstance) {
82+
assertThat(serverTestInstance.status().name(), equalTo(clientInstance.status().name()));
83+
assertThat(serverTestInstance.acknowledgeHeader(), equalTo(clientInstance.acknowledgeHeader()));
84+
assertThat(serverTestInstance.acknowledgeMessages().keySet(), equalTo(clientInstance.acknowledgeMessages().keySet()));
85+
for(Map.Entry<String, String[]> entry: serverTestInstance.acknowledgeMessages().entrySet()) {
86+
assertTrue(Arrays.equals(entry.getValue(), clientInstance.acknowledgeMessages().get(entry.getKey())));
87+
}
14088
}
14189
}

0 commit comments

Comments
 (0)