use of io.bootique.metrics.health.HealthCheckOutcome in project bootique-jdbc by bootique.
the class HikariCPInstrumentedModuleIT method testHealthChecks_HealthNoParam_ChecksTurnedOff.
@Test
public void testHealthChecks_HealthNoParam_ChecksTurnedOff() {
BQRuntime runtime = TEST_FACTORY.app("-c", "classpath:io/bootique/jdbc/instrumented/hikaricp/dummy-ds.yml").autoLoadModules().createRuntime();
DataSourceFactory factory = runtime.getInstance(DataSourceFactory.class);
String dataSourceName = "DerbyDatabaseIT";
HikariDataSource dataSource = (HikariDataSource) factory.forName(dataSourceName);
assertNotNull(dataSource);
HealthCheckRegistry registry = runtime.getInstance(HealthCheckRegistry.class);
/**
* embedded health check {@link io.bootique.jdbc.instrumented.healthcheck.DataSourceHealthCheck}
*/
assertTrue(registry.containsHealthCheck(DataSourceHealthCheck.healthCheckName(dataSourceName)));
Map<String, HealthCheckOutcome> results = registry.runHealthChecks();
assertEquals(results.size(), 1);
}
use of io.bootique.metrics.health.HealthCheckOutcome in project bootique-jdbc by bootique.
the class HikariCPInstrumentedModuleIT method testHealthChecksMultipleDs.
@Test
public void testHealthChecksMultipleDs() throws SQLException {
BQRuntime runtime = TEST_FACTORY.app("-c", "classpath:io/bootique/jdbc/instrumented/hikaricp/hikaricp-ds2-health.yml").autoLoadModules().createRuntime();
DataSourceFactory factory = runtime.getInstance(DataSourceFactory.class);
String derby2 = "derby2", derby3 = "derby3";
HikariDataSource ds2 = (HikariDataSource) factory.forName(derby2);
assertNotNull(ds2);
HikariDataSource ds3 = (HikariDataSource) factory.forName(derby3);
assertNotNull(ds3);
HealthCheckRegistry registry = runtime.getInstance(HealthCheckRegistry.class);
assertTrue(registry.containsHealthCheck(ConnectivityCheck.healthCheckName(derby2)));
assertTrue(registry.containsHealthCheck(Connection99PercentCheck.healthCheckName(derby2)));
/**
* embedded health check {@link io.bootique.jdbc.instrumented.healthcheck.DataSourceHealthCheck}
*/
assertTrue(registry.containsHealthCheck(DataSourceHealthCheck.healthCheckName(derby2)));
assertTrue(registry.containsHealthCheck(ConnectivityCheck.healthCheckName(derby3)));
assertTrue(registry.containsHealthCheck(Connection99PercentCheck.healthCheckName(derby3)));
/**
* embedded health check {@link io.bootique.jdbc.instrumented.healthcheck.DataSourceHealthCheck}
*/
assertTrue(registry.containsHealthCheck(DataSourceHealthCheck.healthCheckName(derby3)));
Map<String, HealthCheckOutcome> results = registry.runHealthChecks();
assertEquals(results.size(), 6);
}
use of io.bootique.metrics.health.HealthCheckOutcome in project bootique-jdbc by bootique.
the class HikariCPInstrumentedModuleIT method testHealthChecks_TurnedOn.
@Test
public void testHealthChecks_TurnedOn() {
BQRuntime runtime = TEST_FACTORY.app("-c", "classpath:io/bootique/jdbc/instrumented/hikaricp/hikaricp-ds-health.yml").autoLoadModules().createRuntime();
DataSourceFactory factory = runtime.getInstance(DataSourceFactory.class);
String dataSourceName = "derby1";
HikariDataSource dataSource = (HikariDataSource) factory.forName(dataSourceName);
assertNotNull(dataSource);
HealthCheckRegistry registry = runtime.getInstance(HealthCheckRegistry.class);
assertTrue(registry.containsHealthCheck(ConnectivityCheck.healthCheckName(dataSourceName)));
assertTrue(registry.containsHealthCheck(Connection99PercentCheck.healthCheckName(dataSourceName)));
/**
* embedded health check {@link io.bootique.jdbc.instrumented.healthcheck.DataSourceHealthCheck}
*/
assertTrue(registry.containsHealthCheck(DataSourceHealthCheck.healthCheckName(dataSourceName)));
Map<String, HealthCheckOutcome> results = registry.runHealthChecks();
assertEquals(results.size(), 3);
}
Aggregations