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: Ajay Kumar Movva <[email protected]>
- Loading branch information
Ajay Kumar Movva
committed
Feb 1, 2024
1 parent
68199a1
commit 434fb1c
Showing
6 changed files
with
116 additions
and
133 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
17 changes: 0 additions & 17 deletions
17
server/src/test/java/org/opensearch/index/remote/DummyTests.java
This file was deleted.
Oops, something went wrong.
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
109 changes: 0 additions & 109 deletions
109
...ensearch/ratelimitting/admissioncontrol/controllers/CPUBasedAdmissionControllerTests.java
This file was deleted.
Oops, something went wrong.
109 changes: 109 additions & 0 deletions
109
...ensearch/ratelimitting/admissioncontrol/controllers/CpuBasedAdmissionControllerTests.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,109 @@ | ||
/* | ||
* 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.ratelimitting.admissioncontrol.controllers; | ||
|
||
import org.opensearch.cluster.service.ClusterService; | ||
import org.opensearch.common.settings.ClusterSettings; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.ratelimitting.admissioncontrol.enums.AdmissionControlMode; | ||
import org.opensearch.ratelimitting.admissioncontrol.settings.CPUBasedAdmissionControllerSettings; | ||
import org.opensearch.test.OpenSearchTestCase; | ||
import org.opensearch.threadpool.TestThreadPool; | ||
import org.opensearch.threadpool.ThreadPool; | ||
|
||
public class CpuBasedAdmissionControllerTests extends OpenSearchTestCase { | ||
private ClusterService clusterService; | ||
private ThreadPool threadPool; | ||
CpuBasedAdmissionController admissionController = null; | ||
|
||
String action = "TEST_ACTION"; | ||
|
||
@Override | ||
public void setUp() throws Exception { | ||
super.setUp(); | ||
threadPool = new TestThreadPool("admission_controller_settings_test"); | ||
clusterService = new ClusterService( | ||
Settings.EMPTY, | ||
new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), | ||
threadPool | ||
); | ||
} | ||
|
||
@Override | ||
public void tearDown() throws Exception { | ||
super.tearDown(); | ||
threadPool.shutdownNow(); | ||
} | ||
|
||
public void testCheckDefaultParameters() { | ||
admissionController = new CpuBasedAdmissionController( | ||
CPUBasedAdmissionControllerSettings.CPU_BASED_ADMISSION_CONTROLLER, | ||
Settings.EMPTY, | ||
clusterService.getClusterSettings() | ||
); | ||
assertEquals(admissionController.getName(), CPUBasedAdmissionControllerSettings.CPU_BASED_ADMISSION_CONTROLLER); | ||
assertEquals(admissionController.getRejectionCount(), 0); | ||
assertEquals(admissionController.settings.getTransportLayerAdmissionControllerMode(), AdmissionControlMode.DISABLED); | ||
assertFalse( | ||
admissionController.isEnabledForTransportLayer(admissionController.settings.getTransportLayerAdmissionControllerMode()) | ||
); | ||
} | ||
|
||
// public void testCheckUpdateSettings() { | ||
// admissionController = new CpuBasedAdmissionController( | ||
// CPUBasedAdmissionControllerSettings.CPU_BASED_ADMISSION_CONTROLLER, | ||
// Settings.EMPTY, | ||
// clusterService.getClusterSettings() | ||
// ); | ||
// Settings settings = Settings.builder() | ||
// .put( | ||
// CPUBasedAdmissionControllerSettings.CPU_BASED_ADMISSION_CONTROLLER_TRANSPORT_LAYER_MODE.getKey(), | ||
// AdmissionControlMode.ENFORCED.getMode() | ||
// ) | ||
// .build(); | ||
// clusterService.getClusterSettings().applySettings(settings); | ||
// | ||
// assertEquals(admissionController.getName(), CPUBasedAdmissionControllerSettings.CPU_BASED_ADMISSION_CONTROLLER); | ||
// assertEquals(admissionController.getRejectionCount(), 0); | ||
// assertEquals(admissionController.settings.getTransportLayerAdmissionControllerMode(), AdmissionControlMode.ENFORCED); | ||
// assertTrue(admissionController.isEnabledForTransportLayer(admissionController.settings.getTransportLayerAdmissionControllerMode())); | ||
// } | ||
// | ||
// public void testApplyControllerWithDefaultSettings() { | ||
// admissionController = new CpuBasedAdmissionController( | ||
// CPUBasedAdmissionControllerSettings.CPU_BASED_ADMISSION_CONTROLLER, | ||
// Settings.EMPTY, | ||
// clusterService.getClusterSettings() | ||
// ); | ||
// assertEquals(admissionController.getRejectionCount(), 0); | ||
// assertEquals(admissionController.settings.getTransportLayerAdmissionControllerMode(), AdmissionControlMode.DISABLED); | ||
// action = "indices:data/write/bulk[s][p]"; | ||
// admissionController.apply(action); | ||
// assertEquals(admissionController.getRejectionCount(), 0); | ||
// } | ||
// | ||
// public void testApplyControllerWhenSettingsEnabled() { | ||
// Settings settings = Settings.builder() | ||
// .put( | ||
// CPUBasedAdmissionControllerSettings.CPU_BASED_ADMISSION_CONTROLLER_TRANSPORT_LAYER_MODE.getKey(), | ||
// AdmissionControlMode.ENFORCED.getMode() | ||
// ) | ||
// .build(); | ||
// admissionController = new CpuBasedAdmissionController( | ||
// CPUBasedAdmissionControllerSettings.CPU_BASED_ADMISSION_CONTROLLER, | ||
// settings, | ||
// clusterService.getClusterSettings() | ||
// ); | ||
// assertTrue(admissionController.isEnabledForTransportLayer(admissionController.settings.getTransportLayerAdmissionControllerMode())); | ||
// assertEquals(admissionController.getRejectionCount(), 0); | ||
// action = "indices:data/write/bulk[s][p]"; | ||
// admissionController.apply(action); | ||
// assertEquals(admissionController.getRejectionCount(), 1); | ||
// } | ||
} |