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.
Signed-off-by: Rahul Karajgikar <karajgik@amazon.com>
- Loading branch information
Rahul Karajgikar
committed
Oct 17, 2024
1 parent
b332424
commit c96d677
Showing
3 changed files
with
134 additions
and
1 deletion.
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
66 changes: 66 additions & 0 deletions
66
server/src/test/java/org/opensearch/gateway/ShardsBatchGatewayAllocatorTests.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,66 @@ | ||
/* | ||
* 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.gateway; | ||
|
||
import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; | ||
import org.opensearch.common.settings.Setting; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.test.OpenSearchSingleNodeTestCase; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.opensearch.gateway.ShardsBatchGatewayAllocator.GATEWAY_ALLOCATOR_BATCH_SIZE; | ||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked; | ||
|
||
public class ShardsBatchGatewayAllocatorTests extends OpenSearchSingleNodeTestCase { | ||
public void testBatchSizeValueUpdate() { | ||
Setting<Long> setting1 = GATEWAY_ALLOCATOR_BATCH_SIZE; | ||
Settings batchSizeSetting = Settings.builder().put(setting1.getKey(), "3000").build(); | ||
try { | ||
ClusterUpdateSettingsResponse response = client().admin() | ||
.cluster() | ||
.prepareUpdateSettings() | ||
.setPersistentSettings(batchSizeSetting) | ||
.execute() | ||
.actionGet(); | ||
|
||
assertAcked(response); | ||
assertThat(setting1.get(response.getPersistentSettings()), equalTo(3000L)); | ||
} finally { | ||
// cleanup | ||
batchSizeSetting = Settings.builder().putNull(setting1.getKey()).build(); | ||
client().admin().cluster().prepareUpdateSettings().setPersistentSettings(batchSizeSetting).execute().actionGet(); | ||
} | ||
} | ||
|
||
public void testBatchSizeMaxValue() { | ||
Setting<Long> setting1 = GATEWAY_ALLOCATOR_BATCH_SIZE; | ||
Settings batchSizeSetting = Settings.builder().put(setting1.getKey(), "11000").build(); | ||
|
||
assertThrows( | ||
"failed to parse value [11000] for setting [" + setting1.getKey() + "], must be <= [10000]", | ||
IllegalArgumentException.class, | ||
() -> { | ||
client().admin().cluster().prepareUpdateSettings().setPersistentSettings(batchSizeSetting).execute().actionGet(); | ||
} | ||
); | ||
} | ||
|
||
public void testBatchSizeMinValue() { | ||
Setting<Long> setting1 = GATEWAY_ALLOCATOR_BATCH_SIZE; | ||
Settings batchSizeSetting = Settings.builder().put(setting1.getKey(), "0").build(); | ||
|
||
assertThrows( | ||
"failed to parse value [0] for setting [" + setting1.getKey() + "], must be >= [1]", | ||
IllegalArgumentException.class, | ||
() -> { | ||
client().admin().cluster().prepareUpdateSettings().setPersistentSettings(batchSizeSetting).execute().actionGet(); | ||
} | ||
); | ||
} | ||
} |