use of com.alipay.sofa.healthcheck.impl.ComponentHealthChecker in project sofa-boot by alipay.
the class ComponentHealthCheckerTest method componentHealthCheckerTest.
@Test
public void componentHealthCheckerTest() {
ComponentHealthChecker componentHealthChecker = applicationContext.getBean(ComponentHealthChecker.class);
Health health = componentHealthChecker.isHealthy();
Map<String, Object> details = health.getDetails();
for (String key : details.keySet()) {
Assert.assertTrue(((String) details.get(key)).contains("passed"));
}
}
use of com.alipay.sofa.healthcheck.impl.ComponentHealthChecker in project sofa-boot by alipay.
the class HealthCheckerProcessorParallelTest method testComponentHealthCheckerFailedFirst.
@Test
public void testComponentHealthCheckerFailedFirst() {
SofaRuntimeManager manager = new StandardSofaRuntimeManager("testComponentHealthCheckerFailedFirst", Thread.currentThread().getContextClassLoader(), null);
manager.getComponentManager().register(new TestComponent("component1", true));
manager.getComponentManager().register(new TestComponent("component2", true));
manager.getComponentManager().register(new TestComponent("component3", false));
manager.getComponentManager().register(new TestComponent("component4", true));
manager.getComponentManager().register(new TestComponent("component5", false));
ComponentHealthChecker componentHealthChecker = new ComponentHealthChecker(new SofaRuntimeContext(manager, manager.getComponentManager(), null));
int i = 0;
for (Map.Entry<String, Object> entry : componentHealthChecker.isHealthy().getDetails().entrySet()) {
if (i < 2) {
Assert.assertEquals(entry.getValue().toString(), "failed");
} else {
Assert.assertEquals(entry.getValue().toString(), "passed");
}
++i;
}
}
use of com.alipay.sofa.healthcheck.impl.ComponentHealthChecker in project sofa-boot by alipay.
the class HealthCheckerConfigTest method testCustomConfig.
@Test
public void testCustomConfig() {
ComponentHealthChecker componentHealthChecker = ctx.getBean(ComponentHealthChecker.class);
Assert.assertEquals(customRetryCount, componentHealthChecker.getRetryCount());
Assert.assertEquals(customRetryInterval, componentHealthChecker.getRetryTimeInterval());
}
use of com.alipay.sofa.healthcheck.impl.ComponentHealthChecker in project sofa-boot by alipay.
the class SofaComponentHealthCheckerTest method testDefaultConfig.
@Test
public void testDefaultConfig() {
ComponentHealthChecker sofaComponentHealthChecker = ctx.getBean(ComponentHealthChecker.class);
Assert.assertEquals(SofaBootConstants.SOFABOOT_COMPONENT_CHECK_RETRY_DEFAULT_COUNT, sofaComponentHealthChecker.getRetryCount());
Assert.assertEquals(SofaBootConstants.SOFABOOT_COMPONENT_CHECK_RETRY_DEFAULT_INTERVAL, sofaComponentHealthChecker.getRetryTimeInterval());
}
use of com.alipay.sofa.healthcheck.impl.ComponentHealthChecker in project sofa-boot by sofastack.
the class HealthCheckerConfigTest method testCustomConfig.
@Test
public void testCustomConfig() {
ComponentHealthChecker componentHealthChecker = ctx.getBean(ComponentHealthChecker.class);
Assert.assertEquals(customRetryCount, componentHealthChecker.getRetryCount());
Assert.assertEquals(customRetryInterval, componentHealthChecker.getRetryTimeInterval());
}
Aggregations