forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Backport 2.x] Reject invalid SearchBackpressureMode (opensearch-proj…
…ect#6832) (opensearch-project#7541) (opensearch-project#7571) * Reject invalid SearchBackpressureMode (opensearch-project#6832) (opensearch-project#7541) * Reject invalid SearchBackpressureMode (opensearch-project#6832) ClusterState updates of SearchBackpressureMode are persisted without validation which causes the entire cluster to become unstable or corrupted when a cluster tries to load invalid mode. Signed-off-by: Austin Lee <[email protected]> (cherry picked from commit ba35781) * Change version guard on rest-api-spec test Signed-off-by: Andrew Ross <[email protected]> * Add version guard for happy path test case Signed-off-by: Andrew Ross <[email protected]> --------- Signed-off-by: Andrew Ross <[email protected]> Co-authored-by: Austin Lee <[email protected]>
- Loading branch information
1 parent
1222c17
commit 2d8f25f
Showing
5 changed files
with
81 additions
and
4 deletions.
There are no files selected for viewing
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
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
40 changes: 40 additions & 0 deletions
40
...est/java/org/opensearch/search/backpressure/settings/SearchBackpressureSettingsTests.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,40 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.search.backpressure.settings; | ||
|
||
import org.opensearch.common.settings.ClusterSettings; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.test.OpenSearchTestCase; | ||
|
||
public class SearchBackpressureSettingsTests extends OpenSearchTestCase { | ||
|
||
/** | ||
* Validate proper construction of SearchBackpressureSettings object with a valid mode. | ||
*/ | ||
public void testSearchBackpressureSettings() { | ||
Settings settings = Settings.builder().put("search_backpressure.mode", "monitor_only").build(); | ||
ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); | ||
SearchBackpressureSettings sbs = new SearchBackpressureSettings(settings, cs); | ||
assertEquals(SearchBackpressureMode.MONITOR_ONLY, sbs.getMode()); | ||
assertEquals(settings, sbs.getSettings()); | ||
assertEquals(cs, sbs.getClusterSettings()); | ||
} | ||
|
||
/** | ||
* Validate construction of SearchBackpressureSettings object gets rejected | ||
* on invalid SearchBackpressureMode value. | ||
*/ | ||
public void testSearchBackpressureSettingValidateInvalidMode() { | ||
Settings settings = Settings.builder().put("search_backpressure.mode", "foo").build(); | ||
assertThrows( | ||
IllegalArgumentException.class, | ||
() -> new SearchBackpressureSettings(settings, new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)) | ||
); | ||
} | ||
} |