use of io.pravega.shared.health.TestHealthContributors.HealthyContributor in project pravega by pravega.
the class HealthManagerTests method testDetailsEndpoints.
/**
* Tests that when specified a {@link Health} result will return any details information belonging to that
* {@link HealthContributor} or it's dependencies.
*/
@Test
public void testDetailsEndpoints() throws TimeoutException {
@Cleanup HealthyContributor contributor = new HealthyContributor("contributor");
service.register(contributor);
// Wait for the health result to be picked up by the HealthServiceUpdater.
awaitHealthContributor(service, contributor.getName());
Health health = service.getEndpoint().getHealth();
Assert.assertEquals("There should be at least one child contributor", 1, health.getChildren().size());
// Tests that the Details object(s) are reachable via the 'service level' endpoint.
Health sample = health.getChildren().entrySet().stream().findFirst().get().getValue();
Assert.assertEquals("There should be one details entry provided by the SimpleIndicator.", 1, sample.getDetails().size());
Assert.assertEquals(String.format("Key should equal \"%s\"", HealthyContributor.DETAILS_KEY), HealthyContributor.DETAILS_KEY, sample.getDetails().keySet().stream().findFirst().get());
Assert.assertEquals(String.format("Value should equal \"%s\"", HealthyContributor.DETAILS_VAL), HealthyContributor.DETAILS_VAL, sample.getDetails().entrySet().stream().findFirst().get().getValue());
// Directly query the HealthContributor endpoint.
health = service.getEndpoint().getHealth(contributor.getName());
Assert.assertEquals(String.format("Key should equal \"%s\"", HealthyContributor.DETAILS_KEY), HealthyContributor.DETAILS_KEY, health.getDetails().keySet().stream().findFirst().get());
Assert.assertEquals(String.format("Value should equal \"%s\"", HealthyContributor.DETAILS_VAL), HealthyContributor.DETAILS_VAL, health.getDetails().get(HealthyContributor.DETAILS_KEY));
}
use of io.pravega.shared.health.TestHealthContributors.HealthyContributor in project pravega by pravega.
the class HealthContributorTests method testHealth.
/**
* Perform a basic {@link Health} check.
*/
@Test
public void testHealth() {
@Cleanup HealthyContributor contributor = new HealthyContributor();
Health health = contributor.getHealthSnapshot();
Assert.assertEquals("Should exactly one detail entry.", 1, health.getDetails().size());
Assert.assertEquals("HealthContributor should report an 'UP' Status.", Status.UP, health.getStatus());
}
use of io.pravega.shared.health.TestHealthContributors.HealthyContributor in project pravega by pravega.
the class HealthManagerTests method testStatusEndpoints.
/**
* Test that both the {@link HealthServiceManager} and a {@link HealthContributor} can be queried for its {@link Status}
* information.
*/
@Test
public void testStatusEndpoints() throws Exception {
@Cleanup HealthyContributor contributor = new HealthyContributor("contributor");
service.register(contributor);
awaitHealthContributor(service, contributor.getName());
// Test the 'service level' endpoint.
Assert.assertEquals("Status should be UP", Status.UP, service.getEndpoint().getStatus());
// Test the contributor level endpoint.
Assert.assertEquals("Status should be UP", Status.UP, service.getEndpoint().getStatus(contributor.getName()));
}
use of io.pravega.shared.health.TestHealthContributors.HealthyContributor in project pravega by pravega.
the class HealthManagerTests method testHealth.
/**
* Tests that the {@link HealthServiceManager} is able to provide {@link Health} results for both a specific {@link HealthContributor}
* and the service itself ({@link HealthServiceManager}.
*/
@Test
public void testHealth() throws Exception {
@Cleanup HealthyContributor contributor = new HealthyContributor();
service.register(contributor);
awaitHealthContributor(service, contributor.getName());
Assert.assertNotNull(service.getEndpoint().getHealth(contributor.getName()));
Assert.assertNotNull(service.getEndpoint().getHealth());
Assert.assertEquals("Status of the default/root component is expected to be 'UP'", Status.UP, service.getEndpoint().getStatus());
Assert.assertEquals("There should be exactly one child (SimpleIndicator)", 1, service.getEndpoint().getHealth().getChildren().size());
}
use of io.pravega.shared.health.TestHealthContributors.HealthyContributor in project pravega by pravega.
the class HealthManagerTests method testReadinessEndpoints.
/**
* Test that both the {@link HealthServiceManager} and a {@link HealthContributor} can be queried for its readiness information.
*/
@Test
public void testReadinessEndpoints() throws TimeoutException {
@Cleanup HealthyContributor contributor = new HealthyContributor("contributor");
service.register(contributor);
// Wait for the HealthServiceUpdater to update the Health state.
awaitHealthContributor(service, contributor.getName());
boolean ready = service.getEndpoint().isReady();
Assert.assertEquals("The HealthServiceManager should produce a 'ready' result.", true, ready);
ready = service.getEndpoint().isReady(contributor.getName());
Assert.assertEquals("The SampleIndicator should produce a 'ready' result.", true, ready);
}
Aggregations