use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class CassandraDriverHealthIndicatorTests method healthWithcassandraDownShouldReturnDown.
@Test
void healthWithcassandraDownShouldReturnDown() {
CqlSession session = mock(CqlSession.class);
given(session.getMetadata()).willThrow(new DriverTimeoutException("Test Exception"));
CassandraDriverHealthIndicator healthIndicator = new CassandraDriverHealthIndicator(session);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(health.getDetails().get("error")).isEqualTo(DriverTimeoutException.class.getName() + ": Test Exception");
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class CassandraDriverHealthIndicatorTests method healthWithoutNodeVersionShouldNotAddVersionDetail.
@Test
void healthWithoutNodeVersionShouldNotAddVersionDetail() {
CqlSession session = mockCqlSessionWithNodeState(NodeState.UP);
CassandraDriverHealthIndicator healthIndicator = new CassandraDriverHealthIndicator(session);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("version")).isNull();
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class CassandraDriverHealthIndicatorTests method healthWithOneUnhealthyNodeShouldReturnDown.
@Test
void healthWithOneUnhealthyNodeShouldReturnDown() {
CqlSession session = mockCqlSessionWithNodeState(NodeState.DOWN);
CassandraDriverHealthIndicator healthIndicator = new CassandraDriverHealthIndicator(session);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class CassandraDriverHealthIndicatorTests method healthWithNodeVersionShouldAddVersionDetail.
@Test
void healthWithNodeVersionShouldAddVersionDetail() {
CqlSession session = mock(CqlSession.class);
Metadata metadata = mock(Metadata.class);
given(session.getMetadata()).willReturn(metadata);
Node node = mock(Node.class);
given(node.getState()).willReturn(NodeState.UP);
given(node.getCassandraVersion()).willReturn(Version.V4_0_0);
given(metadata.getNodes()).willReturn(createNodesWithRandomUUID(Collections.singletonList(node)));
CassandraDriverHealthIndicator healthIndicator = new CassandraDriverHealthIndicator(session);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("version")).isEqualTo(Version.V4_0_0);
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class CassandraDriverHealthIndicatorTests method healthWithOneHealthyNodeAndOneUnhealthyNodeShouldReturnUp.
@Test
void healthWithOneHealthyNodeAndOneUnhealthyNodeShouldReturnUp() {
CqlSession session = mockCqlSessionWithNodeState(NodeState.UP, NodeState.DOWN);
CassandraDriverHealthIndicator healthIndicator = new CassandraDriverHealthIndicator(session);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
}
Aggregations