use of com.datastax.oss.driver.api.core.CqlSession 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);
}
use of com.datastax.oss.driver.api.core.CqlSession in project spring-boot by spring-projects.
the class CassandraDriverHealthIndicatorTests method healthWithOneUnknownNodeShouldReturnDown.
@Test
void healthWithOneUnknownNodeShouldReturnDown() {
CqlSession session = mockCqlSessionWithNodeState(NodeState.UNKNOWN);
CassandraDriverHealthIndicator healthIndicator = new CassandraDriverHealthIndicator(session);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
}
use of com.datastax.oss.driver.api.core.CqlSession in project spring-boot by spring-projects.
the class CassandraDriverReactiveHealthIndicatorTests 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)));
CassandraDriverReactiveHealthIndicator healthIndicator = new CassandraDriverReactiveHealthIndicator(session);
Mono<Health> health = healthIndicator.health();
StepVerifier.create(health).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.UP);
assertThat(h.getDetails()).containsOnlyKeys("version");
assertThat(h.getDetails().get("version")).isEqualTo(Version.V4_0_0);
}).verifyComplete();
}
use of com.datastax.oss.driver.api.core.CqlSession in project spring-boot by spring-projects.
the class CassandraDriverReactiveHealthIndicatorTests method healthWithoutNodeVersionShouldNotAddVersionDetail.
@Test
void healthWithoutNodeVersionShouldNotAddVersionDetail() {
CqlSession session = mockCqlSessionWithNodeState(NodeState.UP);
CassandraDriverReactiveHealthIndicator healthIndicator = new CassandraDriverReactiveHealthIndicator(session);
Mono<Health> health = healthIndicator.health();
StepVerifier.create(health).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.UP);
assertThat(h.getDetails().get("version")).isNull();
}).verifyComplete();
}
use of com.datastax.oss.driver.api.core.CqlSession in project spring-boot by spring-projects.
the class CassandraDriverReactiveHealthIndicatorTests method healthWithOneHealthyNodeShouldReturnUp.
@Test
void healthWithOneHealthyNodeShouldReturnUp() {
CqlSession session = mockCqlSessionWithNodeState(NodeState.UP);
CassandraDriverReactiveHealthIndicator healthIndicator = new CassandraDriverReactiveHealthIndicator(session);
Mono<Health> health = healthIndicator.health();
StepVerifier.create(health).consumeNextWith((h) -> assertThat(h.getStatus()).isEqualTo(Status.UP)).verifyComplete();
}
Aggregations