Skip to content

Commit

Permalink
Fix spotless failures
Browse files Browse the repository at this point in the history
Signed-off-by: Suraj Singh <surajrider@gmail.com>
  • Loading branch information
dreamer-89 committed Sep 16, 2022
1 parent 3f473d5 commit 6fda602
Showing 1 changed file with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.util.FeatureFlags;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.index.query.QueryBuilders;
import org.opensearch.indices.replication.common.ReplicationType;
import org.opensearch.rest.RestStatus;
Expand Down Expand Up @@ -49,15 +48,11 @@ public static void assumeFeatureFlag() {
}

public Settings segRepEnableIndexSettings() {
return getShardSettings()
.put(IndexMetadata.SETTING_REPLICATION_TYPE, ReplicationType.SEGMENT)
.build();
return getShardSettings().put(IndexMetadata.SETTING_REPLICATION_TYPE, ReplicationType.SEGMENT).build();
}

public Settings docRepEnableIndexSettings() {
return getShardSettings()
.put(IndexMetadata.SETTING_REPLICATION_TYPE, ReplicationType.DOCUMENT)
.build();
return getShardSettings().put(IndexMetadata.SETTING_REPLICATION_TYPE, ReplicationType.DOCUMENT).build();
}

public Settings.Builder getShardSettings() {
Expand All @@ -73,15 +68,16 @@ protected boolean addMockInternalEngine() {
}

public void ingestData(int docCount, String indexName) throws Exception {
try(
try (
BackgroundIndexer indexer = new BackgroundIndexer(
INDEX_NAME,
"_doc",
client(),
-1,
RandomizedTest.scaledRandomIntBetween(2, 5),
false,
random())
random()
)
) {
indexer.start(docCount);
waitForDocs(docCount, indexer);
Expand Down Expand Up @@ -147,7 +143,10 @@ public void testRestoreOnSegRep() throws Exception {
assertThat(restoreSnapshotResponse.status(), equalTo(RestStatus.ACCEPTED));
logger.info("Ensure cluster is green");
ensureGreen(RESTORED_INDEX_NAME);
GetSettingsResponse settingsResponse = client().admin().indices().getSettings(new GetSettingsRequest().indices(RESTORED_INDEX_NAME)).get();
GetSettingsResponse settingsResponse = client().admin()
.indices()
.getSettings(new GetSettingsRequest().indices(RESTORED_INDEX_NAME))
.get();
assertEquals(settingsResponse.getSetting(RESTORED_INDEX_NAME, "index.replication.type"), "SEGMENT");
SearchResponse resp = client().prepareSearch(RESTORED_INDEX_NAME).setQuery(QueryBuilders.matchAllQuery()).get();
assertHitCount(resp, DOC_COUNT);
Expand All @@ -169,7 +168,10 @@ public void testRestoreOnSegRepDuringIngestion() throws Exception {
logger.info("Ensure cluster is green");
ingestData(5000, RESTORED_INDEX_NAME);
ensureGreen(RESTORED_INDEX_NAME);
GetSettingsResponse settingsResponse = client().admin().indices().getSettings(new GetSettingsRequest().indices(RESTORED_INDEX_NAME)).get();
GetSettingsResponse settingsResponse = client().admin()
.indices()
.getSettings(new GetSettingsRequest().indices(RESTORED_INDEX_NAME))
.get();
assertEquals(settingsResponse.getSetting(RESTORED_INDEX_NAME, "index.replication.type"), "SEGMENT");
SearchResponse resp = client().prepareSearch(RESTORED_INDEX_NAME).setQuery(QueryBuilders.matchAllQuery()).get();
assertHitCount(resp, DOC_COUNT);
Expand All @@ -189,7 +191,10 @@ public void testSnapshotOnDocRep_RestoreOnSegRep() throws Exception {
assertThat(restoreSnapshotResponse.status(), equalTo(RestStatus.ACCEPTED));
logger.info("Ensure cluster is green");
ensureGreen(RESTORED_INDEX_NAME);
GetSettingsResponse settingsResponse = client().admin().indices().getSettings(new GetSettingsRequest().indices(RESTORED_INDEX_NAME)).get();
GetSettingsResponse settingsResponse = client().admin()
.indices()
.getSettings(new GetSettingsRequest().indices(RESTORED_INDEX_NAME))
.get();
assertEquals(settingsResponse.getSetting(RESTORED_INDEX_NAME, "index.replication.type"), "SEGMENT");

SearchResponse resp = client().prepareSearch(RESTORED_INDEX_NAME).setQuery(QueryBuilders.matchAllQuery()).get();
Expand All @@ -210,7 +215,10 @@ public void testSnapshotOnSegRep_RestoreOnDocRep() throws Exception {
assertThat(restoreSnapshotResponse.status(), equalTo(RestStatus.ACCEPTED));
logger.info("Wait for green index health");
ensureGreen(RESTORED_INDEX_NAME);
GetSettingsResponse settingsResponse = client().admin().indices().getSettings(new GetSettingsRequest().indices(RESTORED_INDEX_NAME)).get();
GetSettingsResponse settingsResponse = client().admin()
.indices()
.getSettings(new GetSettingsRequest().indices(RESTORED_INDEX_NAME))
.get();
assertEquals(settingsResponse.getSetting(RESTORED_INDEX_NAME, "index.replication.type"), "DOCUMENT");
SearchResponse resp = client().prepareSearch(RESTORED_INDEX_NAME).setQuery(QueryBuilders.matchAllQuery()).get();
assertHitCount(resp, DOC_COUNT);
Expand All @@ -230,7 +238,10 @@ public void testSnapshotOnDocRep_RestoreOnDocRep() throws Exception {
assertThat(restoreSnapshotResponse.status(), equalTo(RestStatus.ACCEPTED));
logger.info("Ensure cluster is green");
ensureGreen(RESTORED_INDEX_NAME);
GetSettingsResponse settingsResponse = client().admin().indices().getSettings(new GetSettingsRequest().indices(RESTORED_INDEX_NAME)).get();
GetSettingsResponse settingsResponse = client().admin()
.indices()
.getSettings(new GetSettingsRequest().indices(RESTORED_INDEX_NAME))
.get();
assertEquals(settingsResponse.getSetting(RESTORED_INDEX_NAME, "index.replication.type"), "DOCUMENT");

SearchResponse resp = client().prepareSearch(RESTORED_INDEX_NAME).setQuery(QueryBuilders.matchAllQuery()).get();
Expand Down

0 comments on commit 6fda602

Please sign in to comment.