forked from opensearch-project/OpenSearch
-
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.
Adding support for dynamically updating Leader/follower checker timeo…
…uts (opensearch-project#10528) * making leader check timeout dynamic Signed-off-by: Niyati Aggarwal <[email protected]> * making follower check timeout dynamic Signed-off-by: Niyati Aggarwal <[email protected]> * fixing existing unit tests Signed-off-by: Niyati Aggarwal <[email protected]> * fixing checkstyle violations Signed-off-by: Niyati Aggarwal <[email protected]> * adding tests for leader/follower check timeout Signed-off-by: Niyati Aggarwal <[email protected]> * setting maximum and minimum timeout value for leader/follower checker Signed-off-by: Niyati Aggarwal <[email protected]> * adding tests for checking boundary cases Signed-off-by: Niyati Aggarwal <[email protected]> * Fixing checkstyle violations Signed-off-by: Niyati Aggarwal <[email protected]> * changed the log file and added other suggested changes Signed-off-by: Niyati Aggarwal <[email protected]> * fixing checkstyle violations Signed-off-by: Niyati Aggarwal <[email protected]> * Addressing review comments Signed-off-by: Niyati Aggarwal <[email protected]> * addressing proposed changes Signed-off-by: Niyati Aggarwal <[email protected]> * Applying checkstyle fixes Signed-off-by: Niyati Aggarwal <[email protected]> * Fixing flakiness for existing tests Signed-off-by: Niyati Aggarwal <[email protected]> * Applying checkstyle fixes Signed-off-by: Niyati Aggarwal <[email protected]> * Fixing the timeout value limits for randomSettings Signed-off-by: Niyati Aggarwal <[email protected]> --------- Signed-off-by: Niyati Aggarwal <[email protected]>
- Loading branch information
Showing
8 changed files
with
164 additions
and
23 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
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
113 changes: 113 additions & 0 deletions
113
...r/src/test/java/org/opensearch/cluster/coordination/CoordinationCheckerSettingsTests.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,113 @@ | ||
/* | ||
* 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.cluster.coordination; | ||
|
||
import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; | ||
import org.opensearch.common.settings.Setting; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.common.unit.TimeValue; | ||
import org.opensearch.test.OpenSearchSingleNodeTestCase; | ||
|
||
import static org.opensearch.cluster.coordination.FollowersChecker.FOLLOWER_CHECK_TIMEOUT_SETTING; | ||
import static org.opensearch.cluster.coordination.LeaderChecker.LEADER_CHECK_TIMEOUT_SETTING; | ||
import static org.opensearch.common.unit.TimeValue.timeValueSeconds; | ||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked; | ||
|
||
public class CoordinationCheckerSettingsTests extends OpenSearchSingleNodeTestCase { | ||
public void testFollowerCheckTimeoutValueUpdate() { | ||
Setting<TimeValue> setting1 = FOLLOWER_CHECK_TIMEOUT_SETTING; | ||
Settings timeSettings1 = Settings.builder().put(setting1.getKey(), "60s").build(); | ||
try { | ||
ClusterUpdateSettingsResponse response = client().admin() | ||
.cluster() | ||
.prepareUpdateSettings() | ||
.setPersistentSettings(timeSettings1) | ||
.execute() | ||
.actionGet(); | ||
|
||
assertAcked(response); | ||
assertEquals(timeValueSeconds(60), setting1.get(response.getPersistentSettings())); | ||
} finally { | ||
// cleanup | ||
timeSettings1 = Settings.builder().putNull(setting1.getKey()).build(); | ||
client().admin().cluster().prepareUpdateSettings().setPersistentSettings(timeSettings1).execute().actionGet(); | ||
} | ||
} | ||
|
||
public void testFollowerCheckTimeoutMaxValue() { | ||
Setting<TimeValue> setting1 = FOLLOWER_CHECK_TIMEOUT_SETTING; | ||
Settings timeSettings1 = Settings.builder().put(setting1.getKey(), "61s").build(); | ||
|
||
assertThrows( | ||
"failed to parse value [61s] for setting [" + setting1.getKey() + "], must be <= [60000ms]", | ||
IllegalArgumentException.class, | ||
() -> { | ||
client().admin().cluster().prepareUpdateSettings().setPersistentSettings(timeSettings1).execute().actionGet(); | ||
} | ||
); | ||
} | ||
|
||
public void testFollowerCheckTimeoutMinValue() { | ||
Setting<TimeValue> setting1 = FOLLOWER_CHECK_TIMEOUT_SETTING; | ||
Settings timeSettings1 = Settings.builder().put(setting1.getKey(), "0s").build(); | ||
|
||
assertThrows( | ||
"failed to parse value [0s] for setting [" + setting1.getKey() + "], must be >= [1ms]", | ||
IllegalArgumentException.class, | ||
() -> { | ||
client().admin().cluster().prepareUpdateSettings().setPersistentSettings(timeSettings1).execute().actionGet(); | ||
} | ||
); | ||
} | ||
|
||
public void testLeaderCheckTimeoutValueUpdate() { | ||
Setting<TimeValue> setting1 = LEADER_CHECK_TIMEOUT_SETTING; | ||
Settings timeSettings1 = Settings.builder().put(setting1.getKey(), "60s").build(); | ||
try { | ||
ClusterUpdateSettingsResponse response = client().admin() | ||
.cluster() | ||
.prepareUpdateSettings() | ||
.setPersistentSettings(timeSettings1) | ||
.execute() | ||
.actionGet(); | ||
assertAcked(response); | ||
assertEquals(timeValueSeconds(60), setting1.get(response.getPersistentSettings())); | ||
} finally { | ||
// cleanup | ||
timeSettings1 = Settings.builder().putNull(setting1.getKey()).build(); | ||
client().admin().cluster().prepareUpdateSettings().setPersistentSettings(timeSettings1).execute().actionGet(); | ||
} | ||
} | ||
|
||
public void testLeaderCheckTimeoutMaxValue() { | ||
Setting<TimeValue> setting1 = LEADER_CHECK_TIMEOUT_SETTING; | ||
Settings timeSettings1 = Settings.builder().put(setting1.getKey(), "61s").build(); | ||
|
||
assertThrows( | ||
"failed to parse value [61s] for setting [" + setting1.getKey() + "], must be <= [60000ms]", | ||
IllegalArgumentException.class, | ||
() -> { | ||
client().admin().cluster().prepareUpdateSettings().setPersistentSettings(timeSettings1).execute().actionGet(); | ||
} | ||
); | ||
} | ||
|
||
public void testLeaderCheckTimeoutMinValue() { | ||
Setting<TimeValue> setting1 = LEADER_CHECK_TIMEOUT_SETTING; | ||
Settings timeSettings1 = Settings.builder().put(setting1.getKey(), "0s").build(); | ||
|
||
assertThrows( | ||
"failed to parse value [0s] for setting [" + setting1.getKey() + "], must be >= [1ms]", | ||
IllegalArgumentException.class, | ||
() -> { | ||
client().admin().cluster().prepareUpdateSettings().setPersistentSettings(timeSettings1).execute().actionGet(); | ||
} | ||
); | ||
} | ||
} |
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
Oops, something went wrong.