From 0df329dde778148e4f38eaf5b63c6bae52b374ab Mon Sep 17 00:00:00 2001 From: David Turner Date: Mon, 20 Apr 2020 14:17:09 +0100 Subject: [PATCH] Use soft deletes for searchable snapshots tests (#55453) This allows us to perform some dummy indexing including updates/deletes. --- .../SearchableSnapshotsIntegTests.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsIntegTests.java b/x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsIntegTests.java index a66b275c014..3f3a41d4946 100644 --- a/x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsIntegTests.java @@ -46,6 +46,7 @@ import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.stream.StreamSupport; +import static org.elasticsearch.index.IndexSettings.INDEX_SOFT_DELETES_SETTING; import static org.elasticsearch.index.query.QueryBuilders.matchQuery; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshots.SNAPSHOT_DIRECTORY_FACTORY_KEY; @@ -71,13 +72,14 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT .setSettings(Settings.builder().put("location", repo).put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES)) ); - createIndex(indexName); + // Peer recovery always copies .liv files but we do not permit writing to searchable snapshot directories so this doesn't work, but + // we can bypass this by forcing soft deletes to be used. TODO this restriction can be lifted when #55142 is resolved. + assertAcked(prepareCreate(indexName, Settings.builder().put(INDEX_SOFT_DELETES_SETTING.getKey(), true))); final List indexRequestBuilders = new ArrayList<>(); for (int i = between(10, 10_000); i >= 0; i--) { indexRequestBuilders.add(client().prepareIndex(indexName, "_doc").setSource("foo", randomBoolean() ? "bar" : "baz")); } - // TODO NORELEASE no dummy docs since that includes deletes, yet we always copy the .liv file in peer recovery - indexRandom(true, false, indexRequestBuilders); + indexRandom(true, true, indexRequestBuilders); refresh(indexName); assertThat( client().admin().indices().prepareForceMerge(indexName).setOnlyExpungeDeletes(true).setFlush(true).get().getFailedShards(),