-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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 (#10528) (#11166) * making leader check timeout dynamic * making follower check timeout dynamic * fixing existing unit tests * fixing checkstyle violations * adding tests for leader/follower check timeout * setting maximum and minimum timeout value for leader/follower checker * adding tests for checking boundary cases * Fixing checkstyle violations * changed the log file and added other suggested changes * fixing checkstyle violations * Addressing review comments * addressing proposed changes * Applying checkstyle fixes * Fixing flakiness for existing tests * Applying checkstyle fixes * Fixing the timeout value limits for randomSettings --------- (cherry picked from commit 0452d14) Signed-off-by: Niyati Aggarwal <niyatiagg4641@gmail.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
c2b5587
commit 879b9af
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.