Search in sources :

Example 1 with CircuitBreakerPlugin

use of org.opensearch.plugins.CircuitBreakerPlugin in project OpenSearch by opensearch-project.

the class NodeTests method testCreateWithCircuitBreakerPlugins.

public void testCreateWithCircuitBreakerPlugins() throws IOException {
    Settings.Builder settings = baseSettings().put("breaker.test_breaker.limit", "50b");
    List<Class<? extends Plugin>> plugins = basePlugins();
    plugins.add(MockCircuitBreakerPlugin.class);
    try (Node node = new MockNode(settings.build(), plugins)) {
        CircuitBreakerService service = node.injector().getInstance(CircuitBreakerService.class);
        assertThat(service.getBreaker("test_breaker"), is(not(nullValue())));
        assertThat(service.getBreaker("test_breaker").getLimit(), equalTo(50L));
        CircuitBreakerPlugin breakerPlugin = node.getPluginsService().filterPlugins(CircuitBreakerPlugin.class).get(0);
        assertTrue(breakerPlugin instanceof MockCircuitBreakerPlugin);
        assertSame("plugin circuit breaker instance is not the same as breaker service's instance", ((MockCircuitBreakerPlugin) breakerPlugin).myCircuitBreaker.get(), service.getBreaker("test_breaker"));
    }
}
Also used : CircuitBreakerPlugin(org.opensearch.plugins.CircuitBreakerPlugin) NodeRoles.dataNode(org.opensearch.test.NodeRoles.dataNode) CircuitBreakerService(org.opensearch.indices.breaker.CircuitBreakerService) Settings(org.opensearch.common.settings.Settings) BreakerSettings(org.opensearch.indices.breaker.BreakerSettings) CircuitBreakerPlugin(org.opensearch.plugins.CircuitBreakerPlugin) Plugin(org.opensearch.plugins.Plugin)

Aggregations

Settings (org.opensearch.common.settings.Settings)1 BreakerSettings (org.opensearch.indices.breaker.BreakerSettings)1 CircuitBreakerService (org.opensearch.indices.breaker.CircuitBreakerService)1 CircuitBreakerPlugin (org.opensearch.plugins.CircuitBreakerPlugin)1 Plugin (org.opensearch.plugins.Plugin)1 NodeRoles.dataNode (org.opensearch.test.NodeRoles.dataNode)1