Skip to content

Commit

Permalink
Fixed AdmissionControlSingleNodeTests flaky tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ajay Kumar Movva <movvaam@amazon.com>
  • Loading branch information
Ajay Kumar Movva committed Mar 16, 2024
1 parent 53a36f4 commit d4ba448
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
import java.util.Map;

import static org.opensearch.ratelimitting.admissioncontrol.AdmissionControlSettings.ADMISSION_CONTROL_TRANSPORT_LAYER_MODE;
import static org.opensearch.ratelimitting.admissioncontrol.settings.CpuBasedAdmissionControllerSettings.CPU_BASED_ADMISSION_CONTROLLER_TRANSPORT_LAYER_MODE;
import static org.opensearch.ratelimitting.admissioncontrol.settings.CpuBasedAdmissionControllerSettings.INDEXING_CPU_USAGE_LIMIT;
import static org.opensearch.ratelimitting.admissioncontrol.settings.CpuBasedAdmissionControllerSettings.SEARCH_CPU_USAGE_LIMIT;
import static org.opensearch.ratelimitting.admissioncontrol.settings.IoBasedAdmissionControllerSettings.INDEXING_IO_USAGE_LIMIT;
import static org.opensearch.ratelimitting.admissioncontrol.settings.IoBasedAdmissionControllerSettings.IO_BASED_ADMISSION_CONTROLLER_TRANSPORT_LAYER_MODE;
import static org.opensearch.ratelimitting.admissioncontrol.settings.IoBasedAdmissionControllerSettings.SEARCH_IO_USAGE_LIMIT;
import static org.opensearch.ratelimitting.admissioncontrol.settings.IoBasedAdmissionControllerSettings.INDEXING_IO_USAGE_LIMIT;
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
import static org.hamcrest.Matchers.is;

Expand Down Expand Up @@ -72,7 +74,7 @@ protected Settings nodeSettings() {
.put(ResourceTrackerSettings.GLOBAL_CPU_USAGE_AC_WINDOW_DURATION_SETTING.getKey(), TimeValue.timeValueMillis(500))
.put(ResourceTrackerSettings.GLOBAL_JVM_USAGE_AC_WINDOW_DURATION_SETTING.getKey(), TimeValue.timeValueMillis(500))
.put(ResourceTrackerSettings.GLOBAL_IO_USAGE_AC_WINDOW_DURATION_SETTING.getKey(), TimeValue.timeValueMillis(5000))
.put(ADMISSION_CONTROL_TRANSPORT_LAYER_MODE.getKey(), AdmissionControlMode.ENFORCED)
.put(CPU_BASED_ADMISSION_CONTROLLER_TRANSPORT_LAYER_MODE.getKey(), AdmissionControlMode.ENFORCED.getMode())
.put(SEARCH_CPU_USAGE_LIMIT.getKey(), 0)
.put(INDEXING_CPU_USAGE_LIMIT.getKey(), 0)
.build();
Expand Down Expand Up @@ -143,8 +145,8 @@ public void testAdmissionControlRejectionEnforcedMode() throws Exception {
.put(super.nodeSettings())
.put(SEARCH_IO_USAGE_LIMIT.getKey(), 0)
.put(INDEXING_IO_USAGE_LIMIT.getKey(), 0)
.put(SEARCH_CPU_USAGE_LIMIT.getKey(), 101)
.put(INDEXING_CPU_USAGE_LIMIT.getKey(), 101)
.put(CPU_BASED_ADMISSION_CONTROLLER_TRANSPORT_LAYER_MODE.getKey(), AdmissionControlMode.DISABLED.getMode())
.put(IO_BASED_ADMISSION_CONTROLLER_TRANSPORT_LAYER_MODE.getKey(), AdmissionControlMode.ENFORCED.getMode())
);
assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet());

Expand Down Expand Up @@ -211,7 +213,7 @@ public void testAdmissionControlRejectionMonitorOnlyMode() throws Exception {
updateSettingsRequest.transientSettings(
Settings.builder()
.put(super.nodeSettings())
.put(ADMISSION_CONTROL_TRANSPORT_LAYER_MODE.getKey(), AdmissionControlMode.MONITOR.getMode())
.put(CPU_BASED_ADMISSION_CONTROLLER_TRANSPORT_LAYER_MODE.getKey(), AdmissionControlMode.MONITOR.getMode())
);
assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet());

Expand Down Expand Up @@ -252,6 +254,8 @@ public void testAdmissionControlRejectionMonitorOnlyMode() throws Exception {
.put(INDEXING_IO_USAGE_LIMIT.getKey(), 0)
.put(SEARCH_CPU_USAGE_LIMIT.getKey(), 101)
.put(INDEXING_CPU_USAGE_LIMIT.getKey(), 101)
.put(CPU_BASED_ADMISSION_CONTROLLER_TRANSPORT_LAYER_MODE.getKey(), AdmissionControlMode.DISABLED.getMode())
.put(IO_BASED_ADMISSION_CONTROLLER_TRANSPORT_LAYER_MODE.getKey(), AdmissionControlMode.MONITOR.getMode())
);
assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet());
bulk = client().prepareBulk();
Expand Down Expand Up @@ -307,7 +311,7 @@ public void testAdmissionControlRejectionDisabledMode() throws Exception {

ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest();
updateSettingsRequest.transientSettings(
Settings.builder().put(super.nodeSettings()).put(ADMISSION_CONTROL_TRANSPORT_LAYER_MODE.getKey(), AdmissionControlMode.DISABLED)
Settings.builder().put(super.nodeSettings()).put(CPU_BASED_ADMISSION_CONTROLLER_TRANSPORT_LAYER_MODE.getKey(), AdmissionControlMode.DISABLED.getMode())
);
assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet());

Expand All @@ -334,10 +338,7 @@ public void testAdmissionControlRejectionDisabledMode() throws Exception {
updateSettingsRequest.transientSettings(
Settings.builder()
.put(super.nodeSettings())
.put(SEARCH_IO_USAGE_LIMIT.getKey(), 0)
.put(INDEXING_IO_USAGE_LIMIT.getKey(), 0)
.put(SEARCH_CPU_USAGE_LIMIT.getKey(), 101)
.put(INDEXING_CPU_USAGE_LIMIT.getKey(), 101)
.put(IO_BASED_ADMISSION_CONTROLLER_TRANSPORT_LAYER_MODE.getKey(), AdmissionControlMode.DISABLED)
);
assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet());
bulk = client().prepareBulk();
Expand Down Expand Up @@ -376,7 +377,7 @@ public void testAdmissionControlWithinLimits() throws Exception {
updateSettingsRequest.transientSettings(
Settings.builder()
.put(super.nodeSettings())
.put(ADMISSION_CONTROL_TRANSPORT_LAYER_MODE.getKey(), AdmissionControlMode.ENFORCED)
.put(ADMISSION_CONTROL_TRANSPORT_LAYER_MODE.getKey(), AdmissionControlMode.ENFORCED.getMode())
.put(SEARCH_CPU_USAGE_LIMIT.getKey(), 101)
.put(INDEXING_CPU_USAGE_LIMIT.getKey(), 101)
.put(SEARCH_IO_USAGE_LIMIT.getKey(), 101)
Expand Down

0 comments on commit d4ba448

Please sign in to comment.