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"));
}
}
Aggregations