Skip to content

Commit

Permalink
Modify comments
Browse files Browse the repository at this point in the history
Signed-off-by: Xue Zhou <xuezhou@amazon.com>
  • Loading branch information
xuezhou25 committed Jan 11, 2023
1 parent 030619b commit 22adbd3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Change http code for DecommissioningFailedException from 500 to 400 ([#5283](https://github.com/opensearch-project/OpenSearch/pull/5283))
- Pre conditions check before updating weighted routing metadata ([#4955](https://github.com/opensearch-project/OpenSearch/pull/4955))
- Gracefully handle concurrent zone decommission action ([#5542](https://github.com/opensearch-project/OpenSearch/pull/5542))
- Mapping IllegalArgumentException to SettingsException extend OpenSearchException in AbstractScopedSettings class ([#4792](https://github.com/opensearch-project/OpenSearch/pull/4792))

### Deprecated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,27 +175,27 @@ protected Settings nodeSettings(int nodeOrdinal) {
}

public void testUpdateDependentClusterSettings() {
SettingsException iae = expectThrows(
SettingsException e = expectThrows(
SettingsException.class,
() -> client().admin()
.cluster()
.prepareUpdateSettings()
.setPersistentSettings(Settings.builder().put("cluster.acc.test.pw", "asdf"))
.get()
);
assertEquals("missing required setting [cluster.acc.test.user] for setting [cluster.acc.test.pw]", iae.getMessage());
assertEquals("missing required setting [cluster.acc.test.user] for setting [cluster.acc.test.pw]", e.getMessage());

iae = expectThrows(
e = expectThrows(
SettingsException.class,
() -> client().admin()
.cluster()
.prepareUpdateSettings()
.setTransientSettings(Settings.builder().put("cluster.acc.test.pw", "asdf"))
.get()
);
assertEquals("missing required setting [cluster.acc.test.user] for setting [cluster.acc.test.pw]", iae.getMessage());
assertEquals("missing required setting [cluster.acc.test.user] for setting [cluster.acc.test.pw]", e.getMessage());

iae = expectThrows(
e = expectThrows(
SettingsException.class,
() -> client().admin()
.cluster()
Expand All @@ -204,23 +204,23 @@ public void testUpdateDependentClusterSettings() {
.setPersistentSettings(Settings.builder().put("cluster.acc.test.user", "asdf"))
.get()
);
assertEquals("missing required setting [cluster.acc.test.user] for setting [cluster.acc.test.pw]", iae.getMessage());
assertEquals("missing required setting [cluster.acc.test.user] for setting [cluster.acc.test.pw]", e.getMessage());

if (randomBoolean()) {
client().admin()
.cluster()
.prepareUpdateSettings()
.setTransientSettings(Settings.builder().put("cluster.acc.test.pw", "asdf").put("cluster.acc.test.user", "asdf"))
.get();
iae = expectThrows(
e = expectThrows(
SettingsException.class,
() -> client().admin()
.cluster()
.prepareUpdateSettings()
.setTransientSettings(Settings.builder().putNull("cluster.acc.test.user"))
.get()
);
assertEquals("missing required setting [cluster.acc.test.user] for setting [cluster.acc.test.pw]", iae.getMessage());
assertEquals("missing required setting [cluster.acc.test.user] for setting [cluster.acc.test.pw]", e.getMessage());
client().admin()
.cluster()
.prepareUpdateSettings()
Expand All @@ -233,15 +233,15 @@ public void testUpdateDependentClusterSettings() {
.setPersistentSettings(Settings.builder().put("cluster.acc.test.pw", "asdf").put("cluster.acc.test.user", "asdf"))
.get();

iae = expectThrows(
e = expectThrows(
SettingsException.class,
() -> client().admin()
.cluster()
.prepareUpdateSettings()
.setPersistentSettings(Settings.builder().putNull("cluster.acc.test.user"))
.get()
);
assertEquals("missing required setting [cluster.acc.test.user] for setting [cluster.acc.test.pw]", iae.getMessage());
assertEquals("missing required setting [cluster.acc.test.user] for setting [cluster.acc.test.pw]", e.getMessage());

client().admin()
.cluster()
Expand All @@ -253,11 +253,11 @@ public void testUpdateDependentClusterSettings() {
}

public void testUpdateDependentIndexSettings() {
SettingsException iae = expectThrows(
SettingsException e = expectThrows(
SettingsException.class,
() -> prepareCreate("test", Settings.builder().put("index.acc.test.pw", "asdf")).get()
);
assertEquals("missing required setting [index.acc.test.user] for setting [index.acc.test.pw]", iae.getMessage());
assertEquals("missing required setting [index.acc.test.user] for setting [index.acc.test.pw]", e.getMessage());

createIndex("test");
for (int i = 0; i < 2; i++) {
Expand All @@ -266,7 +266,7 @@ public void testUpdateDependentIndexSettings() {
client().admin().indices().prepareClose("test").get();
}

iae = expectThrows(
e = expectThrows(
SettingsException.class,
() -> client().admin()
.indices()
Expand All @@ -275,7 +275,7 @@ public void testUpdateDependentIndexSettings() {
.execute()
.actionGet()
);
assertEquals("missing required setting [index.acc.test.user] for setting [index.acc.test.pw]", iae.getMessage());
assertEquals("missing required setting [index.acc.test.user] for setting [index.acc.test.pw]", e.getMessage());

// user has no dependency
client().admin()
Expand All @@ -294,7 +294,7 @@ public void testUpdateDependentIndexSettings() {
.actionGet();

// now try to remove it and make sure it fails
iae = expectThrows(
e = expectThrows(
SettingsException.class,
() -> client().admin()
.indices()
Expand All @@ -303,7 +303,7 @@ public void testUpdateDependentIndexSettings() {
.execute()
.actionGet()
);
assertEquals("missing required setting [index.acc.test.user] for setting [index.acc.test.pw]", iae.getMessage());
assertEquals("missing required setting [index.acc.test.user] for setting [index.acc.test.pw]", e.getMessage());

// now we are consistent
client().admin()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ public void testDependentSettings() {

AbstractScopedSettings service = new ClusterSettings(Settings.EMPTY, new HashSet<>(Arrays.asList(intSetting, stringSetting)));

SettingsException iae = expectThrows(
SettingsException e = expectThrows(
SettingsException.class,
() -> service.validate(Settings.builder().put("foo.test.bar", 7).build(), true)
);
assertEquals("missing required setting [foo.test.name] for setting [foo.test.bar]", iae.getMessage());
assertEquals("missing required setting [foo.test.name] for setting [foo.test.bar]", e.getMessage());

service.validate(Settings.builder().put("foo.test.name", "test").put("foo.test.bar", 7).build(), true);

Expand Down Expand Up @@ -247,11 +247,11 @@ public void validate(final String key, final Object value, final Object dependen

AbstractScopedSettings service = new ClusterSettings(Settings.EMPTY, new HashSet<>(Arrays.asList(intSetting, stringSetting)));

SettingsException iae = expectThrows(
SettingsException e = expectThrows(
SettingsException.class,
() -> service.validate(Settings.builder().put("foo.test.bar", 7).put("foo.test.name", "invalid").build(), true)
);
assertEquals("[foo.test.bar] is set but [name] is [invalid]", iae.getMessage());
assertEquals("[foo.test.bar] is set but [name] is [invalid]", e.getMessage());

service.validate(Settings.builder().put("foo.test.bar", 7).put("foo.test.name", "valid").build(), true);

Expand Down Expand Up @@ -963,11 +963,11 @@ public void testGetSetting() {

public void testValidateWithSuggestion() {
IndexScopedSettings settings = new IndexScopedSettings(Settings.EMPTY, IndexScopedSettings.BUILT_IN_INDEX_SETTINGS);
SettingsException iae = expectThrows(
SettingsException e = expectThrows(
SettingsException.class,
() -> settings.validate(Settings.builder().put("index.numbe_of_replica", "1").build(), false)
);
assertEquals(iae.getMessage(), "unknown setting [index.numbe_of_replica] did you mean [index.number_of_replicas]?");
assertEquals(e.getMessage(), "unknown setting [index.numbe_of_replica] did you mean [index.number_of_replicas]?");
}

public void testValidate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1072,15 +1072,15 @@ public void testSetSearchThrottled() {
)
).actionGet();

SettingsException iae = expectThrows(
SettingsException se = expectThrows(
SettingsException.class,
() -> client().admin()
.indices()
.prepareUpdateSettings("throttled_threadpool_index")
.setSettings(Settings.builder().put(IndexSettings.INDEX_SEARCH_THROTTLED.getKey(), false))
.get()
);
assertEquals("can not update private setting [index.search.throttled]; this setting is managed by OpenSearch", iae.getMessage());
assertEquals("can not update private setting [index.search.throttled]; this setting is managed by OpenSearch", se.getMessage());
assertFalse(service.getIndicesService().indexServiceSafe(index).getIndexSettings().isSearchThrottled());
SearchRequest searchRequest = new SearchRequest().allowPartialSearchResults(false);
ShardSearchRequest req = new ShardSearchRequest(
Expand Down

0 comments on commit 22adbd3

Please sign in to comment.