From 88b5ef2f18cd4891260e368d2e90e620969d3c68 Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Fri, 10 Jan 2020 09:35:07 -0500 Subject: [PATCH 1/3] Clean soft-deletes setting in ccr tests --- .../java/org/elasticsearch/client/CCRIT.java | 3 - .../documentation/CCRDocumentationIT.java | 7 -- .../xpack/ccr/FollowIndexIT.java | 8 +- .../elasticsearch/xpack/ccr/AutoFollowIT.java | 20 +---- .../org/elasticsearch/xpack/ccr/ChainIT.java | 5 +- .../xpack/ccr/FollowIndexIT.java | 5 +- .../elasticsearch/xpack/ccr/XPackUsageIT.java | 7 +- .../elasticsearch/xpack/ccr/RestartIT.java | 4 +- .../xpack/ccr/FollowIndexSecurityIT.java | 18 +---- .../elasticsearch/xpack/CcrIntegTestCase.java | 4 + .../elasticsearch/xpack/ccr/AutoFollowIT.java | 21 ++---- .../xpack/ccr/CcrRepositoryIT.java | 18 ++--- .../xpack/ccr/CcrRetentionLeaseIT.java | 18 +---- .../xpack/ccr/CloseFollowerIndexIT.java | 4 +- .../elasticsearch/xpack/ccr/FollowInfoIT.java | 9 +-- .../xpack/ccr/FollowStatsIT.java | 14 ++-- .../xpack/ccr/FollowerFailOverIT.java | 11 +-- .../xpack/ccr/IndexFollowingIT.java | 75 ++++++------------- .../xpack/ccr/LocalIndexFollowingIT.java | 4 +- .../xpack/ccr/RestartIndexFollowingIT.java | 5 +- .../action/AutoFollowCoordinatorTests.java | 16 +--- .../ccr/action/ShardChangesActionTests.java | 4 - .../xpack/ccr/action/ShardChangesTests.java | 5 +- .../ShardFollowTaskReplicationTests.java | 8 +- .../TransportResumeFollowActionTests.java | 24 ++---- .../action/bulk/BulkShardOperationsTests.java | 7 +- .../engine/FollowEngineIndexShardTests.java | 13 +--- .../index/engine/FollowingEngineTests.java | 12 +-- .../xpack/ilm/CCRIndexLifecycleIT.java | 7 -- 29 files changed, 86 insertions(+), 270 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/CCRIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/CCRIT.java index c6678102fe2b1..b2d8b2a4c4354 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/CCRIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/CCRIT.java @@ -76,7 +76,6 @@ public void testIndexFollowing() throws Exception { CcrClient ccrClient = highLevelClient().ccr(); CreateIndexRequest createIndexRequest = new CreateIndexRequest("leader"); - createIndexRequest.settings(Collections.singletonMap("index.soft_deletes.enabled", true)); CreateIndexResponse response = highLevelClient().indices().create(createIndexRequest, RequestOptions.DEFAULT); assertThat(response.isAcknowledged(), is(true)); @@ -193,7 +192,6 @@ public void testForgetFollower() throws IOException { final int numberOfShards = randomIntBetween(1, 2); settings.put("index.number_of_replicas", "0"); settings.put("index.number_of_shards", Integer.toString(numberOfShards)); - settings.put("index.soft_deletes.enabled", Boolean.TRUE.toString()); createIndexRequest.settings(settings); final CreateIndexResponse response = highLevelClient().indices().create(createIndexRequest, RequestOptions.DEFAULT); assertThat(response.isAcknowledged(), is(true)); @@ -252,7 +250,6 @@ public void testAutoFollowing() throws Exception { assertThat(putAutoFollowPatternResponse.isAcknowledged(), is(true)); CreateIndexRequest createIndexRequest = new CreateIndexRequest("logs-20200101"); - createIndexRequest.settings(Collections.singletonMap("index.soft_deletes.enabled", true)); CreateIndexResponse response = highLevelClient().indices().create(createIndexRequest, RequestOptions.DEFAULT); assertThat(response.isAcknowledged(), is(true)); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/CCRDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/CCRDocumentationIT.java index 5e7da8142129d..5f5b76d0c5158 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/CCRDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/CCRDocumentationIT.java @@ -80,7 +80,6 @@ public void testPutFollow() throws Exception { { // Create leader index: CreateIndexRequest createIndexRequest = new CreateIndexRequest("leader"); - createIndexRequest.settings(Collections.singletonMap("index.soft_deletes.enabled", true)); CreateIndexResponse response = client.indices().create(createIndexRequest, RequestOptions.DEFAULT); assertThat(response.isAcknowledged(), is(true)); } @@ -161,7 +160,6 @@ public void testPauseFollow() throws Exception { { // Create leader index: CreateIndexRequest createIndexRequest = new CreateIndexRequest("leader"); - createIndexRequest.settings(Collections.singletonMap("index.soft_deletes.enabled", true)); CreateIndexResponse response = client.indices().create(createIndexRequest, RequestOptions.DEFAULT); assertThat(response.isAcknowledged(), is(true)); } @@ -227,7 +225,6 @@ public void testResumeFollow() throws Exception { { // Create leader index: CreateIndexRequest createIndexRequest = new CreateIndexRequest("leader"); - createIndexRequest.settings(Collections.singletonMap("index.soft_deletes.enabled", true)); CreateIndexResponse response = client.indices().create(createIndexRequest, RequestOptions.DEFAULT); assertThat(response.isAcknowledged(), is(true)); } @@ -303,7 +300,6 @@ public void testUnfollow() throws Exception { { // Create leader index: CreateIndexRequest createIndexRequest = new CreateIndexRequest("leader"); - createIndexRequest.settings(Collections.singletonMap("index.soft_deletes.enabled", true)); CreateIndexResponse response = client.indices().create(createIndexRequest, RequestOptions.DEFAULT); assertThat(response.isAcknowledged(), is(true)); } @@ -392,7 +388,6 @@ public void testForgetFollower() throws InterruptedException, IOException { final Map settings = new HashMap<>(2); final int numberOfShards = randomIntBetween(1, 2); settings.put("index.number_of_shards", Integer.toString(numberOfShards)); - settings.put("index.soft_deletes.enabled", Boolean.TRUE.toString()); createIndexRequest.settings(settings); final CreateIndexResponse response = client.indices().create(createIndexRequest, RequestOptions.DEFAULT); assertThat(response.isAcknowledged(), is(true)); @@ -837,7 +832,6 @@ public void testGetFollowStats() throws Exception { { // Create leader index: CreateIndexRequest createIndexRequest = new CreateIndexRequest("leader"); - createIndexRequest.settings(Collections.singletonMap("index.soft_deletes.enabled", true)); CreateIndexResponse response = client.indices().create(createIndexRequest, RequestOptions.DEFAULT); assertThat(response.isAcknowledged(), is(true)); } @@ -905,7 +899,6 @@ public void testGetFollowInfos() throws Exception { { // Create leader index: CreateIndexRequest createIndexRequest = new CreateIndexRequest("leader"); - createIndexRequest.settings(Collections.singletonMap("index.soft_deletes.enabled", true)); CreateIndexResponse response = client.indices().create(createIndexRequest, RequestOptions.DEFAULT); assertThat(response.isAcknowledged(), is(true)); } diff --git a/x-pack/plugin/ccr/qa/downgrade-to-basic-license/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexIT.java b/x-pack/plugin/ccr/qa/downgrade-to-basic-license/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexIT.java index 4e46de95adb03..cc8d399776ece 100644 --- a/x-pack/plugin/ccr/qa/downgrade-to-basic-license/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexIT.java +++ b/x-pack/plugin/ccr/qa/downgrade-to-basic-license/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexIT.java @@ -9,11 +9,9 @@ import org.elasticsearch.client.Request; import org.elasticsearch.client.ResponseException; import org.elasticsearch.client.RestClient; -import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.PathUtils; import org.elasticsearch.common.logging.JsonLogLine; import org.elasticsearch.common.logging.JsonLogsStream; -import org.elasticsearch.common.settings.Settings; import org.hamcrest.FeatureMatcher; import org.hamcrest.Matcher; import org.hamcrest.Matchers; @@ -114,12 +112,8 @@ protected Boolean featureValueOf(JsonLogLine actual) { } private void createNewIndexAndIndexDocs(RestClient client, String index) throws IOException { - Settings settings = Settings.builder() - .put("index.soft_deletes.enabled", true) - .build(); Request request = new Request("PUT", "/" + index); - request.setJsonEntity("{\"settings\": " + Strings.toString(settings) + - ", \"mappings\": {\"properties\": {\"field\": {\"type\": \"keyword\"}}}}"); + request.setJsonEntity("{\"mappings\": {\"properties\": {\"field\": {\"type\": \"keyword\"}}}}"); assertOK(client.performRequest(request)); for (int i = 0; i < 5; i++) { diff --git a/x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java b/x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java index 055c536faac39..cad4ffb314b4f 100644 --- a/x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java +++ b/x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java @@ -8,8 +8,6 @@ import org.elasticsearch.client.Request; import org.elasticsearch.client.RestClient; -import org.elasticsearch.common.Strings; -import org.elasticsearch.common.settings.Settings; import java.io.IOException; import java.util.Map; @@ -33,12 +31,8 @@ public void testMultipleAutoFollowPatternsDifferentClusters() throws Exception { putPatternRequest.setJsonEntity("{\"leader_index_patterns\": [\"logs-*\"], \"remote_cluster\": \"middle_cluster\"}"); assertOK(client().performRequest(putPatternRequest)); try (RestClient leaderClient = buildLeaderClient()) { - Settings settings = Settings.builder() - .put("index.soft_deletes.enabled", true) - .build(); Request request = new Request("PUT", "/logs-20190101"); - request.setJsonEntity("{\"settings\": " + Strings.toString(settings) + - ", \"mappings\": {\"properties\": {\"field\": {\"type\": \"keyword\"}}}}"); + request.setJsonEntity("{\"mappings\": {\"properties\": {\"field\": {\"type\": \"keyword\"}}}}"); assertOK(leaderClient.performRequest(request)); for (int i = 0; i < 5; i++) { String id = Integer.toString(i); @@ -46,12 +40,8 @@ public void testMultipleAutoFollowPatternsDifferentClusters() throws Exception { } } try (RestClient middleClient = buildMiddleClient()) { - Settings settings = Settings.builder() - .put("index.soft_deletes.enabled", true) - .build(); Request request = new Request("PUT", "/logs-20200101"); - request.setJsonEntity("{\"settings\": " + Strings.toString(settings) + - ", \"mappings\": {\"properties\": {\"field\": {\"type\": \"keyword\"}}}}"); + request.setJsonEntity("{\"mappings\": {\"properties\": {\"field\": {\"type\": \"keyword\"}}}}"); assertOK(middleClient.performRequest(request)); for (int i = 0; i < 5; i++) { String id = Integer.toString(i); @@ -80,12 +70,8 @@ public void testAutoFollowPatterns() throws Exception { assertOK(client().performRequest(request)); try (RestClient leaderClient = buildLeaderClient()) { - Settings settings = Settings.builder() - .put("index.soft_deletes.enabled", true) - .build(); request = new Request("PUT", "/metrics-20210101"); - request.setJsonEntity("{\"settings\": " + Strings.toString(settings) + - ", \"mappings\": {\"properties\": {\"field\": {\"type\": \"keyword\"}}}}"); + request.setJsonEntity("{\"mappings\": {\"properties\": {\"field\": {\"type\": \"keyword\"}}}}"); assertOK(leaderClient.performRequest(request)); for (int i = 0; i < 5; i++) { diff --git a/x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/ChainIT.java b/x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/ChainIT.java index b3e6384f7f635..72ae8764e7099 100644 --- a/x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/ChainIT.java +++ b/x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/ChainIT.java @@ -25,10 +25,7 @@ public void testFollowIndex() throws Exception { " \"excludes\": [\"filtered_field\"]" + "}"; } - Settings indexSettings = Settings.builder() - .put("index.soft_deletes.enabled", true) - .build(); - createIndex(leaderIndexName, indexSettings, mapping); + createIndex(leaderIndexName, Settings.EMPTY, mapping); for (int i = 0; i < numDocs; i++) { logger.info("Indexing doc [{}]", i); index(client(), leaderIndexName, Integer.toString(i), "field", i, "filtered_field", "true"); diff --git a/x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexIT.java b/x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexIT.java index b50fe9233e8fa..61b3c8b11865d 100644 --- a/x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexIT.java +++ b/x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexIT.java @@ -30,10 +30,7 @@ public void testFollowIndex() throws Exception { " \"excludes\": [\"filtered_field\"]" + "}"; } - Settings indexSettings = Settings.builder() - .put("index.soft_deletes.enabled", true) - .build(); - createIndex(leaderIndexName, indexSettings, mapping); + createIndex(leaderIndexName, Settings.EMPTY, mapping); for (int i = 0; i < numDocs; i++) { logger.info("Indexing doc [{}]", i); index(client(), leaderIndexName, Integer.toString(i), "field", i, "filtered_field", "true"); diff --git a/x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/XPackUsageIT.java b/x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/XPackUsageIT.java index b429657fe57cf..8d5a8d62a46ff 100644 --- a/x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/XPackUsageIT.java +++ b/x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/XPackUsageIT.java @@ -7,8 +7,6 @@ import org.elasticsearch.client.Request; import org.elasticsearch.client.RestClient; -import org.elasticsearch.common.Strings; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.ObjectPath; import java.io.IOException; @@ -70,11 +68,8 @@ public void testXPackCcrUsage() throws Exception { private void createLeaderIndex(String indexName) throws IOException { try (RestClient leaderClient = buildLeaderClient()) { - Settings settings = Settings.builder() - .put("index.soft_deletes.enabled", true) - .build(); Request request = new Request("PUT", "/" + indexName); - request.setJsonEntity("{\"settings\": " + Strings.toString(settings) + "}"); + request.setJsonEntity("{}"); assertOK(leaderClient.performRequest(request)); } } diff --git a/x-pack/plugin/ccr/qa/restart/src/test/java/org/elasticsearch/xpack/ccr/RestartIT.java b/x-pack/plugin/ccr/qa/restart/src/test/java/org/elasticsearch/xpack/ccr/RestartIT.java index cbbc6945034c0..7422fe1b766ac 100644 --- a/x-pack/plugin/ccr/qa/restart/src/test/java/org/elasticsearch/xpack/ccr/RestartIT.java +++ b/x-pack/plugin/ccr/qa/restart/src/test/java/org/elasticsearch/xpack/ccr/RestartIT.java @@ -10,7 +10,6 @@ import org.elasticsearch.client.RestClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.IndexSettings; import java.io.IOException; @@ -71,9 +70,8 @@ public void testRestart() throws Exception { } private void createIndexAndIndexDocuments(final String index, final int numberOfDocuments, final RestClient client) throws IOException { - final Settings settings = Settings.builder().put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true).build(); final Request createIndexRequest = new Request("PUT", "/" + index); - createIndexRequest.setJsonEntity("{\"settings\":" + Strings.toString(settings) + "}"); + createIndexRequest.setJsonEntity("{\"settings\":" + Strings.toString(Settings.EMPTY) + "}"); assertOK(client.performRequest(createIndexRequest)); indexDocuments(index, numberOfDocuments, 0, client); } diff --git a/x-pack/plugin/ccr/qa/security/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexSecurityIT.java b/x-pack/plugin/ccr/qa/security/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexSecurityIT.java index f8ed48777dacc..7f1e4c37536b5 100644 --- a/x-pack/plugin/ccr/qa/security/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexSecurityIT.java +++ b/x-pack/plugin/ccr/qa/security/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexSecurityIT.java @@ -9,7 +9,6 @@ import org.elasticsearch.client.Response; import org.elasticsearch.client.ResponseException; import org.elasticsearch.client.RestClient; -import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; @@ -53,9 +52,8 @@ public void testFollowIndex() throws Exception { final String unallowedIndex = "unallowed-index"; if ("leader".equals(targetCluster)) { logger.info("Running against leader cluster"); - Settings indexSettings = Settings.builder().put("index.soft_deletes.enabled", true).build(); - createIndex(allowedIndex, indexSettings); - createIndex(unallowedIndex, indexSettings); + createIndex(allowedIndex, Settings.EMPTY); + createIndex(unallowedIndex, Settings.EMPTY); for (int i = 0; i < numDocs; i++) { logger.info("Indexing doc [{}]", i); index(allowedIndex, Integer.toString(i), "field", i); @@ -150,11 +148,7 @@ public void testAutoFollowPatterns() throws Exception { try (RestClient leaderClient = buildLeaderClient()) { for (String index : new String[]{allowedIndex, disallowedIndex}) { - Settings settings = Settings.builder() - .put("index.soft_deletes.enabled", true) - .build(); - String requestBody = "{\"settings\": " + Strings.toString(settings) + - ", \"mappings\": {\"properties\": {\"field\": {\"type\": \"keyword\"}}}}"; + String requestBody = "{\"mappings\": {\"properties\": {\"field\": {\"type\": \"keyword\"}}}}"; request = new Request("PUT", "/" + index); request.setJsonEntity(requestBody); assertOK(leaderClient.performRequest(request)); @@ -187,11 +181,7 @@ public void testForgetFollower() throws IOException { final String forgetFollower = "forget-follower"; if ("leader".equals(targetCluster)) { logger.info("running against leader cluster"); - final Settings indexSettings = Settings.builder() - .put("index.number_of_replicas", 0) - .put("index.number_of_shards", 1) - .put("index.soft_deletes.enabled", true) - .build(); + final Settings indexSettings = Settings.builder().put("index.number_of_replicas", 0).put("index.number_of_shards", 1).build(); createIndex(forgetLeader, indexSettings); } else { logger.info("running against follower cluster"); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java index fbd537ed18d98..7181dd9b6c9a2 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java @@ -413,6 +413,10 @@ public void setupSourceEnabledOrDisabled() { protected boolean sourceEnabled; + protected String getIndexSettings(final int numberOfShards, final int numberOfReplicas) throws IOException { + return getIndexSettings(numberOfShards, numberOfReplicas, Collections.emptyMap()); + } + protected String getIndexSettings(final int numberOfShards, final int numberOfReplicas, final Map additionalIndexSettings) throws IOException { final String settings; diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java index f944dd70813bc..47d9e673bc120 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java @@ -60,7 +60,6 @@ protected boolean reuseClusters() { public void testAutoFollow() throws Exception { Settings leaderIndexSettings = Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) .build(); @@ -94,7 +93,6 @@ public void testAutoFollow() throws Exception { public void testCleanFollowedLeaderIndexUUIDs() throws Exception { Settings leaderIndexSettings = Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) .build(); @@ -133,7 +131,6 @@ public void testCleanFollowedLeaderIndexUUIDs() throws Exception { public void testAutoFollowManyIndices() throws Exception { Settings leaderIndexSettings = Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) .build(); @@ -215,7 +212,6 @@ public void testAutoFollowManyIndices() throws Exception { public void testAutoFollowParameterAreDelegated() throws Exception { Settings leaderIndexSettings = Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) .build(); @@ -318,7 +314,6 @@ public void testAutoFollowParameterAreDelegated() throws Exception { public void testConflictingPatterns() throws Exception { Settings leaderIndexSettings = Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) .build(); @@ -362,12 +357,12 @@ public void testAutoFollowSoftDeletesDisabled() throws Exception { putAutoFollowPatterns("my-pattern1", new String[] {"logs-*"}); // Soft deletes are disabled: - Settings leaderIndexSettings = Settings.builder() + Settings.Builder leaderIndexSettings = Settings.builder() .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), false) .put(IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) - .put(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) - .build(); - createLeaderIndex("logs-20200101", leaderIndexSettings); + .put(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0); + + createLeaderIndex("logs-20200101", leaderIndexSettings.build()); assertBusy(() -> { AutoFollowStats autoFollowStats = getAutoFollowStats(); assertThat(autoFollowStats.getNumberOfSuccessfulFollowIndices(), equalTo(0L)); @@ -381,11 +376,9 @@ public void testAutoFollowSoftDeletesDisabled() throws Exception { // Soft deletes are enabled: leaderIndexSettings = Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) - .put(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) - .build(); - createLeaderIndex("logs-20200102", leaderIndexSettings); + .put(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0); + createLeaderIndex("logs-20200102", leaderIndexSettings.build()); assertBusy(() -> { AutoFollowStats autoFollowStats = getAutoFollowStats(); assertThat(autoFollowStats.getNumberOfSuccessfulFollowIndices(), equalTo(1L)); @@ -395,7 +388,6 @@ public void testAutoFollowSoftDeletesDisabled() throws Exception { public void testPauseAndResumeAutoFollowPattern() throws Exception { final Settings leaderIndexSettings = Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) .build(); @@ -465,7 +457,6 @@ public void testPauseAndResumeAutoFollowPattern() throws Exception { public void testPauseAndResumeWithMultipleAutoFollowPatterns() throws Exception { final Settings leaderIndexSettings = Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) .build(); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRepositoryIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRepositoryIT.java index a8f393073a745..e48e03b8d2b79 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRepositoryIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRepositoryIT.java @@ -24,7 +24,6 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.common.xcontent.support.XContentMapValues; -import org.elasticsearch.index.IndexSettings; import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.repositories.Repository; import org.elasticsearch.repositories.RepositoryMissingException; @@ -48,7 +47,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import static java.util.Collections.singletonMap; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; @@ -109,8 +107,7 @@ public void testThatRepositoryRecoversEmptyIndexBasedOnLeaderSettings() throws I String followerIndex = "index2"; final int numberOfPrimaryShards = randomIntBetween(1, 3); - final String leaderIndexSettings = getIndexSettings(numberOfPrimaryShards, between(0, 1), - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(numberOfPrimaryShards, between(0, 1)); assertAcked(leaderClient().admin().indices().prepareCreate(leaderIndex).setSource(leaderIndexSettings, XContentType.JSON)); ensureLeaderGreen(leaderIndex); @@ -157,7 +154,6 @@ public void testThatRepositoryRecoversEmptyIndexBasedOnLeaderSettings() throws I assertEquals(leaderMetadata.getIndexUUID(), ccrMetadata.get(Ccr.CCR_CUSTOM_METADATA_LEADER_INDEX_UUID_KEY)); assertEquals("leader_cluster", ccrMetadata.get(Ccr.CCR_CUSTOM_METADATA_REMOTE_CLUSTER_NAME_KEY)); assertEquals(followerIndex, followerMetadata.getSettings().get(IndexMetaData.SETTING_INDEX_PROVIDED_NAME)); - assertEquals(true, IndexSettings.INDEX_SOFT_DELETES_SETTING.get(followerMetadata.getSettings())); // UUID is changed so that we can follow indexes on same cluster assertNotEquals(leaderMetadata.getIndexUUID(), followerMetadata.getIndexUUID()); @@ -174,8 +170,7 @@ public void testDocsAreRecovered() throws Exception { String followerIndex = "index2"; final int numberOfPrimaryShards = randomIntBetween(1, 3); - final String leaderIndexSettings = getIndexSettings(numberOfPrimaryShards, between(0, 1), - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(numberOfPrimaryShards, between(0, 1)); assertAcked(leaderClient().admin().indices().prepareCreate(leaderIndex).setSource(leaderIndexSettings, XContentType.JSON)); ensureLeaderGreen(leaderIndex); @@ -231,8 +226,7 @@ public void testRateLimitingIsEmployed() throws Exception { String followerIndex = "index2"; final int numberOfPrimaryShards = randomIntBetween(1, 3); - final String leaderIndexSettings = getIndexSettings(numberOfPrimaryShards, between(0, 1), - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(numberOfPrimaryShards, between(0, 1)); assertAcked(leaderClient().admin().indices().prepareCreate(leaderIndex).setSource(leaderIndexSettings, XContentType.JSON)); ensureLeaderGreen(leaderIndex); @@ -297,8 +291,7 @@ public void testIndividualActionsTimeout() throws Exception { String followerIndex = "index2"; final int numberOfPrimaryShards = randomIntBetween(1, 3); - final String leaderIndexSettings = getIndexSettings(numberOfPrimaryShards, between(0, 1), - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(numberOfPrimaryShards, between(0, 1)); assertAcked(leaderClient().admin().indices().prepareCreate(leaderIndex).setSource(leaderIndexSettings, XContentType.JSON)); ensureLeaderGreen(leaderIndex); @@ -372,8 +365,7 @@ public void testFollowerMappingIsUpdated() throws IOException { String followerIndex = "index2"; final int numberOfPrimaryShards = randomIntBetween(1, 3); - final String leaderIndexSettings = getIndexSettings(numberOfPrimaryShards, between(0, 1), - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(numberOfPrimaryShards, between(0, 1)); assertAcked(leaderClient().admin().indices().prepareCreate(leaderIndex).setSource(leaderIndexSettings, XContentType.JSON)); ensureLeaderGreen(leaderIndex); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRetentionLeaseIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRetentionLeaseIT.java index b74ca1dbc985a..782a61206d8ce 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRetentionLeaseIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRetentionLeaseIT.java @@ -32,7 +32,6 @@ import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexService; -import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.seqno.RetentionLease; import org.elasticsearch.index.seqno.RetentionLeaseActions; import org.elasticsearch.index.seqno.RetentionLeaseNotFoundException; @@ -75,7 +74,6 @@ import java.util.stream.IntStream; import java.util.stream.Stream; -import static java.util.Collections.singletonMap; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.xpack.ccr.CcrRetentionLeases.retentionLeaseId; import static org.hamcrest.Matchers.arrayWithSize; @@ -128,7 +126,6 @@ private RestoreSnapshotRequest setUpRestoreSnapshotRequest( final String leaderClusterRepoName = CcrRepository.NAME_PREFIX + "leader_cluster"; final Map additionalSettings = new HashMap<>(); - additionalSettings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true"); additionalSettings.put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), TimeValue.timeValueMillis(200).getStringRep()); final String leaderIndexSettings = getIndexSettings(numberOfShards, numberOfReplicas, additionalSettings); assertAcked(leaderClient().admin().indices().prepareCreate(leaderIndex).setSource(leaderIndexSettings, XContentType.JSON)); @@ -371,8 +368,7 @@ public void testUnfollowRemovesRetentionLeases() throws Exception { final String leaderIndex = "leader"; final String followerIndex = "follower"; final int numberOfShards = randomIntBetween(1, 4); - final String leaderIndexSettings = - getIndexSettings(numberOfShards, 0, singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(numberOfShards, 0); assertAcked(leaderClient().admin().indices().prepareCreate(leaderIndex).setSource(leaderIndexSettings, XContentType.JSON).get()); ensureLeaderYellow(leaderIndex); final PutFollowAction.Request followRequest = putFollow(leaderIndex, followerIndex); @@ -464,8 +460,7 @@ public void testUnfollowFailsToRemoveRetentionLeases() throws Exception { final String leaderIndex = "leader"; final String followerIndex = "follower"; final int numberOfShards = randomIntBetween(1, 4); - final String leaderIndexSettings = - getIndexSettings(numberOfShards, 0, singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(numberOfShards, 0); assertAcked(leaderClient().admin().indices().prepareCreate(leaderIndex).setSource(leaderIndexSettings, XContentType.JSON).get()); ensureLeaderYellow(leaderIndex); final PutFollowAction.Request followRequest = putFollow(leaderIndex, followerIndex); @@ -536,7 +531,6 @@ public void testRetentionLeaseRenewedWhileFollowing() throws Exception { final int numberOfShards = randomIntBetween(1, 4); final int numberOfReplicas = randomIntBetween(0, 1); final Map additionalIndexSettings = new HashMap<>(); - additionalIndexSettings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), Boolean.toString(true)); additionalIndexSettings.put( IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), TimeValue.timeValueMillis(200).getStringRep()); @@ -556,7 +550,6 @@ public void testRetentionLeaseAdvancesWhileFollowing() throws Exception { final int numberOfShards = randomIntBetween(1, 4); final int numberOfReplicas = randomIntBetween(0, 1); final Map additionalIndexSettings = new HashMap<>(); - additionalIndexSettings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), Boolean.toString(true)); additionalIndexSettings.put( IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), TimeValue.timeValueMillis(200).getStringRep()); @@ -620,7 +613,6 @@ public void testRetentionLeaseRenewalIsCancelledWhenFollowingIsPaused() throws E final int numberOfShards = randomIntBetween(1, 4); final int numberOfReplicas = randomIntBetween(0, 1); final Map additionalIndexSettings = new HashMap<>(); - additionalIndexSettings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), Boolean.toString(true)); additionalIndexSettings.put( IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), TimeValue.timeValueMillis(200).getStringRep()); @@ -727,7 +719,6 @@ public void testRetentionLeaseRenewalIsResumedWhenFollowingIsResumed() throws Ex final int numberOfShards = randomIntBetween(1, 4); final int numberOfReplicas = randomIntBetween(0, 1); final Map additionalIndexSettings = new HashMap<>(); - additionalIndexSettings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), Boolean.toString(true)); additionalIndexSettings.put( IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), TimeValue.timeValueMillis(200).getStringRep()); @@ -754,7 +745,6 @@ public void testRetentionLeaseIsAddedIfItDisappearsWhileFollowing() throws Excep final int numberOfShards = 1; final int numberOfReplicas = 1; final Map additionalIndexSettings = new HashMap<>(); - additionalIndexSettings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), Boolean.toString(true)); additionalIndexSettings.put( IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), TimeValue.timeValueMillis(200).getStringRep()); @@ -855,7 +845,6 @@ public void testPeriodicRenewalDoesNotAddRetentionLeaseAfterUnfollow() throws Ex final int numberOfShards = 1; final int numberOfReplicas = 1; final Map additionalIndexSettings = new HashMap<>(); - additionalIndexSettings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), Boolean.toString(true)); additionalIndexSettings.put( IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), TimeValue.timeValueMillis(200).getStringRep()); @@ -945,8 +934,7 @@ public void testForgetFollower() throws Exception { final String leaderIndex = "leader"; final String followerIndex = "follower"; final int numberOfShards = randomIntBetween(1, 4); - final String leaderIndexSettings = - getIndexSettings(numberOfShards, 0, singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(numberOfShards, 0); assertAcked(leaderClient().admin().indices().prepareCreate(leaderIndex).setSource(leaderIndexSettings, XContentType.JSON).get()); ensureLeaderYellow(leaderIndex); final PutFollowAction.Request followRequest = putFollow(leaderIndex, followerIndex); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CloseFollowerIndexIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CloseFollowerIndexIT.java index 82ca1a61e752d..c77515abefb9e 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CloseFollowerIndexIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CloseFollowerIndexIT.java @@ -17,7 +17,6 @@ import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.engine.ReadOnlyEngine; import org.elasticsearch.xpack.CcrIntegTestCase; import org.elasticsearch.xpack.core.ccr.action.PutFollowAction; @@ -29,7 +28,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import static java.util.Collections.singletonMap; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; @@ -67,7 +65,7 @@ public void restoreUncaughtExceptionHandler() { } public void testCloseAndReopenFollowerIndex() throws Exception { - final String leaderIndexSettings = getIndexSettings(1, 1, singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(1, 1); assertAcked(leaderClient().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON)); ensureLeaderYellow("index1"); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/FollowInfoIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/FollowInfoIT.java index 478043a862b38..07f9380b45ebb 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/FollowInfoIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/FollowInfoIT.java @@ -8,15 +8,14 @@ import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.IndexNotFoundException; -import org.elasticsearch.index.IndexSettings; import org.elasticsearch.xpack.CcrSingleNodeTestCase; import org.elasticsearch.xpack.core.ccr.action.FollowInfoAction; import org.elasticsearch.xpack.core.ccr.action.PauseFollowAction; import org.elasticsearch.xpack.core.ccr.action.PutFollowAction; +import java.util.Collections; import java.util.Comparator; -import static java.util.Collections.singletonMap; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.xpack.ccr.LocalIndexFollowingIT.getIndexSettings; import static org.elasticsearch.xpack.core.ccr.action.FollowInfoAction.Response.Status; @@ -27,8 +26,7 @@ public class FollowInfoIT extends CcrSingleNodeTestCase { public void testFollowInfoApiFollowerIndexFiltering() throws Exception { - final String leaderIndexSettings = getIndexSettings(1, 0, - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(1, 0, Collections.emptyMap()); assertAcked(client().admin().indices().prepareCreate("leader1").setSource(leaderIndexSettings, XContentType.JSON)); ensureGreen("leader1"); assertAcked(client().admin().indices().prepareCreate("leader2").setSource(leaderIndexSettings, XContentType.JSON)); @@ -111,8 +109,7 @@ public void testFollowInfoApiFollowerIndexFiltering() throws Exception { } public void testFollowInfoApiIndexMissing() throws Exception { - final String leaderIndexSettings = getIndexSettings(1, 0, - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(1, 0, Collections.emptyMap()); assertAcked(client().admin().indices().prepareCreate("leader1").setSource(leaderIndexSettings, XContentType.JSON)); ensureGreen("leader1"); assertAcked(client().admin().indices().prepareCreate("leader2").setSource(leaderIndexSettings, XContentType.JSON)); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/FollowStatsIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/FollowStatsIT.java index df24a5296a24c..fea0ede8f96ad 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/FollowStatsIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/FollowStatsIT.java @@ -13,7 +13,6 @@ import org.elasticsearch.action.admin.indices.close.CloseIndexRequest; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.index.IndexSettings; import org.elasticsearch.persistent.PersistentTasksCustomMetaData; import org.elasticsearch.xpack.CcrSingleNodeTestCase; import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction; @@ -21,12 +20,12 @@ import org.elasticsearch.xpack.core.ccr.action.PauseFollowAction; import org.elasticsearch.xpack.core.ccr.action.PutFollowAction; +import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; -import static java.util.Collections.singletonMap; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.xpack.ccr.LocalIndexFollowingIT.getIndexSettings; import static org.hamcrest.Matchers.equalTo; @@ -79,8 +78,7 @@ public void onFailure(final Exception e) { } public void testFollowStatsApiFollowerIndexFiltering() throws Exception { - final String leaderIndexSettings = getIndexSettings(1, 0, - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(1, 0, Collections.emptyMap()); assertAcked(client().admin().indices().prepareCreate("leader1").setSource(leaderIndexSettings, XContentType.JSON)); ensureGreen("leader1"); assertAcked(client().admin().indices().prepareCreate("leader2").setSource(leaderIndexSettings, XContentType.JSON)); @@ -130,8 +128,7 @@ public void testFollowStatsApiResourceNotFound() throws Exception { () -> client().execute(FollowStatsAction.INSTANCE, statsRequest).actionGet()); assertThat(e.getMessage(), equalTo("No shard follow tasks for follower indices [follower1]")); - final String leaderIndexSettings = getIndexSettings(1, 0, - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(1, 0, Collections.emptyMap()); assertAcked(client().admin().indices().prepareCreate("leader1").setSource(leaderIndexSettings, XContentType.JSON)); ensureGreen("leader1"); @@ -151,7 +148,7 @@ public void testFollowStatsApiResourceNotFound() throws Exception { } public void testFollowStatsApiWithDeletedFollowerIndex() throws Exception { - final String leaderIndexSettings = getIndexSettings(1, 0, singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(1, 0, Collections.emptyMap()); assertAcked(client().admin().indices().prepareCreate("leader1").setSource(leaderIndexSettings, XContentType.JSON)); ensureGreen("leader1"); @@ -179,8 +176,7 @@ public void testFollowStatsApiWithDeletedFollowerIndex() throws Exception { } public void testFollowStatsApiIncludeShardFollowStatsWithClosedFollowerIndex() throws Exception { - final String leaderIndexSettings = getIndexSettings(1, 0, - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(1, 0, Collections.emptyMap()); assertAcked(client().admin().indices().prepareCreate("leader1").setSource(leaderIndexSettings, XContentType.JSON)); ensureGreen("leader1"); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/FollowerFailOverIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/FollowerFailOverIT.java index 177b1c66ca457..1b7f7c1a9aa1f 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/FollowerFailOverIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/FollowerFailOverIT.java @@ -21,7 +21,6 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.common.xcontent.support.XContentMapValues; -import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.shard.ShardId; @@ -39,7 +38,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; -import static java.util.Collections.singletonMap; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.hamcrest.Matchers.equalTo; @@ -56,8 +54,7 @@ public void testFailOverOnFollower() throws Exception { int numberOfReplicas = between(1, 2); getFollowerCluster().startMasterOnlyNode(); getFollowerCluster().ensureAtLeastNumDataNodes(numberOfReplicas + between(1, 2)); - String leaderIndexSettings = getIndexSettings(1, numberOfReplicas, - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + String leaderIndexSettings = getIndexSettings(1, numberOfReplicas); assertAcked(leaderClient().admin().indices().prepareCreate(leaderIndex).setSource(leaderIndexSettings, XContentType.JSON)); AtomicBoolean stopped = new AtomicBoolean(); Thread[] threads = new Thread[between(1, 8)]; @@ -122,7 +119,7 @@ public void testFailOverOnFollower() throws Exception { public void testFollowIndexAndCloseNode() throws Exception { getFollowerCluster().ensureAtLeastNumDataNodes(3); - String leaderIndexSettings = getIndexSettings(3, 1, singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + String leaderIndexSettings = getIndexSettings(3, 1); assertAcked(leaderClient().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON)); ensureLeaderGreen("index1"); @@ -176,8 +173,7 @@ public void testFollowIndexAndCloseNode() throws Exception { public void testAddNewReplicasOnFollower() throws Exception { int numberOfReplicas = between(0, 1); - String leaderIndexSettings = getIndexSettings(1, numberOfReplicas, - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + String leaderIndexSettings = getIndexSettings(1, numberOfReplicas); assertAcked(leaderClient().admin().indices().prepareCreate("leader-index").setSource(leaderIndexSettings, XContentType.JSON)); PutFollowAction.Request follow = putFollow("leader-index", "follower-index"); followerClient().execute(PutFollowAction.INSTANCE, follow).get(); @@ -244,7 +240,6 @@ public void testReadRequestsReturnLatestMappingVersion() throws Exception { .setSettings(Settings.builder() .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true") .put("index.routing.allocation.require.box", "large")) .get() ); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java index e25c0be5731ae..c12021eaf21ee 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java @@ -66,7 +66,6 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.index.IndexService; -import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.seqno.ReplicationTracker; import org.elasticsearch.index.seqno.RetentionLeaseActions; import org.elasticsearch.index.shard.ShardId; @@ -114,7 +113,6 @@ import java.util.stream.IntStream; import java.util.stream.Stream; -import static java.util.Collections.singletonMap; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.xpack.ccr.CcrRetentionLeases.retentionLeaseId; @@ -145,8 +143,7 @@ public void testFollowIndex() throws Exception { new ByteSizeValue(randomIntBetween(1, 1000), ByteSizeUnit.KB))) .get(); - final String leaderIndexSettings = getIndexSettings(numberOfPrimaryShards, numberOfReplicas, - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(numberOfPrimaryShards, numberOfReplicas); assertAcked(leaderClient().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON)); ensureLeaderYellow("index1"); @@ -244,8 +241,7 @@ public void testFollowIndex() throws Exception { public void testFollowIndexWithConcurrentMappingChanges() throws Exception { final int numberOfPrimaryShards = randomIntBetween(1, 3); - final String leaderIndexSettings = getIndexSettings(numberOfPrimaryShards, between(0, 1), - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(numberOfPrimaryShards, between(0, 1)); assertAcked(leaderClient().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON)); ensureLeaderYellow("index1"); @@ -313,8 +309,7 @@ public void testFollowIndexWithConcurrentMappingChanges() throws Exception { public void testFollowIndexWithoutWaitForComplete() throws Exception { final int numberOfPrimaryShards = randomIntBetween(1, 3); - final String leaderIndexSettings = getIndexSettings(numberOfPrimaryShards, between(0, 1), - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(numberOfPrimaryShards, between(0, 1)); assertAcked(leaderClient().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON)); ensureLeaderYellow("index1"); @@ -355,8 +350,7 @@ public void testFollowIndexWithoutWaitForComplete() throws Exception { } public void testSyncMappings() throws Exception { - final String leaderIndexSettings = getIndexSettings(2, between(0, 1), - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(2, between(0, 1)); assertAcked(leaderClient().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON)); ensureLeaderYellow("index1"); @@ -395,7 +389,6 @@ public void testSyncMappings() throws Exception { public void testNoMappingDefined() throws Exception { assertAcked(leaderClient().admin().indices().prepareCreate("index1") .setSettings(Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0) .build())); @@ -415,8 +408,7 @@ public void testNoMappingDefined() throws Exception { } public void testDoNotAllowPutMappingToFollower() throws Exception { - final String leaderIndexSettings = getIndexSettings(between(1, 2), between(0, 1), - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(between(1, 2), between(0, 1)); assertAcked(leaderClient().admin().indices().prepareCreate("index-1").setSource(leaderIndexSettings, XContentType.JSON)); followerClient().execute(PutFollowAction.INSTANCE, putFollow("index-1", "index-2")).get(); PutMappingRequest putMappingRequest = new PutMappingRequest("index-2").source("new_field", "type=keyword"); @@ -435,7 +427,7 @@ public void testDoNotAllowPutMappingToFollower() throws Exception { public void testDoNotAllowAddAliasToFollower() throws Exception { final String leaderIndexSettings = - getIndexSettings(between(1, 2), between(0, 1), singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + getIndexSettings(between(1, 2), between(0, 1)); assertAcked(leaderClient().admin().indices().prepareCreate("leader").setSource(leaderIndexSettings, XContentType.JSON)); followerClient().execute(PutFollowAction.INSTANCE, putFollow("leader", "follower")).get(); final IndicesAliasesRequest request = new IndicesAliasesRequest() @@ -451,7 +443,7 @@ public void testDoNotAllowAddAliasToFollower() throws Exception { public void testAddAliasAfterUnfollow() throws Exception { final String leaderIndexSettings = - getIndexSettings(between(1, 2), between(0, 1), singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + getIndexSettings(between(1, 2), between(0, 1)); assertAcked(leaderClient().admin().indices().prepareCreate("leader").setSource(leaderIndexSettings, XContentType.JSON)); followerClient().execute(PutFollowAction.INSTANCE, putFollow("leader", "follower")).get(); pauseFollow("follower"); @@ -472,8 +464,7 @@ public void testAddAliasAfterUnfollow() throws Exception { public void testFollowIndex_backlog() throws Exception { int numberOfShards = between(1, 5); - String leaderIndexSettings = getIndexSettings(numberOfShards, between(0, 1), - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + String leaderIndexSettings = getIndexSettings(numberOfShards, between(0, 1)); assertAcked(leaderClient().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON)); BulkProcessor.Listener listener = new BulkProcessor.Listener() { @Override @@ -536,8 +527,7 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure) } public void testFollowIndexWithNestedField() throws Exception { - final String leaderIndexSettings = - getIndexSettingsWithNestedMapping(1, between(0, 1), singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettingsWithNestedMapping(1, between(0, 1), Collections.emptyMap()); assertAcked(leaderClient().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON)); ensureLeaderGreen("index1"); @@ -582,7 +572,7 @@ public void testUnfollowNonExistingIndex() { } public void testFollowNonExistentIndex() throws Exception { - String indexSettings = getIndexSettings(1, 0, Collections.emptyMap()); + String indexSettings = getIndexSettings(1, 0); assertAcked(leaderClient().admin().indices().prepareCreate("test-leader").setSource(indexSettings, XContentType.JSON).get()); assertAcked(followerClient().admin().indices().prepareCreate("test-follower").setSource(indexSettings, XContentType.JSON).get()); ensureLeaderGreen("test-leader"); @@ -603,8 +593,7 @@ public void testFollowNonExistentIndex() throws Exception { } public void testFollowIndexMaxOperationSizeInBytes() throws Exception { - final String leaderIndexSettings = getIndexSettings(1, between(0, 1), - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(1, between(0, 1)); assertAcked(leaderClient().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON)); ensureLeaderYellow("index1"); @@ -638,7 +627,7 @@ public void testFollowIndexMaxOperationSizeInBytes() throws Exception { } public void testAttemptToChangeCcrFollowingIndexSetting() throws Exception { - String leaderIndexSettings = getIndexSettings(1, 0, singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + String leaderIndexSettings = getIndexSettings(1, 0); assertAcked(leaderClient().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON).get()); ensureLeaderYellow("index1"); PutFollowAction.Request followRequest = putFollow("index1", "index2"); @@ -657,7 +646,6 @@ public void testAttemptToChangeCcrFollowingIndexSetting() throws Exception { public void testCloseLeaderIndex() throws Exception { assertAcked(leaderClient().admin().indices().prepareCreate("index1") .setSettings(Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0) .build())); @@ -691,7 +679,6 @@ public void testCloseLeaderIndex() throws Exception { public void testCloseFollowIndex() throws Exception { assertAcked(leaderClient().admin().indices().prepareCreate("index1") .setSettings(Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0) .build())); @@ -720,7 +707,6 @@ public void testCloseFollowIndex() throws Exception { public void testDeleteLeaderIndex() throws Exception { assertAcked(leaderClient().admin().indices().prepareCreate("index1") .setSettings(Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0) .build())); @@ -748,10 +734,7 @@ public void testDeleteLeaderIndex() throws Exception { public void testFollowClosedIndex() { final String leaderIndex = "test-index"; - assertAcked(leaderClient().admin().indices().prepareCreate(leaderIndex) - .setSettings(Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) - .build())); + assertAcked(leaderClient().admin().indices().prepareCreate(leaderIndex)); assertAcked(leaderClient().admin().indices().prepareClose(leaderIndex)); final String followerIndex = "follow-test-index"; @@ -764,7 +747,6 @@ public void testResumeFollowOnClosedIndex() throws Exception { final String leaderIndex = "test-index"; assertAcked(leaderClient().admin().indices().prepareCreate(leaderIndex) .setSettings(Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0) .build())); @@ -790,7 +772,6 @@ public void testResumeFollowOnClosedIndex() throws Exception { public void testDeleteFollowerIndex() throws Exception { assertAcked(leaderClient().admin().indices().prepareCreate("index1") .setSettings(Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0) .build())); @@ -821,7 +802,6 @@ public void testDeleteFollowerIndex() throws Exception { public void testPauseIndex() throws Exception { assertAcked(leaderClient().admin().indices().prepareCreate("leader") .setSettings(Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0) .build())); @@ -840,7 +820,7 @@ public void testPauseIndex() throws Exception { } public void testUnfollowIndex() throws Exception { - String leaderIndexSettings = getIndexSettings(1, 0, singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + String leaderIndexSettings = getIndexSettings(1, 0); assertAcked(leaderClient().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON).get()); PutFollowAction.Request followRequest = putFollow("index1", "index2"); followerClient().execute(PutFollowAction.INSTANCE, followRequest).get(); @@ -867,8 +847,7 @@ public void testUnfollowIndex() throws Exception { } public void testUnknownClusterAlias() throws Exception { - String leaderIndexSettings = getIndexSettings(1, 0, - Collections.singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + String leaderIndexSettings = getIndexSettings(1, 0); assertAcked(leaderClient().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON)); ensureLeaderGreen("index1"); PutFollowAction.Request followRequest = putFollow("index1", "index2"); @@ -893,7 +872,6 @@ public void testLeaderIndexRed() throws Exception { assertAcked(leaderClient().admin().indices().prepareCreate("index1") .setWaitForActiveShards(ActiveShardCount.NONE) .setSettings(Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0) .build())); @@ -913,8 +891,7 @@ public void testLeaderIndexRed() throws Exception { } public void testUpdateDynamicLeaderIndexSettings() throws Exception { - final String leaderIndexSettings = getIndexSettings(1, 0, - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(1, 0); assertAcked(leaderClient().admin().indices().prepareCreate("leader").setSource(leaderIndexSettings, XContentType.JSON)); ensureLeaderYellow("leader"); @@ -967,8 +944,7 @@ public void testLeaderIndexSettingNotPercolatedToFollower() throws Exception { // Sets an index setting on leader index that is excluded from being replicated to the follower index and // expects that this setting is not replicated to the follower index, but does expect that the settings version // is incremented. - final String leaderIndexSettings = getIndexSettings(1, 0, - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(1, 0); assertAcked(leaderClient().admin().indices().prepareCreate("leader").setSource(leaderIndexSettings, XContentType.JSON)); ensureLeaderYellow("leader"); @@ -1017,8 +993,7 @@ public void testLeaderIndexSettingNotPercolatedToFollower() throws Exception { } public void testUpdateAnalysisLeaderIndexSettings() throws Exception { - final String leaderIndexSettings = getIndexSettings(1, 0, - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(1, 0); assertAcked(leaderClient().admin().indices().prepareCreate("leader").setSource(leaderIndexSettings, XContentType.JSON)); ensureLeaderYellow("leader"); @@ -1089,8 +1064,7 @@ public void testUpdateAnalysisLeaderIndexSettings() throws Exception { } public void testDoNotReplicatePrivateSettings() throws Exception { - assertAcked(leaderClient().admin().indices().prepareCreate("leader").setSource( - getIndexSettings(1, 0, singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")), XContentType.JSON)); + assertAcked(leaderClient().admin().indices().prepareCreate("leader").setSource(getIndexSettings(1, 0), XContentType.JSON)); ensureLeaderGreen("leader"); final PutFollowAction.Request followRequest = putFollow("leader", "follower"); followerClient().execute(PutFollowAction.INSTANCE, followRequest).get(); @@ -1129,8 +1103,7 @@ public void onFailure(String source, Exception e) { } public void testReplicatePrivateSettingsOnly() throws Exception { - assertAcked(leaderClient().admin().indices().prepareCreate("leader").setSource( - getIndexSettings(1, 0, singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")), XContentType.JSON)); + assertAcked(leaderClient().admin().indices().prepareCreate("leader").setSource(getIndexSettings(1, 0), XContentType.JSON)); ensureLeaderGreen("leader"); followerClient().execute(PutFollowAction.INSTANCE, putFollow("leader", "follower")).get(); final ClusterService clusterService = getLeaderCluster().getInstance(ClusterService.class, getLeaderCluster().getMasterName()); @@ -1170,8 +1143,7 @@ public void onFailure(String source, Exception e) { public void testMustCloseIndexAndPauseToRestartWithPutFollowing() throws Exception { final int numberOfPrimaryShards = randomIntBetween(1, 3); - final String leaderIndexSettings = getIndexSettings(numberOfPrimaryShards, between(0, 1), - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(numberOfPrimaryShards, between(0, 1)); assertAcked(leaderClient().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON)); ensureLeaderYellow("index1"); @@ -1254,7 +1226,6 @@ private void runFallBehindTest( final Consumer> exceptionConsumer) throws Exception { final int numberOfPrimaryShards = randomIntBetween(1, 3); final Map extraSettingsMap = new HashMap<>(2); - extraSettingsMap.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true"); extraSettingsMap.put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "200ms"); final String leaderIndexSettings = getIndexSettings(numberOfPrimaryShards, between(0, 1), extraSettingsMap); assertAcked(leaderClient().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON)); @@ -1337,8 +1308,7 @@ public void testUpdateRemoteConfigsDuringFollowing() throws Exception { final int numberOfPrimaryShards = randomIntBetween(1, 3); int numberOfReplicas = between(0, 1); - final String leaderIndexSettings = getIndexSettings(numberOfPrimaryShards, numberOfReplicas, - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(numberOfPrimaryShards, numberOfReplicas); assertAcked(leaderClient().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON)); ensureLeaderYellow("index1"); @@ -1400,7 +1370,6 @@ public void testCleanUpShardFollowTasksForDeletedIndices() throws Exception { final int numberOfShards = randomIntBetween(1, 10); assertAcked(leaderClient().admin().indices().prepareCreate("index1") .setSettings(Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, numberOfShards) .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, randomIntBetween(0, 1)) .build())); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/LocalIndexFollowingIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/LocalIndexFollowingIT.java index 3a52950d1788b..dc988e50635ad 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/LocalIndexFollowingIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/LocalIndexFollowingIT.java @@ -35,8 +35,7 @@ public class LocalIndexFollowingIT extends CcrSingleNodeTestCase { public void testFollowIndex() throws Exception { - final String leaderIndexSettings = getIndexSettings(2, 0, - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(2, 0, Collections.emptyMap()); assertAcked(client().admin().indices().prepareCreate("leader").setSource(leaderIndexSettings, XContentType.JSON)); ensureGreen("leader"); @@ -104,7 +103,6 @@ public void testRemoveRemoteConnection() throws Exception { long previousNumberOfSuccessfulFollowedIndices = getAutoFollowStats().getNumberOfSuccessfulFollowIndices(); Settings leaderIndexSettings = Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) .build(); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/RestartIndexFollowingIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/RestartIndexFollowingIT.java index 88370aed0db71..c13d778634fd9 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/RestartIndexFollowingIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/RestartIndexFollowingIT.java @@ -11,7 +11,6 @@ import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.index.IndexSettings; import org.elasticsearch.transport.RemoteConnectionInfo; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.CcrIntegTestCase; @@ -20,7 +19,6 @@ import java.util.List; import java.util.Locale; -import static java.util.Collections.singletonMap; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.hamcrest.Matchers.equalTo; @@ -37,8 +35,7 @@ protected boolean configureRemoteClusterViaNodeSettings() { } public void testFollowIndex() throws Exception { - final String leaderIndexSettings = getIndexSettings(1, 0, - singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); + final String leaderIndexSettings = getIndexSettings(1, 0); assertAcked(leaderClient().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON)); ensureLeaderGreen("index1"); setupRemoteCluster(); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinatorTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinatorTests.java index 1801171866540..de6786ea3d825 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinatorTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinatorTests.java @@ -29,7 +29,6 @@ import org.elasticsearch.common.util.concurrent.ConcurrentCollections; import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; import org.elasticsearch.index.Index; -import org.elasticsearch.index.IndexSettings; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.ccr.Ccr; import org.elasticsearch.xpack.ccr.CcrLicenseChecker; @@ -617,7 +616,7 @@ public void testGetLeaderIndicesToFollow_shardsNotStarted() { ClusterState remoteState = createRemoteClusterState("index1", true); MetaData.Builder mBuilder= MetaData.builder(remoteState.metaData()); mBuilder.put(IndexMetaData.builder("index2") - .settings(settings(Version.CURRENT).put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true)) + .settings(settings(Version.CURRENT)) .numberOfShards(1) .numberOfReplicas(0)); ShardRouting shardRouting = @@ -706,13 +705,11 @@ public void testCleanFollowedLeaderIndices() { MetaData remoteMetadata = new MetaData.Builder() .put(IndexMetaData.builder("index1") .settings(settings(Version.CURRENT) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.SETTING_INDEX_UUID, "index1")) .numberOfShards(1) .numberOfReplicas(0)) .put(IndexMetaData.builder("index3") .settings(settings(Version.CURRENT) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.SETTING_INDEX_UUID, "index3")) .numberOfShards(1) .numberOfReplicas(0)) @@ -735,19 +732,16 @@ public void testCleanFollowedLeaderIndicesNoChanges() { MetaData remoteMetadata = new MetaData.Builder() .put(IndexMetaData.builder("index1") .settings(settings(Version.CURRENT) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.SETTING_INDEX_UUID, "index1")) .numberOfShards(1) .numberOfReplicas(0)) .put(IndexMetaData.builder("index2") .settings(settings(Version.CURRENT) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.SETTING_INDEX_UUID, "index2")) .numberOfShards(1) .numberOfReplicas(0)) .put(IndexMetaData.builder("index3") .settings(settings(Version.CURRENT) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.SETTING_INDEX_UUID, "index3")) .numberOfShards(1) .numberOfReplicas(0)) @@ -767,7 +761,7 @@ public void testCleanFollowedLeaderIndicesNoEntry() { MetaData remoteMetadata = new MetaData.Builder() .put(IndexMetaData.builder("index1") - .settings(settings(Version.CURRENT).put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true)) + .settings(settings(Version.CURRENT)) .numberOfShards(1) .numberOfReplicas(0)) .build(); @@ -1251,7 +1245,7 @@ public void testAutoFollowerFollowerIndexAlreadyExists() { ClusterState currentState = ClusterState.builder(new ClusterName("name")) .metaData(MetaData.builder() .put(IndexMetaData.builder("logs-20190101") - .settings(settings(Version.CURRENT).put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true)) + .settings(settings(Version.CURRENT)) .putCustom(Ccr.CCR_CUSTOM_METADATA_KEY, Map.of(Ccr.CCR_CUSTOM_METADATA_LEADER_INDEX_UUID_KEY, remoteState.metaData().index("logs-20190101").getIndexUUID())) .numberOfShards(1) @@ -1396,7 +1390,7 @@ public void testClosedIndicesAreNotAutoFollowed() { final ClusterState localState = ClusterState.builder(new ClusterName("local")) .metaData(MetaData.builder() .putCustom(AutoFollowMetadata.TYPE, - new AutoFollowMetadata(Map.of(pattern, new AutoFollowPattern("remote", List.of("docs-*"), null, true, + new AutoFollowMetadata(Map.of(pattern, new AutoFollowPattern("remote", List.of("docs-*"), null, true, null, null, null, null, null, null, null, null, null, null)), Map.of(pattern, List.of()), Map.of(pattern, Map.of())))) .build(); @@ -1474,7 +1468,6 @@ private static ClusterState createRemoteClusterState(String indexName, boolean e private static ClusterState createRemoteClusterState(String indexName, boolean enableSoftDeletes, long metadataVersion) { Settings.Builder indexSettings; indexSettings = settings(Version.CURRENT) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), enableSoftDeletes) .put(IndexMetaData.SETTING_INDEX_UUID, UUIDs.randomBase64UUID(random())); IndexMetaData indexMetaData = IndexMetaData.builder(indexName) @@ -1504,7 +1497,6 @@ private static ClusterState createRemoteClusterState(final ClusterState previous for (String indexName : indices) { IndexMetaData indexMetaData = IndexMetaData.builder(indexName) .settings(settings(Version.CURRENT) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexMetaData.SETTING_INDEX_UUID, UUIDs.randomBase64UUID(random()))) .numberOfShards(1) .numberOfReplicas(0) diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardChangesActionTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardChangesActionTests.java index 801cc7aef158c..b4980913e6bd7 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardChangesActionTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardChangesActionTests.java @@ -17,7 +17,6 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.index.IndexService; -import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.shard.IndexShardNotStartedException; import org.elasticsearch.index.shard.ShardId; @@ -50,7 +49,6 @@ public void testGetOperations() throws Exception { final Settings settings = Settings.builder() .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .build(); final IndexService indexService = createIndex("index", settings); @@ -135,7 +133,6 @@ public void testGetOperationsExceedByteLimit() throws Exception { final Settings settings = Settings.builder() .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .build(); final IndexService indexService = createIndex("index", settings); @@ -166,7 +163,6 @@ public void testGetOperationsAlwaysReturnAtLeastOneOp() throws Exception { final Settings settings = Settings.builder() .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .build(); final IndexService indexService = createIndex("index", settings); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardChangesTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardChangesTests.java index c4b56adbd388e..856693b976648 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardChangesTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardChangesTests.java @@ -46,9 +46,7 @@ protected Collection> getPlugins() { // this emulates what the CCR persistent task will do for pulling public void testGetOperationsBasedOnGlobalSequenceId() throws Exception { - client().admin().indices().prepareCreate("index") - .setSettings(Settings.builder().put("index.number_of_shards", 1).put("index.soft_deletes.enabled", true)) - .get(); + client().admin().indices().prepareCreate("index").setSettings(Settings.builder().put("index.number_of_shards", 1)).get(); client().prepareIndex("index").setId("1").setSource("{}", XContentType.JSON).get(); client().prepareIndex("index").setId("2").setSource("{}", XContentType.JSON).get(); @@ -105,7 +103,6 @@ public void testGetOperationsBasedOnGlobalSequenceId() throws Exception { public void testMissingOperations() throws Exception { client().admin().indices().prepareCreate("index") .setSettings(Settings.builder() - .put("index.soft_deletes.enabled", true) .put("index.soft_deletes.retention.operations", 0) .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowTaskReplicationTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowTaskReplicationTests.java index aebf4129c1afb..67c46b60dddf6 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowTaskReplicationTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowTaskReplicationTests.java @@ -341,7 +341,6 @@ public void testAddNewFollowingReplica() throws Exception { } Future recoveryFuture = null; Settings settings = Settings.builder().put(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey(), true) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(), new ByteSizeValue(between(1, 1000), ByteSizeUnit.KB)) .build(); IndexMetaData indexMetaData = buildIndexMetaData(between(0, 1), settings, indexMapping); @@ -427,7 +426,6 @@ public void testRetentionLeaseManagement() throws Exception { private ReplicationGroup createLeaderGroup(int replicas) throws IOException { Settings settings = Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexSettings.INDEX_SOFT_DELETES_RETENTION_OPERATIONS_SETTING.getKey(), 10000) .build(); return createGroup(replicas, settings); @@ -435,10 +433,8 @@ private ReplicationGroup createLeaderGroup(int replicas) throws IOException { private ReplicationGroup createFollowGroup(ReplicationGroup leaderGroup, int replicas) throws IOException { final Settings settings = Settings.builder().put(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey(), true) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) - .put( - IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(), - new ByteSizeValue(between(1, 1000), ByteSizeUnit.KB)) + .put(IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(), + new ByteSizeValue(between(1, 1000), ByteSizeUnit.KB)) .build(); IndexMetaData indexMetaData = buildIndexMetaData(replicas, settings, indexMapping); return new ReplicationGroup(indexMetaData) { diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowActionTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowActionTests.java index 3fddd5a7d3f7e..12ee49bd9432e 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowActionTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowActionTests.java @@ -96,8 +96,7 @@ public void testValidation() throws IOException { } { // should fail, because leader index is closed - IndexMetaData leaderIMD = createIMD("index1", State.CLOSE, "{}", 5, Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true").build(), null); + IndexMetaData leaderIMD = createIMD("index1", State.CLOSE, "{}", 5, Settings.EMPTY, null); IndexMetaData followIMD = createIMD("index2", State.OPEN, "{}", 5, Settings.EMPTY, customMetaData); Exception e = expectThrows(IllegalArgumentException.class, () -> validate(request, leaderIMD, followIMD, UUIDs, null)); assertThat(e.getMessage(), equalTo("leader and follow index must be open")); @@ -116,10 +115,9 @@ public void testValidation() throws IOException { { // should fail, because leader has a field with the same name mapped as keyword and follower as text IndexMetaData leaderIMD = createIMD("index1", State.OPEN, "{\"properties\": {\"field\": {\"type\": \"keyword\"}}}", 5, - Settings.builder().put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true").build(), null); + Settings.EMPTY, null); IndexMetaData followIMD = createIMD("index2", State.OPEN, "{\"properties\": {\"field\": {\"type\": \"text\"}}}", 5, - Settings.builder().put(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey(), true) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true).build(), customMetaData); + Settings.builder().put(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey(), true).build(), customMetaData); MapperService mapperService = MapperTestUtils.newMapperService(xContentRegistry(), createTempDir(), Settings.EMPTY, "index2"); mapperService.updateMapping(null, followIMD); Exception e = expectThrows(IllegalArgumentException.class, () -> validate(request, leaderIMD, followIMD, UUIDs, mapperService)); @@ -129,12 +127,10 @@ public void testValidation() throws IOException { // should fail because of non whitelisted settings not the same between leader and follow index String mapping = "{\"properties\": {\"field\": {\"type\": \"text\", \"analyzer\": \"my_analyzer\"}}}"; IndexMetaData leaderIMD = createIMD("index1", State.OPEN, mapping, 5, Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true") .put("index.analysis.analyzer.my_analyzer.type", "custom") .put("index.analysis.analyzer.my_analyzer.tokenizer", "whitespace").build(), null); IndexMetaData followIMD = createIMD("index2", State.OPEN, mapping, 5, Settings.builder() .put(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey(), true) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put("index.analysis.analyzer.my_analyzer.type", "custom") .put("index.analysis.analyzer.my_analyzer.tokenizer", "standard").build(), customMetaData); Exception e = expectThrows(IllegalArgumentException.class, () -> validate(request, leaderIMD, followIMD, UUIDs, null)); @@ -145,10 +141,8 @@ public void testValidation() throws IOException { } { // should fail because the following index does not have the following_index settings - IndexMetaData leaderIMD = createIMD("index1", 5, - Settings.builder().put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true").build(), null); - Settings followingIndexSettings = Settings.builder().put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) - .put(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey(), false).build(); + IndexMetaData leaderIMD = createIMD("index1", 5, Settings.EMPTY, null); + Settings followingIndexSettings = Settings.builder().put(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey(), false).build(); IndexMetaData followIMD = createIMD("index2", 5, followingIndexSettings, customMetaData); MapperService mapperService = MapperTestUtils.newMapperService(xContentRegistry(), createTempDir(), followingIndexSettings, "index2"); @@ -160,10 +154,8 @@ public void testValidation() throws IOException { } { // should succeed - IndexMetaData leaderIMD = createIMD("index1", 5, Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true").build(), null); + IndexMetaData leaderIMD = createIMD("index1", 5, Settings.EMPTY, null); IndexMetaData followIMD = createIMD("index2", 5, Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey(), true).build(), customMetaData); MapperService mapperService = MapperTestUtils.newMapperService(xContentRegistry(), createTempDir(), Settings.EMPTY, "index2"); mapperService.updateMapping(null, followIMD); @@ -173,12 +165,10 @@ public void testValidation() throws IOException { // should succeed, index settings are identical String mapping = "{\"properties\": {\"field\": {\"type\": \"text\", \"analyzer\": \"my_analyzer\"}}}"; IndexMetaData leaderIMD = createIMD("index1", State.OPEN, mapping, 5, Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true") .put("index.analysis.analyzer.my_analyzer.type", "custom") .put("index.analysis.analyzer.my_analyzer.tokenizer", "standard").build(), null); IndexMetaData followIMD = createIMD("index2", State.OPEN, mapping, 5, Settings.builder() .put(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey(), true) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put("index.analysis.analyzer.my_analyzer.type", "custom") .put("index.analysis.analyzer.my_analyzer.tokenizer", "standard").build(), customMetaData); MapperService mapperService = MapperTestUtils.newMapperService(xContentRegistry(), createTempDir(), @@ -190,13 +180,11 @@ public void testValidation() throws IOException { // should succeed despite whitelisted settings being different String mapping = "{\"properties\": {\"field\": {\"type\": \"text\", \"analyzer\": \"my_analyzer\"}}}"; IndexMetaData leaderIMD = createIMD("index1", State.OPEN, mapping, 5, Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true") .put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "1s") .put("index.analysis.analyzer.my_analyzer.type", "custom") .put("index.analysis.analyzer.my_analyzer.tokenizer", "standard").build(), null); IndexMetaData followIMD = createIMD("index2", State.OPEN, mapping, 5, Settings.builder() .put(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey(), true) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "10s") .put("index.analysis.analyzer.my_analyzer.type", "custom") .put("index.analysis.analyzer.my_analyzer.tokenizer", "standard").build(), customMetaData); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/bulk/BulkShardOperationsTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/bulk/BulkShardOperationsTests.java index 2510a177056d3..1915e578e7f0e 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/bulk/BulkShardOperationsTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/bulk/BulkShardOperationsTests.java @@ -13,7 +13,6 @@ import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.Randomness; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.mapper.Uid; import org.elasticsearch.index.shard.IndexShard; @@ -41,8 +40,7 @@ public class BulkShardOperationsTests extends IndexShardTestCase { // test that we use the primary term on the follower when applying operations from the leader public void testPrimaryTermFromFollower() throws IOException { - final Settings settings = Settings.builder().put(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey(), true) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true).build(); + final Settings settings = Settings.builder().put(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey(), true).build(); final IndexShard followerPrimary = newStartedShard(true, settings, new FollowingEngineFactory()); // we use this primary on the operations yet we expect the applied operations to have the primary term of the follower @@ -92,8 +90,7 @@ public void testPrimaryTermFromFollower() throws IOException { } public void testPrimaryResultIncludeOnlyAppliedOperations() throws Exception { - final Settings settings = Settings.builder().put(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey(), true) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true).build(); + final Settings settings = Settings.builder().put(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey(), true).build(); final IndexShard oldPrimary = newStartedShard(true, settings, new FollowingEngineFactory()); final long oldPrimaryTerm = oldPrimary.getOperationPrimaryTerm(); long seqno = 0; diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/index/engine/FollowEngineIndexShardTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/index/engine/FollowEngineIndexShardTests.java index 44112b114a771..fe06c0b0b1e00 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/index/engine/FollowEngineIndexShardTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/index/engine/FollowEngineIndexShardTests.java @@ -21,7 +21,6 @@ import org.elasticsearch.common.lease.Releasable; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.engine.EngineTestCase; import org.elasticsearch.index.mapper.SourceToParse; import org.elasticsearch.index.shard.IndexShard; @@ -50,11 +49,7 @@ public class FollowEngineIndexShardTests extends IndexShardTestCase { public void testDoNotFillGaps() throws Exception { - Settings settings = Settings.builder() - .put(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey(), true) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) - .build(); - final IndexShard indexShard = newStartedShard(false, settings, new FollowingEngineFactory()); + final IndexShard indexShard = newStartedShard(false, Settings.EMPTY, new FollowingEngineFactory()); long seqNo = -1; for (int i = 0; i < 8; i++) { @@ -99,13 +94,9 @@ public void testDoNotFillGaps() throws Exception { } public void testRestoreShard() throws IOException { - final Settings sourceSettings = Settings.builder() - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) - .build(); - final IndexShard source = newStartedShard(true, sourceSettings); + final IndexShard source = newStartedShard(true, Settings.EMPTY); final Settings targetSettings = Settings.builder() .put(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey(), true) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .build(); IndexShard target = newStartedShard(true, targetSettings, new FollowingEngineFactory()); assertThat(IndexShardTestCase.getEngine(target), instanceOf(FollowingEngine.class)); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/index/engine/FollowingEngineTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/index/engine/FollowingEngineTests.java index eb07feed60068..286526f6e70f2 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/index/engine/FollowingEngineTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/index/engine/FollowingEngineTests.java @@ -131,7 +131,6 @@ public void testOutOfOrderDocuments() throws IOException { .put("index.number_of_replicas", 0) .put("index.version.created", Version.CURRENT) .put("index.xpack.ccr.following_index", true) - .put("index.soft_deletes.enabled", true) .build(); final IndexMetaData indexMetaData = IndexMetaData.builder(index.getName()).settings(settings).build(); final IndexSettings indexSettings = new IndexSettings(indexMetaData, settings); @@ -157,7 +156,6 @@ public void runIndexTest( .put("index.number_of_replicas", 0) .put("index.version.created", Version.CURRENT) .put("index.xpack.ccr.following_index", true) - .put("index.soft_deletes.enabled", true) .build(); final IndexMetaData indexMetaData = IndexMetaData.builder(index.getName()).settings(settings).build(); final IndexSettings indexSettings = new IndexSettings(indexMetaData, settings); @@ -192,7 +190,6 @@ public void runDeleteTest( .put("index.number_of_replicas", 0) .put("index.version.created", Version.CURRENT) .put("index.xpack.ccr.following_index", true) - .put("index.soft_deletes.enabled", true) .build(); final IndexMetaData indexMetaData = IndexMetaData.builder(index.getName()).settings(settings).build(); final IndexSettings indexSettings = new IndexSettings(indexMetaData, settings); @@ -223,7 +220,6 @@ public void testDoNotFillSeqNoGaps() throws Exception { .put("index.number_of_replicas", 0) .put("index.version.created", Version.CURRENT) .put("index.xpack.ccr.following_index", true) - .put("index.soft_deletes.enabled", true) .build(); final IndexMetaData indexMetaData = IndexMetaData.builder(index.getName()).settings(settings).build(); final IndexSettings indexSettings = new IndexSettings(indexMetaData, settings); @@ -492,7 +488,7 @@ private void runFollowTest(CheckedBiConsumer nestedDocFunc = EngineTestCase.nestedParsedDocFactory(); @@ -673,8 +668,7 @@ public void testVerifyShardBeforeIndexClosingIsNoOp() throws IOException { public void testMaxSeqNoInCommitUserData() throws Exception { final Settings settings = Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0) - .put("index.version.created", Version.CURRENT).put("index.xpack.ccr.following_index", true) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true).build(); + .put("index.version.created", Version.CURRENT).put("index.xpack.ccr.following_index", true).build(); final IndexMetaData indexMetaData = IndexMetaData.builder(index.getName()).settings(settings).build(); final IndexSettings indexSettings = new IndexSettings(indexMetaData, settings); try (Store store = createStore(shardId, indexSettings, newDirectory())) { diff --git a/x-pack/plugin/ilm/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ilm/CCRIndexLifecycleIT.java b/x-pack/plugin/ilm/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ilm/CCRIndexLifecycleIT.java index 3933a1cd70365..2f4c61a9fe006 100644 --- a/x-pack/plugin/ilm/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ilm/CCRIndexLifecycleIT.java +++ b/x-pack/plugin/ilm/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ilm/CCRIndexLifecycleIT.java @@ -55,7 +55,6 @@ public void testBasicCCRAndILMIntegration() throws Exception { if ("leader".equals(targetCluster)) { putILMPolicy(policyName, "50GB", null, TimeValue.timeValueHours(7*24)); Settings indexSettings = Settings.builder() - .put("index.soft_deletes.enabled", true) .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) .put("index.lifecycle.name", policyName) @@ -114,7 +113,6 @@ public void testCCRUnfollowDuringSnapshot() throws Exception { String indexName = "unfollow-test-index"; if ("leader".equals(targetCluster)) { Settings indexSettings = Settings.builder() - .put("index.soft_deletes.enabled", true) .put("index.number_of_shards", 2) .put("index.number_of_replicas", 0) .build(); @@ -190,7 +188,6 @@ public void testCcrAndIlmWithRollover() throws Exception { putILMPolicy(policyName, null, 1, null); Request templateRequest = new Request("PUT", "_template/my_template"); Settings indexSettings = Settings.builder() - .put("index.soft_deletes.enabled", true) .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) .put("index.lifecycle.name", policyName) @@ -290,7 +287,6 @@ public void testAliasReplicatedOnShrink() throws Exception { if ("leader".equals(targetCluster)) { Settings indexSettings = Settings.builder() - .put("index.soft_deletes.enabled", true) .put("index.number_of_shards", 3) .put("index.number_of_replicas", 0) .put("index.lifecycle.name", policyName) // this policy won't exist on the leader, that's fine @@ -356,7 +352,6 @@ public void testUnfollowInjectedBeforeShrink() throws Exception { if ("leader".equals(targetCluster)) { Settings indexSettings = Settings.builder() - .put("index.soft_deletes.enabled", true) .put("index.number_of_shards", 3) .put("index.number_of_replicas", 0) .put("index.lifecycle.name", policyName) // this policy won't exist on the leader, that's fine @@ -408,7 +403,6 @@ public void testCannotShrinkLeaderIndex() throws Exception { // follower putShrinkOnlyPolicy(client(), policyName); Settings indexSettings = Settings.builder() - .put("index.soft_deletes.enabled", true) .put("index.number_of_shards", 2) .put("index.number_of_replicas", 0) .build(); @@ -481,7 +475,6 @@ public void testILMUnfollowFailsToRemoveRetentionLeases() throws Exception { if ("leader".equals(targetCluster)) { Settings indexSettings = Settings.builder() - .put("index.soft_deletes.enabled", true) .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) .put("index.lifecycle.name", policyName) // this policy won't exist on the leader, that's fine From 2d0e7d99c05800f7c33ba9d7663f77b1d359a90e Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Fri, 17 Jan 2020 23:49:21 -0500 Subject: [PATCH 2/3] stylecheck --- .../src/test/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java | 1 - .../java/org/elasticsearch/xpack/ccr/LocalIndexFollowingIT.java | 2 -- 2 files changed, 3 deletions(-) diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java index 2ea3a1466ff8c..3551288b65342 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java @@ -18,7 +18,6 @@ import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.index.IndexNotFoundException; -import org.elasticsearch.index.IndexSettings; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.xpack.CcrIntegTestCase; import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata; diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/LocalIndexFollowingIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/LocalIndexFollowingIT.java index 782e43cf326ef..1ea95db2df6c5 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/LocalIndexFollowingIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/LocalIndexFollowingIT.java @@ -12,7 +12,6 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.index.IndexSettings; import org.elasticsearch.xpack.CcrSingleNodeTestCase; import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction; import org.elasticsearch.xpack.core.ccr.action.FollowStatsAction; @@ -25,7 +24,6 @@ import java.util.Collections; import java.util.Map; -import static java.util.Collections.singletonMap; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.hamcrest.Matchers.equalTo; From 63955060bea4855b53b80735cdbcb74ea23c7965 Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Sat, 18 Jan 2020 10:32:38 -0500 Subject: [PATCH 3/3] adjust tests --- .../xpack/ccr/action/AutoFollowCoordinatorTests.java | 11 +++++++++-- .../ccr/index/engine/FollowEngineIndexShardTests.java | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinatorTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinatorTests.java index de6786ea3d825..b51839bb7cf2c 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinatorTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinatorTests.java @@ -29,7 +29,9 @@ import org.elasticsearch.common.util.concurrent.ConcurrentCollections; import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexSettings; import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.test.VersionUtils; import org.elasticsearch.xpack.ccr.Ccr; import org.elasticsearch.xpack.ccr.CcrLicenseChecker; import org.elasticsearch.xpack.ccr.CcrSettings; @@ -1467,8 +1469,13 @@ private static ClusterState createRemoteClusterState(String indexName, boolean e private static ClusterState createRemoteClusterState(String indexName, boolean enableSoftDeletes, long metadataVersion) { Settings.Builder indexSettings; - indexSettings = settings(Version.CURRENT) - .put(IndexMetaData.SETTING_INDEX_UUID, UUIDs.randomBase64UUID(random())); + if (enableSoftDeletes == false) { + indexSettings = settings(VersionUtils.randomPreviousCompatibleVersion(random(), Version.V_8_0_0)) + .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), false); + } else { + indexSettings = settings(Version.CURRENT); + } + indexSettings.put(IndexMetaData.SETTING_INDEX_UUID, UUIDs.randomBase64UUID(random())); IndexMetaData indexMetaData = IndexMetaData.builder(indexName) .settings(indexSettings) diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/index/engine/FollowEngineIndexShardTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/index/engine/FollowEngineIndexShardTests.java index fe06c0b0b1e00..74a331064dce8 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/index/engine/FollowEngineIndexShardTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/index/engine/FollowEngineIndexShardTests.java @@ -49,7 +49,8 @@ public class FollowEngineIndexShardTests extends IndexShardTestCase { public void testDoNotFillGaps() throws Exception { - final IndexShard indexShard = newStartedShard(false, Settings.EMPTY, new FollowingEngineFactory()); + Settings settings = Settings.builder().put(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey(), true).build(); + final IndexShard indexShard = newStartedShard(false, settings, new FollowingEngineFactory()); long seqNo = -1; for (int i = 0; i < 8; i++) {