Skip to content

Commit

Permalink
Applied spotless checks
Browse files Browse the repository at this point in the history
Signed-off-by: Gaurav Chandani <[email protected]>
  • Loading branch information
Gaurav614 committed Feb 20, 2024
1 parent 1cf47e0 commit 987dfa9
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ public void testDeleteIndexWithBlocks() {
}

public void testDeleteIndexOnIndexReadOnlyAllowDeleteSetting() {
assertDeleteIndexOnAllowDeleteSetting(IndexMetadata.SETTING_READ_ONLY_ALLOW_DELETE, IndexMetadata.INDEX_READ_ONLY_ALLOW_DELETE_BLOCK);
assertDeleteIndexOnAllowDeleteSetting(
IndexMetadata.SETTING_READ_ONLY_ALLOW_DELETE,
IndexMetadata.INDEX_READ_ONLY_ALLOW_DELETE_BLOCK
);
}

public void testClusterBlockMessageHasIndexName() {
Expand Down Expand Up @@ -112,10 +115,13 @@ public void testDeleteIndexOnClusterReadOnlyAllowDeleteSetting() {
}

public void testDeleteIndexOnIndexWriteOnlyAllowDeleteSetting() {
assertDeleteIndexOnAllowDeleteSetting(IndexMetadata.SETTING_WRITE_ONLY_ALLOW_DELETE, IndexMetadata.INDEX_WRITE_ONLY_ALLOW_DELETE_BLOCK);
assertDeleteIndexOnAllowDeleteSetting(
IndexMetadata.SETTING_WRITE_ONLY_ALLOW_DELETE,
IndexMetadata.INDEX_WRITE_ONLY_ALLOW_DELETE_BLOCK
);
}

private void assertDeleteIndexOnAllowDeleteSetting(String settingName, ClusterBlock blockToAssert){
private void assertDeleteIndexOnAllowDeleteSetting(String settingName, ClusterBlock blockToAssert) {
createIndex("test");
ensureGreen("test");
client().prepareIndex().setIndex("test").setId("1").setSource("foo", "bar").get();
Expand All @@ -124,10 +130,7 @@ private void assertDeleteIndexOnAllowDeleteSetting(String settingName, ClusterB
Settings settings = Settings.builder().put(settingName, true).build();
assertAcked(client().admin().indices().prepareUpdateSettings("test").setSettings(settings).get());
assertSearchHits(client().prepareSearch().get(), "1");
assertBlocked(
client().prepareIndex().setIndex("test").setId("2").setSource("foo", "bar"),
blockToAssert
);
assertBlocked(client().prepareIndex().setIndex("test").setId("2").setSource("foo", "bar"), blockToAssert);
assertBlocked(
client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder().put("index.number_of_replicas", 2)),
blockToAssert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ public void testForceMergeWithBlocks() {
}

// Request is blocked
for (String blockSetting : Arrays.asList(SETTING_READ_ONLY, SETTING_BLOCKS_METADATA, SETTING_READ_ONLY_ALLOW_DELETE, SETTING_WRITE_ONLY_ALLOW_DELETE)) {
for (String blockSetting : Arrays.asList(
SETTING_READ_ONLY,
SETTING_BLOCKS_METADATA,
SETTING_READ_ONLY_ALLOW_DELETE,
SETTING_WRITE_ONLY_ALLOW_DELETE
)) {
try {
enableIndexBlock("test", blockSetting);
assertBlocked(client().admin().indices().prepareForceMerge("test"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,13 @@ public void testEmptyMixedFeatures() {
}

public void testGetIndexWithBlocks() {
for (String block : Arrays.asList(SETTING_BLOCKS_READ, SETTING_BLOCKS_WRITE, SETTING_READ_ONLY, SETTING_READ_ONLY_ALLOW_DELETE, SETTING_WRITE_ONLY_ALLOW_DELETE)) {
for (String block : Arrays.asList(
SETTING_BLOCKS_READ,
SETTING_BLOCKS_WRITE,
SETTING_READ_ONLY,
SETTING_READ_ONLY_ALLOW_DELETE,
SETTING_WRITE_ONLY_ALLOW_DELETE
)) {
try {
enableIndexBlock("idx", block);
GetIndexResponse response = client().admin()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,12 @@ public void testAddBlocksWhileExistingBlocks() {
}
}

for (APIBlock block : Arrays.asList(APIBlock.READ_ONLY, APIBlock.METADATA, APIBlock.READ_ONLY_ALLOW_DELETE, APIBlock.WRITE_ONLY_ALLOW_DELETE)) {
for (APIBlock block : Arrays.asList(
APIBlock.READ_ONLY,
APIBlock.METADATA,
APIBlock.READ_ONLY_ALLOW_DELETE,
APIBlock.WRITE_ONLY_ALLOW_DELETE
)) {
boolean success = false;
try {
enableIndexBlock("test", block.settingName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ public void testGetSettingsWithBlocks() throws Exception {
)
);

for (String block : Arrays.asList(SETTING_BLOCKS_READ, SETTING_BLOCKS_WRITE, SETTING_READ_ONLY, SETTING_READ_ONLY_ALLOW_DELETE, SETTING_WRITE_ONLY_ALLOW_DELETE)) {
for (String block : Arrays.asList(
SETTING_BLOCKS_READ,
SETTING_BLOCKS_WRITE,
SETTING_READ_ONLY,
SETTING_READ_ONLY_ALLOW_DELETE,
SETTING_WRITE_ONLY_ALLOW_DELETE
)) {
try {
enableIndexBlock("test", block);
GetSettingsResponse response = client().admin().indices().prepareGetSettings("test").get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,12 @@ public void testOpenCloseIndexWithBlocks() {
assertIndexIsClosed("test");

// Opening an index is blocked
for (String blockSetting : Arrays.asList(SETTING_READ_ONLY, SETTING_READ_ONLY_ALLOW_DELETE, SETTING_BLOCKS_METADATA, SETTING_WRITE_ONLY_ALLOW_DELETE)) {
for (String blockSetting : Arrays.asList(
SETTING_READ_ONLY,
SETTING_READ_ONLY_ALLOW_DELETE,
SETTING_BLOCKS_METADATA,
SETTING_WRITE_ONLY_ALLOW_DELETE
)) {
try {
enableIndexBlock("test", blockSetting);
assertBlocked(client().admin().indices().prepareOpen("test"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ public Builder addBlocks(IndexMetadata indexMetadata) {
if (IndexModule.Type.REMOTE_SNAPSHOT.match(indexMetadata.getSettings().get(IndexModule.INDEX_STORE_TYPE_SETTING.getKey()))) {
addIndexBlock(indexName, IndexMetadata.REMOTE_READ_ONLY_ALLOW_DELETE);
}
if(IndexMetadata.INDEX_BLOCKS_WRITE_ONLY_ALLOW_DELETE_SETTING.get(indexMetadata.getSettings())) {
if (IndexMetadata.INDEX_BLOCKS_WRITE_ONLY_ALLOW_DELETE_SETTING.get(indexMetadata.getSettings())) {
addIndexBlock(indexName, IndexMetadata.INDEX_WRITE_ONLY_ALLOW_DELETE_BLOCK);
}
return this;
Expand Down

0 comments on commit 987dfa9

Please sign in to comment.