Search in sources :

Example 11 with Health

use of io.pravega.shared.health.Health in project pravega by pravega.

the class SegmentContainerHealthContributorTest method testSegmentContainerHealth.

/**
 * Check health of SegmentContainer with different states.
 */
@Test
public void testSegmentContainerHealth() {
    when(segmentContainer.state()).thenReturn(Service.State.NEW);
    Health.HealthBuilder builder = Health.builder().name(segmentContainerHealthContributor.getName());
    Status status = segmentContainerHealthContributor.doHealthCheck(builder);
    Assert.assertEquals("HealthContributor should report an 'NEW' Status.", Status.NEW, status);
    when(segmentContainer.state()).thenReturn(Service.State.STARTING);
    status = segmentContainerHealthContributor.doHealthCheck(builder);
    Assert.assertEquals("HealthContributor should report an 'STARTING' Status.", Status.STARTING, status);
    when(segmentContainer.state()).thenReturn(Service.State.RUNNING);
    status = segmentContainerHealthContributor.doHealthCheck(builder);
    Assert.assertEquals("HealthContributor should report an 'UP' Status.", Status.UP, status);
    when(segmentContainer.state()).thenReturn(Service.State.TERMINATED);
    status = segmentContainerHealthContributor.doHealthCheck(builder);
    Assert.assertEquals("HealthContributor should report an 'DOWN' Status.", Status.DOWN, status);
}
Also used : Status(io.pravega.shared.health.Status) Health(io.pravega.shared.health.Health) Test(org.junit.Test)

Example 12 with Health

use of io.pravega.shared.health.Health in project pravega by pravega.

the class ServiceStarterTest method testSegmentContainerRegistryHealth.

/**
 * Check health of SegmentContainerRegistry
 */
@Test
public void testSegmentContainerRegistryHealth() {
    @Cleanup SegmentContainerRegistryHealthContributor segmentContainerRegistryHealthContributor = new SegmentContainerRegistryHealthContributor(serviceStarter.getServiceBuilder().getSegmentContainerRegistry());
    Health.HealthBuilder builder = Health.builder().name(segmentContainerRegistryHealthContributor.getName());
    Status status = segmentContainerRegistryHealthContributor.doHealthCheck(builder);
    Assert.assertEquals("HealthContributor should report an 'UP' Status.", Status.UP, status);
}
Also used : Status(io.pravega.shared.health.Status) Health(io.pravega.shared.health.Health) SegmentContainerRegistryHealthContributor(io.pravega.segmentstore.server.host.health.SegmentContainerRegistryHealthContributor) Cleanup(lombok.Cleanup) Test(org.junit.Test)

Example 13 with Health

use of io.pravega.shared.health.Health in project pravega by pravega.

the class ServiceStarterTest method testHealth.

/**
 * Check the health status of ServiceStarter
 */
@Test
public void testHealth() {
    Health health = serviceStarter.getHealthServiceManager().getHealthSnapshot();
    Assert.assertEquals("HealthContributor should report an 'UP' Status.", Status.UP, health.getStatus());
}
Also used : Health(io.pravega.shared.health.Health) Test(org.junit.Test)

Example 14 with Health

use of io.pravega.shared.health.Health in project pravega by pravega.

the class SegmentContainerRegistryHealthContributorTest method testSegmentContainerHealth.

/**
 * Check health of SegmentContainerRegistry with different states.
 */
@Test
public void testSegmentContainerHealth() {
    when(segmentContainerRegistry.isClosed()).thenReturn(true);
    Health.HealthBuilder builder = Health.builder().name(segmentContainerRegistryHealthContributor.getName());
    Status health = segmentContainerRegistryHealthContributor.doHealthCheck(builder);
    Assert.assertEquals("HealthContributor should report an 'DOWN' Status.", Status.DOWN, health);
    when(segmentContainerRegistry.isClosed()).thenReturn(false);
    health = segmentContainerRegistryHealthContributor.doHealthCheck(builder);
    Assert.assertEquals("HealthContributor should report an 'UP' Status.", Status.UP, health);
}
Also used : Status(io.pravega.shared.health.Status) Health(io.pravega.shared.health.Health) Test(org.junit.Test)

Aggregations

Health (io.pravega.shared.health.Health)14 Test (org.junit.Test)11 Cleanup (lombok.Cleanup)6 Status (io.pravega.shared.health.Status)5 HealthContributor (io.pravega.shared.health.HealthContributor)2 HealthyContributor (io.pravega.shared.health.TestHealthContributors.HealthyContributor)2 lombok.val (lombok.val)2 StreamSegmentStore (io.pravega.segmentstore.contracts.StreamSegmentStore)1 TableStore (io.pravega.segmentstore.contracts.tables.TableStore)1 CacheManagerHealthContributor (io.pravega.segmentstore.server.CacheManager.CacheManagerHealthContributor)1 PassingTokenVerifier (io.pravega.segmentstore.server.host.delegationtoken.PassingTokenVerifier)1 SegmentContainerRegistryHealthContributor (io.pravega.segmentstore.server.host.health.SegmentContainerRegistryHealthContributor)1 ContributorNotFoundException (io.pravega.shared.health.ContributorNotFoundException)1 HealthServiceManager (io.pravega.shared.health.HealthServiceManager)1 FailingContributor (io.pravega.shared.health.TestHealthContributors.FailingContributor)1 ThrowingContributor (io.pravega.shared.health.TestHealthContributors.ThrowingContributor)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 AsyncResponse (javax.ws.rs.container.AsyncResponse)1