Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Fix failing reaction wheel tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sruti1312 committed Aug 8, 2020
1 parent bfdb93d commit 0194f9f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public void testBuilder() {
ResourceEnum.FIELD_DATA_CACHE,
appContext.getNodeConfigCache(),
CacheDeciderConfig.DEFAULT_FIELD_DATA_CACHE_UPPER_BOUND,
true);
true,
appContext);
BatchStartControlRequest request = ModifyCacheMaxSizeRequestBuilder.newBuilder(action).build();
Assert.assertEquals(1, request.getActionsCount());
ReactionWheel.Action requestAction = request.getActions(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.amazon.opendistro.elasticsearch.performanceanalyzer.plugins.reaction_wheel;

import com.amazon.opendistro.elasticsearch.performanceanalyzer.AppContext;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.decisionmaker.actions.ModifyQueueCapacityAction;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.grpc.ResourceEnum;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.plugins.reaction_wheel.ReactionWheelUtil.ControlType;
Expand All @@ -20,8 +21,9 @@ public class ModifyQueueCapacityRequestBuilderTest {

@Test
public void testBuilder() {
AppContext appContext = new AppContext();
ModifyQueueCapacityAction action =
new ModifyQueueCapacityAction(nodeKey, ResourceEnum.SEARCH_THREADPOOL, 1000, true);
new ModifyQueueCapacityAction(nodeKey, ResourceEnum.SEARCH_THREADPOOL, 1000, true, appContext);
BatchStartControlRequest request = ModifyQueueCapacityRequestBuilder.newBuilder(action).build();
Assert.assertEquals(1, request.getActionsCount());
ReactionWheel.Action requestAction = request.getActions(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static com.amazon.opendistro.elasticsearch.performanceanalyzer.plugins.reaction_wheel.ReactionWheelDummyService.SERVER_PORT;

import com.amazon.opendistro.elasticsearch.performanceanalyzer.AppContext;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.decisionmaker.actions.ModifyQueueCapacityAction;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.grpc.ResourceEnum;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.plugins.reaction_wheel.ReactionWheelUtil.ControlType;
Expand All @@ -23,6 +24,7 @@ public class ReactionWheelHandlerTest {
private Server server;
private ReactionWheelDummyService reactionWheelDummyService;
private ReactionWheelHandler reactionWheelHandler;
private AppContext appContext;
InstanceDetails.Id id = new Id("node1");
InstanceDetails.Ip ip = new Ip("127.0.0.1");
NodeKey nodeKey = new NodeKey(id, ip);
Expand All @@ -32,6 +34,7 @@ public void initService() throws IOException {
reactionWheelDummyService = new ReactionWheelDummyService();
server = ServerBuilder.forPort(SERVER_PORT).addService(reactionWheelDummyService).build().start();
reactionWheelHandler = new ReactionWheelHandler();
appContext = new AppContext();
}

@After
Expand All @@ -43,7 +46,7 @@ public void closeService() {
@Test
public void testPublishQueueAction() {
ModifyQueueCapacityAction action =
new ModifyQueueCapacityAction(nodeKey, ResourceEnum.WRITE_THREADPOOL, 100, true);
new ModifyQueueCapacityAction(nodeKey, ResourceEnum.WRITE_THREADPOOL, 100, true, appContext);
reactionWheelHandler.actionPublished(action);
BatchStartControlResult result = reactionWheelDummyService.getAndClearResult();
Assert.assertNotNull(result);
Expand All @@ -65,16 +68,17 @@ public void testPublishQueueAction() {
@Test
public void testPublishInvalidAction() {
InvalidAction invalidAction =
new InvalidAction(nodeKey, ResourceEnum.WRITE_THREADPOOL, 100, true);
new InvalidAction(nodeKey, ResourceEnum.WRITE_THREADPOOL, 100, true, appContext);
reactionWheelHandler.actionPublished(invalidAction);
BatchStartControlResult result = reactionWheelDummyService.getAndClearResult();
Assert.assertNull(result);
}

private static class InvalidAction extends ModifyQueueCapacityAction {

public InvalidAction(NodeKey esNode, ResourceEnum threadPool, int currentCapacity, boolean increase) {
super(esNode, threadPool, currentCapacity, increase);
public InvalidAction
(NodeKey esNode, ResourceEnum threadPool, int currentCapacity, boolean increase, AppContext appContext) {
super(esNode, threadPool, currentCapacity, increase, appContext);
}

@Override
Expand Down

0 comments on commit 0194f9f

Please sign in to comment.