Skip to content

Commit

Permalink
Clean soft-deletes setting in ccr tests (elastic#51113)
Browse files Browse the repository at this point in the history
We no longer need to explicitly enable soft-deletes in CCR tests.

Relates elastic#50775
  • Loading branch information
dnhatn authored and SivagurunathanV committed Jan 21, 2020
1 parent 46045dc commit 8ca83e0
Show file tree
Hide file tree
Showing 29 changed files with 88 additions and 265 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -392,7 +388,6 @@ public void testForgetFollower() throws InterruptedException, IOException {
final Map<String, String> 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));
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,25 +31,17 @@ 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);
index(leaderClient, "logs-20190101", id, "field", i, "filtered_field", "true");
}
}
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);
Expand Down Expand Up @@ -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++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> additionalIndexSettings) throws IOException {
final String settings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -60,7 +59,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();
Expand Down Expand Up @@ -94,7 +92,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();
Expand Down Expand Up @@ -133,7 +130,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();
Expand Down Expand Up @@ -215,7 +211,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();
Expand Down Expand Up @@ -318,7 +313,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();
Expand Down Expand Up @@ -360,7 +354,6 @@ public void testConflictingPatterns() 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();
Expand Down Expand Up @@ -430,7 +423,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();
Expand Down
Loading

0 comments on commit 8ca83e0

Please sign in to comment.