-
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.
Signed-off-by: Ruirui Zhang <[email protected]>
- Loading branch information
Showing
3 changed files
with
86 additions
and
125 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
server/src/internalClusterTest/java/org/opensearch/wlm/WorkloadManagementIT.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,85 @@ | ||
/* | ||
* 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.wlm; | ||
|
||
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.opensearch.client.Request; | ||
import org.opensearch.client.RequestOptions; | ||
import org.opensearch.client.Response; | ||
import org.opensearch.client.ResponseException; | ||
import org.opensearch.cluster.metadata.QueryGroup; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.plugins.Plugin; | ||
import org.opensearch.test.OpenSearchIntegTestCase; | ||
import org.opensearch.test.ParameterizedStaticSettingsOpenSearchIntegTestCase; | ||
|
||
import java.io.IOException; | ||
import java.util.*; | ||
|
||
import static org.opensearch.search.SearchService.CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING; | ||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked; | ||
import static org.opensearch.wlm.QueryGroupTask.QUERY_GROUP_ID_HEADER; | ||
|
||
public class WorkloadManagementIT extends ParameterizedStaticSettingsOpenSearchIntegTestCase { | ||
|
||
private static String queryGroupName = "test"; | ||
|
||
public WorkloadManagementIT(Settings nodeSettings) { | ||
super(nodeSettings); | ||
} | ||
@ParametersFactory | ||
public static Collection<Object[]> parameters() { | ||
return Arrays.asList( | ||
new Object[] { Settings.builder().put(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING.getKey(), false).build() }, | ||
new Object[] { Settings.builder().put(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING.getKey(), true).build() } | ||
); | ||
} | ||
|
||
@Before | ||
public final void setupNodeSettings() { | ||
Settings request = Settings.builder() | ||
.put(WorkloadManagementSettings.NODE_LEVEL_MEMORY_REJECTION_THRESHOLD.getKey(), 0.8) | ||
.put(WorkloadManagementSettings.NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD.getKey(), 0.9) | ||
.put(WorkloadManagementSettings.NODE_LEVEL_CPU_REJECTION_THRESHOLD.getKey(), 0.8) | ||
.put(WorkloadManagementSettings.NODE_LEVEL_CPU_CANCELLATION_THRESHOLD.getKey(), 0.9) | ||
.build(); | ||
assertAcked(client().admin().cluster().prepareUpdateSettings().setPersistentSettings(request).get()); | ||
} | ||
|
||
@After | ||
public final void cleanupNodeSettings() { | ||
assertAcked( | ||
client().admin() | ||
.cluster() | ||
.prepareUpdateSettings() | ||
.setPersistentSettings(Settings.builder().putNull("*")) | ||
.setTransientSettings(Settings.builder().putNull("*")) | ||
); | ||
} | ||
|
||
public void testMemoryThresholdTaskRejection() throws IOException, IOException { | ||
QueryGroup queryGroup = new QueryGroup(queryGroupName, new MutableQueryGroupFragment(MutableQueryGroupFragment.ResiliencyMode.ENFORCED, Map.of(ResourceType.MEMORY, 0.3))); | ||
|
||
QueryGroup queryGroup2 = new QueryGroup(queryGroupName + "2", new MutableQueryGroupFragment(MutableQueryGroupFragment.ResiliencyMode.ENFORCED, Map.of(ResourceType.MEMORY, 0.3))); | ||
String queryGroupId = queryGroup.get_id(); | ||
String queryGroupId2 = queryGroup2.get_id(); | ||
|
||
client().admin().cluster().prepareState().get().getState().metadata().queryGroups().put(queryGroupId, queryGroup); | ||
client().admin().cluster().prepareState().get().getState().metadata().queryGroups().put(queryGroupId2, queryGroup2); | ||
|
||
Request request = new Request("GET", "/"); | ||
RequestOptions.Builder options = request.getOptions().toBuilder(); | ||
options.addHeader(QUERY_GROUP_ID_HEADER, queryGroupId); | ||
request.setOptions(options); | ||
Response response = getRestClient().performRequest(request); | ||
|
||
} | ||
} |
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
124 changes: 0 additions & 124 deletions
124
server/src/test/java/org/opensearch/wlm/cancellation/WorkloadManagementIT.java
This file was deleted.
Oops, something went wrong.