Skip to content

Commit 1687020

Browse files
committed
Merge remote-tracking branch 'es/ccr' into ccr_create_and_follow
* es/ccr: (55 commits) [DOCS] Fixes typos in security settings Fix GeoShapeQueryBuilder serialization after backport [DOCS] Splits auditing.asciidoc into smaller files Reintroduce mandatory http pipelining support (elastic#30820) Painless: Types Section Clean Up (elastic#30283) Add support for indexed shape routing in geo_shape query (elastic#30760) [test] java tests for archive packaging (elastic#30734) Revert "Make http pipelining support mandatory (elastic#30695)" (elastic#30813) [DOCS] Fix more edit URLs in Stack Overview (elastic#30704) Use correct cluster state version for node fault detection (elastic#30810) Change serialization version of doc-value fields. [DOCS] Fixes broken link for native realm [DOCS] Clarified audit.index.client.hosts (elastic#30797) [TEST] Don't expect acks when isolating nodes Mute CorruptedFileIT in CCR Add a `format` option to `docvalue_fields`. (elastic#29639) Fixes UpdateSettingsRequestStreamableTests mutate bug Mustes {p0=snapshot.get_repository/10_basic/*} YAML test Revert "Mutes MachineLearningTests.testNoAttributes_givenSameAndMlEnabled" Only allow x-pack metadata if all nodes are ready (elastic#30743) ...
2 parents c1f8106 + 3fb2c45 commit 1687020

File tree

364 files changed

+8353
-2531
lines changed

Some content is hidden

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

364 files changed

+8353
-2531
lines changed

TESTING.asciidoc

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ You can choose which boxes to test by setting the `-Pvagrant.boxes` project prop
379379
the valid options for this property are:
380380

381381
* `sample` - The default, only chooses ubuntu-1404 and centos-7
382-
* List of box names, comma separated (e.g. `oel-7,fedora-26`) - Chooses exactly the boxes listed.
382+
* List of box names, comma separated (e.g. `oel-7,fedora-28`) - Chooses exactly the boxes listed.
383383
* `linux-all` - All linux boxes.
384384
* `windows-all` - All Windows boxes. If there are any Windows boxes which do not
385385
have images available when this value is provided, the build will fail.
@@ -406,8 +406,8 @@ These are the linux flavors supported, all of which we provide images for
406406
* debian-9 aka stretch, the current debian stable distribution
407407
* centos-6
408408
* centos-7
409-
* fedora-26
410409
* fedora-27
410+
* fedora-28
411411
* oel-6 aka Oracle Enterprise Linux 6
412412
* oel-7 aka Oracle Enterprise Linux 7
413413
* sles-12
@@ -512,7 +512,9 @@ into it
512512
vagrant ssh debian-9
513513
--------------------------------------------
514514

515-
Now inside the VM, to run the https://github.com/sstephenson/bats[bats] packaging tests
515+
Now inside the VM, start the packaging tests from the terminal. There are two packaging
516+
test projects. The old ones are written with https://github.com/sstephenson/bats[bats]
517+
and only run on linux. To run them do
516518

517519
--------------------------------------------
518520
cd $PACKAGING_ARCHIVES
@@ -524,18 +526,36 @@ sudo bats $BATS_TESTS/*.bats
524526
sudo bats $BATS_TESTS/20_tar_package.bats $BATS_TESTS/25_tar_plugins.bats
525527
--------------------------------------------
526528

527-
To run the Java packaging tests, again inside the VM
529+
The new packaging tests are written in Java and run on both linux and windows. On
530+
linux (again, inside the VM)
528531

529532
--------------------------------------------
530-
bash $PACKAGING_TESTS/run-tests.sh
533+
# run the full suite
534+
sudo bash $PACKAGING_TESTS/run-tests.sh
535+
536+
# run specific test cases
537+
sudo bash $PACKAGING_TESTS/run-tests.sh \
538+
org.elasticsearch.packaging.test.DefaultZipTests \
539+
org.elasticsearch.packaging.test.OssZipTests
531540
--------------------------------------------
532541

533-
or on Windows
542+
or on Windows, from a terminal running as Administrator
534543

535544
--------------------------------------------
545+
# run the full suite
536546
powershell -File $Env:PACKAGING_TESTS/run-tests.ps1
547+
548+
# run specific test cases
549+
powershell -File $Env:PACKAGING_TESTS/run-tests.ps1 `
550+
org.elasticsearch.packaging.test.DefaultZipTests `
551+
org.elasticsearch.packaging.test.OssZipTests
537552
--------------------------------------------
538553

554+
Note that on Windows boxes when running from inside the GUI, you may have to log out and
555+
back in to the `vagrant` user (password `vagrant`) for the environment variables that
556+
locate the packaging tests and distributions to take effect, due to how vagrant provisions
557+
Windows machines.
558+
539559
When you've made changes you want to test, keep the VM up and reload the tests and
540560
distributions inside by running (on the host)
541561

Vagrantfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ Vagrant.configure(2) do |config|
9797
rpm_common config, box
9898
end
9999
end
100-
'fedora-26'.tap do |box|
100+
'fedora-27'.tap do |box|
101101
config.vm.define box, define_opts do |config|
102-
config.vm.box = 'elastic/fedora-26-x86_64'
102+
config.vm.box = 'elastic/fedora-27-x86_64'
103103
dnf_common config, box
104104
end
105105
end
106-
'fedora-27'.tap do |box|
106+
'fedora-28'.tap do |box|
107107
config.vm.define box, define_opts do |config|
108-
config.vm.box = 'elastic/fedora-27-x86_64'
108+
config.vm.box = 'elastic/fedora-28-x86_64'
109109
dnf_common config, box
110110
end
111111
end
@@ -237,6 +237,7 @@ def linux_common(config,
237237

238238
config.vm.provision 'markerfile', type: 'shell', inline: <<-SHELL
239239
touch /etc/is_vagrant_vm
240+
touch /is_vagrant_vm # for consistency between linux and windows
240241
SHELL
241242

242243
# This prevents leftovers from previous tests using the

build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ import java.nio.file.Files
3636
import java.nio.file.Path
3737
import java.security.MessageDigest
3838

39+
plugins {
40+
id 'com.gradle.build-scan' version '1.13.2'
41+
}
42+
if (properties.get("org.elasticsearch.acceptScanTOS", "false") == "true") {
43+
buildScan {
44+
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
45+
termsOfServiceAgree = 'yes'
46+
}
47+
}
48+
3949
// common maven publishing configuration
4050
subprojects {
4151
group = 'org.elasticsearch'

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class VagrantTestPlugin implements Plugin<Project> {
2323
'centos-7',
2424
'debian-8',
2525
'debian-9',
26-
'fedora-26',
2726
'fedora-27',
27+
'fedora-28',
2828
'oel-6',
2929
'oel-7',
3030
'opensuse-42',
@@ -52,6 +52,8 @@ class VagrantTestPlugin implements Plugin<Project> {
5252
static final List<String> DISTRIBUTIONS = unmodifiableList([
5353
'archives:tar',
5454
'archives:oss-tar',
55+
'archives:zip',
56+
'archives:oss-zip',
5557
'packages:rpm',
5658
'packages:oss-rpm',
5759
'packages:deb',
@@ -242,13 +244,27 @@ class VagrantTestPlugin implements Plugin<Project> {
242244
Task createLinuxRunnerScript = project.tasks.create('createLinuxRunnerScript', FileContentsTask) {
243245
dependsOn copyPackagingTests
244246
file "${testsDir}/run-tests.sh"
245-
contents "java -cp \"\$PACKAGING_TESTS/*\" org.junit.runner.JUnitCore ${-> project.extensions.esvagrant.testClass}"
247+
contents """\
248+
if [ "\$#" -eq 0 ]; then
249+
test_args=( "${-> project.extensions.esvagrant.testClass}" )
250+
else
251+
test_args=( "\$@" )
252+
fi
253+
java -cp "\$PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner "\${test_args[@]}"
254+
"""
246255
}
247256
Task createWindowsRunnerScript = project.tasks.create('createWindowsRunnerScript', FileContentsTask) {
248257
dependsOn copyPackagingTests
249258
file "${testsDir}/run-tests.ps1"
259+
// the use of $args rather than param() here is deliberate because the syntax for array (multivalued) parameters is likely
260+
// a little trappy for those unfamiliar with powershell
250261
contents """\
251-
java -cp "\$Env:PACKAGING_TESTS/*" org.junit.runner.JUnitCore ${-> project.extensions.esvagrant.testClass}
262+
if (\$args.Count -eq 0) {
263+
\$testArgs = @("${-> project.extensions.esvagrant.testClass}")
264+
} else {
265+
\$testArgs = \$args
266+
}
267+
java -cp "\$Env:PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner @testArgs
252268
exit \$LASTEXITCODE
253269
"""
254270
}
@@ -525,9 +541,10 @@ class VagrantTestPlugin implements Plugin<Project> {
525541

526542
if (LINUX_BOXES.contains(box)) {
527543
javaPackagingTest.command = 'ssh'
528-
javaPackagingTest.args = ['--command', 'bash "$PACKAGING_TESTS/run-tests.sh"']
544+
javaPackagingTest.args = ['--command', 'sudo bash "$PACKAGING_TESTS/run-tests.sh"']
529545
} else {
530546
javaPackagingTest.command = 'winrm'
547+
// winrm commands run as administrator
531548
javaPackagingTest.args = ['--command', 'powershell -File "$Env:PACKAGING_TESTS/run-tests.ps1"']
532549
}
533550

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-alpha1
2-
lucene = 7.4.0-snapshot-59f2b7aec2
2+
lucene = 7.4.0-snapshot-cc2ee23050
33

44
# optional dependencies
55
spatial4j = 0.7

client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.apache.lucene.util.BytesRef;
3131
import org.elasticsearch.action.DocWriteRequest;
3232
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequest;
33+
import org.elasticsearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest;
3334
import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesRequest;
3435
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryRequest;
3536
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
@@ -711,6 +712,16 @@ static Request createRepository(PutRepositoryRequest putRepositoryRequest) throw
711712
return request;
712713
}
713714

715+
static Request deleteRepository(DeleteRepositoryRequest deleteRepositoryRequest) {
716+
String endpoint = new EndpointBuilder().addPathPartAsIs("_snapshot").addPathPart(deleteRepositoryRequest.name()).build();
717+
Request request = new Request(HttpDelete.METHOD_NAME, endpoint);
718+
719+
Params parameters = new Params(request);
720+
parameters.withMasterTimeout(deleteRepositoryRequest.masterNodeTimeout());
721+
parameters.withTimeout(deleteRepositoryRequest.timeout());
722+
return request;
723+
}
724+
714725
static Request putTemplate(PutIndexTemplateRequest putIndexTemplateRequest) throws IOException {
715726
String endpoint = new EndpointBuilder().addPathPartAsIs("_template").addPathPart(putIndexTemplateRequest.name()).build();
716727
Request request = new Request(HttpPut.METHOD_NAME, endpoint);

client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
import org.elasticsearch.action.ActionListener;
2727
import org.elasticsearch.action.ActionRequest;
2828
import org.elasticsearch.action.ActionRequestValidationException;
29-
import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesRequest;
30-
import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesResponse;
3129
import org.elasticsearch.action.bulk.BulkRequest;
3230
import org.elasticsearch.action.bulk.BulkResponse;
3331
import org.elasticsearch.action.delete.DeleteRequest;
@@ -592,7 +590,7 @@ protected final <Req extends ActionRequest, Resp> Resp performRequest(Req reques
592590
throw validationException;
593591
}
594592
Request req = requestConverter.apply(request);
595-
req.setHeaders(headers);
593+
addHeaders(req, headers);
596594
Response response;
597595
try {
598596
response = client.performRequest(req);
@@ -642,12 +640,19 @@ protected final <Req extends ActionRequest, Resp> void performRequestAsync(Req r
642640
listener.onFailure(e);
643641
return;
644642
}
645-
req.setHeaders(headers);
643+
addHeaders(req, headers);
646644

647645
ResponseListener responseListener = wrapResponseListener(responseConverter, listener, ignores);
648646
client.performRequestAsync(req, responseListener);
649647
}
650648

649+
private static void addHeaders(Request request, Header... headers) {
650+
Objects.requireNonNull(headers, "headers cannot be null");
651+
for (Header header : headers) {
652+
request.addHeader(header.getName(), header.getValue());
653+
}
654+
}
655+
651656
final <Resp> ResponseListener wrapResponseListener(CheckedFunction<Response, Resp, IOException> responseConverter,
652657
ActionListener<Resp> actionListener, Set<Integer> ignores) {
653658
return new ResponseListener() {

client/rest-high-level/src/main/java/org/elasticsearch/client/SnapshotClient.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
import org.apache.http.Header;
2323
import org.elasticsearch.action.ActionListener;
24+
import org.elasticsearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest;
25+
import org.elasticsearch.action.admin.cluster.repositories.delete.DeleteRepositoryResponse;
2426
import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesRequest;
2527
import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesResponse;
2628
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryRequest;
@@ -90,4 +92,28 @@ public void createRepositoryAsync(PutRepositoryRequest putRepositoryRequest,
9092
restHighLevelClient.performRequestAsyncAndParseEntity(putRepositoryRequest, RequestConverters::createRepository,
9193
PutRepositoryResponse::fromXContent, listener, emptySet(), headers);
9294
}
95+
96+
/**
97+
* Deletes a snapshot repository.
98+
* <p>
99+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html"> Snapshot and Restore
100+
* API on elastic.co</a>
101+
*/
102+
public DeleteRepositoryResponse deleteRepository(DeleteRepositoryRequest deleteRepositoryRequest, Header... headers)
103+
throws IOException {
104+
return restHighLevelClient.performRequestAndParseEntity(deleteRepositoryRequest, RequestConverters::deleteRepository,
105+
DeleteRepositoryResponse::fromXContent, emptySet(), headers);
106+
}
107+
108+
/**
109+
* Asynchronously deletes a snapshot repository.
110+
* <p>
111+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html"> Snapshot and Restore
112+
* API on elastic.co</a>
113+
*/
114+
public void deleteRepositoryAsync(DeleteRepositoryRequest deleteRepositoryRequest,
115+
ActionListener<DeleteRepositoryResponse> listener, Header... headers) {
116+
restHighLevelClient.performRequestAsyncAndParseEntity(deleteRepositoryRequest, RequestConverters::deleteRepository,
117+
DeleteRepositoryResponse::fromXContent, listener, emptySet(), headers);
118+
}
93119
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ public void initClients() throws IOException {
7373
final RestClient restClient = mock(RestClient.class);
7474
restHighLevelClient = new CustomRestClient(restClient);
7575

76-
doAnswer(inv -> mockPerformRequest(((Request) inv.getArguments()[0]).getHeaders()[0]))
76+
doAnswer(inv -> mockPerformRequest(((Request) inv.getArguments()[0]).getHeaders().iterator().next()))
7777
.when(restClient)
7878
.performRequest(any(Request.class));
7979

8080
doAnswer(inv -> mockPerformRequestAsync(
81-
((Request) inv.getArguments()[0]).getHeaders()[0],
81+
((Request) inv.getArguments()[0]).getHeaders().iterator().next(),
8282
(ResponseListener) inv.getArguments()[1]))
8383
.when(restClient)
8484
.performRequestAsync(any(Request.class), any(ResponseListener.class));

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

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.elasticsearch.action.ActionRequestValidationException;
3131
import org.elasticsearch.action.DocWriteRequest;
3232
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequest;
33+
import org.elasticsearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest;
3334
import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesRequest;
3435
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryRequest;
3536
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
@@ -1546,7 +1547,7 @@ public void testGetRepositories() {
15461547
}
15471548

15481549
public void testCreateRepository() throws IOException {
1549-
String repository = "repo";
1550+
String repository = randomIndicesNames(1, 1)[0];
15501551
String endpoint = "/_snapshot/" + repository;
15511552
Path repositoryLocation = PathUtils.get(".");
15521553
PutRepositoryRequest putRepositoryRequest = new PutRepositoryRequest(repository);
@@ -1555,17 +1556,35 @@ public void testCreateRepository() throws IOException {
15551556

15561557
putRepositoryRequest.settings(
15571558
Settings.builder()
1558-
.put(FsRepository.LOCATION_SETTING.getKey(), repositoryLocation)
1559-
.put(FsRepository.COMPRESS_SETTING.getKey(), randomBoolean())
1560-
.put(FsRepository.CHUNK_SIZE_SETTING.getKey(), randomIntBetween(100, 1000), ByteSizeUnit.BYTES)
1561-
.build());
1559+
.put(FsRepository.LOCATION_SETTING.getKey(), repositoryLocation)
1560+
.put(FsRepository.COMPRESS_SETTING.getKey(), randomBoolean())
1561+
.put(FsRepository.CHUNK_SIZE_SETTING.getKey(), randomIntBetween(100, 1000), ByteSizeUnit.BYTES)
1562+
.build());
15621563

15631564
Request request = RequestConverters.createRepository(putRepositoryRequest);
15641565
assertThat(endpoint, equalTo(request.getEndpoint()));
15651566
assertThat(HttpPut.METHOD_NAME, equalTo(request.getMethod()));
15661567
assertToXContentBody(putRepositoryRequest, request.getEntity());
15671568
}
15681569

1570+
public void testDeleteRepository() {
1571+
Map<String, String> expectedParams = new HashMap<>();
1572+
String repository = randomIndicesNames(1, 1)[0];
1573+
1574+
StringBuilder endpoint = new StringBuilder("/_snapshot/" + repository);
1575+
1576+
DeleteRepositoryRequest deleteRepositoryRequest = new DeleteRepositoryRequest();
1577+
deleteRepositoryRequest.name(repository);
1578+
setRandomMasterTimeout(deleteRepositoryRequest, expectedParams);
1579+
setRandomTimeout(deleteRepositoryRequest::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams);
1580+
1581+
Request request = RequestConverters.deleteRepository(deleteRepositoryRequest);
1582+
assertThat(endpoint.toString(), equalTo(request.getEndpoint()));
1583+
assertThat(HttpDelete.METHOD_NAME, equalTo(request.getMethod()));
1584+
assertThat(expectedParams, equalTo(request.getParameters()));
1585+
assertNull(request.getEntity());
1586+
}
1587+
15691588
public void testPutTemplateRequest() throws Exception {
15701589
Map<String, String> names = new HashMap<>();
15711590
names.put("log", "log");

0 commit comments

Comments
 (0)