forked from opensearch-project/ml-commons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change the index update settings to make it only contain dynamic sett…
…ings (opensearch-project#2156)
- Loading branch information
Showing
5 changed files
with
53 additions
and
6 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
common/src/main/java/org/opensearch/ml/common/utils/IndexUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.ml.common.utils; | ||
|
||
import lombok.extern.log4j.Log4j2; | ||
import java.util.Map; | ||
|
||
@Log4j2 | ||
public class IndexUtils { | ||
|
||
// This setting is for index creation. | ||
public static final Map<String, Object> INDEX_SETTINGS = Map.of("index.number_of_shards", "1", "index.auto_expand_replicas", "0-1"); | ||
|
||
// This setting is for index update only, so only dynamic settings should be contained! | ||
public static final Map<String, Object> UPDATED_INDEX_SETTINGS = Map.of("index.auto_expand_replicas", "0-1"); | ||
} |
29 changes: 29 additions & 0 deletions
29
common/src/test/java/org/opensearch/ml/common/utils/IndexUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.ml.common.utils; | ||
|
||
import org.junit.Test; | ||
import java.util.Map; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
public class IndexUtilsTest { | ||
|
||
@Test | ||
public void testIndexSettingsContainsExpectedValues() { | ||
Map<String, Object> indexSettings = IndexUtils.INDEX_SETTINGS; | ||
assertEquals("index.number_of_shards should be 1", indexSettings.get("index.number_of_shards"), "1"); | ||
assertEquals("index.auto_expand_replicas should be 0-1", indexSettings.get("index.auto_expand_replicas"), "0-1"); | ||
assertEquals("INDEX_SETTINGS should contain exactly 2 settings", 2, indexSettings.size()); | ||
} | ||
|
||
@Test | ||
public void testUpdatedIndexSettingsContainsExpectedValues() { | ||
Map<String, Object> updatedIndexSettings = IndexUtils.UPDATED_INDEX_SETTINGS; | ||
assertEquals("index.auto_expand_replicas should be 0-1", updatedIndexSettings.get("index.auto_expand_replicas"), "0-1"); | ||
assertEquals("INDEX_SETTINGS should contain exactly 1 settings", 1, updatedIndexSettings.size()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters