Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update RestController constructor for tests. #440

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.opensearch.common.settings.Settings;
import org.opensearch.env.Environment;
import org.opensearch.env.TestEnvironment;
import org.opensearch.identity.IdentityService;
import org.opensearch.indices.breaker.BreakerSettings;
import org.opensearch.indices.breaker.CircuitBreakerService;
import org.opensearch.indices.breaker.HierarchyCircuitBreakerService;
Expand Down Expand Up @@ -60,6 +61,7 @@ public class PerformanceAnalyzerPluginTests extends OpenSearchTestCase {
private CircuitBreakerService circuitBreakerService;
private ClusterService clusterService;
private ClusterSettings clusterSettings;
private IdentityService identityService;

@Before
public void setup() {
Expand All @@ -76,13 +78,15 @@ public void setup() {
nodeClient = new NodeClient(settings, threadPool);
environment = TestEnvironment.newEnvironment(settings);
clusterService = new ClusterService(settings, clusterSettings, threadPool);
identityService = new IdentityService(Settings.EMPTY, List.of());
restController =
new RestController(
Collections.emptySet(),
null,
nodeClient,
circuitBreakerService,
usageService);
usageService,
identityService);
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -25,6 +26,7 @@
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.identity.IdentityService;
import org.opensearch.indices.breaker.BreakerSettings;
import org.opensearch.indices.breaker.CircuitBreakerService;
import org.opensearch.indices.breaker.HierarchyCircuitBreakerService;
Expand All @@ -50,6 +52,7 @@ public class PerformanceAnalyzerClusterConfigActionTests {
private ClusterSettings clusterSettings;
private PerformanceAnalyzerClusterSettingHandler clusterSettingHandler;
private NodeStatsSettingHandler nodeStatsSettingHandler;
private IdentityService identityService;

@Mock private PerformanceAnalyzerController controller;
@Mock private ClusterSettingsManager clusterSettingsManager;
Expand All @@ -66,13 +69,15 @@ public void init() {
UsageService usageService = new UsageService();
threadPool = new TestThreadPool("test");
nodeClient = new NodeClient(Settings.EMPTY, threadPool);
identityService = new IdentityService(Settings.EMPTY, List.of());
restController =
new RestController(
Collections.emptySet(),
null,
nodeClient,
circuitBreakerService,
usageService);
usageService,
identityService);
clusterSettingHandler =
new PerformanceAnalyzerClusterSettingHandler(controller, clusterSettingsManager);
nodeStatsSettingHandler = new NodeStatsSettingHandler(controller, clusterSettingsManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -26,6 +27,7 @@
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.identity.IdentityService;
import org.opensearch.indices.breaker.BreakerSettings;
import org.opensearch.indices.breaker.CircuitBreakerService;
import org.opensearch.indices.breaker.HierarchyCircuitBreakerService;
Expand All @@ -46,6 +48,7 @@ public class PerformanceAnalyzerConfigActionTests {
private NodeClient nodeClient;
private CircuitBreakerService circuitBreakerService;
private ClusterSettings clusterSettings;
private IdentityService identityService;

@Mock private PerformanceAnalyzerController controller;

Expand All @@ -61,13 +64,15 @@ public void init() {
UsageService usageService = new UsageService();
threadPool = new TestThreadPool("test");
nodeClient = new NodeClient(Settings.EMPTY, threadPool);
identityService = new IdentityService(Settings.EMPTY, List.of());
restController =
new RestController(
Collections.emptySet(),
null,
nodeClient,
circuitBreakerService,
usageService);
usageService,
identityService);
configAction = new PerformanceAnalyzerConfigAction(restController, controller);
restController.registerHandler(configAction);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -24,6 +25,7 @@
import org.opensearch.common.util.concurrent.ThreadContext;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.identity.IdentityService;
import org.opensearch.indices.breaker.BreakerSettings;
import org.opensearch.indices.breaker.CircuitBreakerService;
import org.opensearch.indices.breaker.HierarchyCircuitBreakerService;
Expand All @@ -46,6 +48,7 @@ public class PerformanceAnalyzerOverridesClusterConfigActionTests {
private NodeClient nodeClient;
private CircuitBreakerService circuitBreakerService;
private ClusterSettings clusterSettings;
private IdentityService identityService;

@Mock private ConfigOverridesClusterSettingHandler configOverridesClusterSettingHandler;
@Mock private ConfigOverridesWrapper overridesWrapper;
Expand All @@ -62,13 +65,15 @@ public void init() {
UsageService usageService = new UsageService();
threadPool = new TestThreadPool("test");
nodeClient = new NodeClient(Settings.EMPTY, threadPool);
identityService = new IdentityService(Settings.EMPTY, List.of());
restController =
new RestController(
Collections.emptySet(),
null,
nodeClient,
circuitBreakerService,
usageService);
usageService,
identityService);
configAction =
new PerformanceAnalyzerOverridesClusterConfigAction(
Settings.EMPTY,
Expand Down