use of com.datastax.oss.driver.api.core.CqlSession in project spring-boot by spring-projects.
the class CassandraDriverHealthIndicatorTests method healthWithOneHealthyNodeAndOneForcedDownNodeShouldReturnUp.
@Test
void healthWithOneHealthyNodeAndOneForcedDownNodeShouldReturnUp() {
CqlSession session = mockCqlSessionWithNodeState(NodeState.UP, NodeState.FORCED_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 CassandraDriverReactiveHealthIndicatorTests method healthWithCassandraDownShouldReturnDown.
@Test
void healthWithCassandraDownShouldReturnDown() {
CqlSession session = mock(CqlSession.class);
given(session.getMetadata()).willThrow(new DriverTimeoutException("Test Exception"));
CassandraDriverReactiveHealthIndicator cassandraReactiveHealthIndicator = new CassandraDriverReactiveHealthIndicator(session);
Mono<Health> health = cassandraReactiveHealthIndicator.health();
StepVerifier.create(health).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.DOWN);
assertThat(h.getDetails()).containsOnlyKeys("error");
assertThat(h.getDetails().get("error")).isEqualTo(DriverTimeoutException.class.getName() + ": Test Exception");
}).verifyComplete();
}
use of com.datastax.oss.driver.api.core.CqlSession in project spring-boot by spring-projects.
the class CassandraDriverReactiveHealthIndicatorTests method healthWithOneHealthyNodeAndOneUnknownNodeShouldReturnUp.
@Test
void healthWithOneHealthyNodeAndOneUnknownNodeShouldReturnUp() {
CqlSession session = mockCqlSessionWithNodeState(NodeState.UP, NodeState.UNKNOWN);
CassandraDriverReactiveHealthIndicator healthIndicator = new CassandraDriverReactiveHealthIndicator(session);
Mono<Health> health = healthIndicator.health();
StepVerifier.create(health).consumeNextWith((h) -> assertThat(h.getStatus()).isEqualTo(Status.UP)).verifyComplete();
}
use of com.datastax.oss.driver.api.core.CqlSession in project spring-boot by spring-projects.
the class CassandraDriverReactiveHealthIndicatorTests method healthWithOneUnhealthyNodeShouldReturnDown.
@Test
void healthWithOneUnhealthyNodeShouldReturnDown() {
CqlSession session = mockCqlSessionWithNodeState(NodeState.DOWN);
CassandraDriverReactiveHealthIndicator healthIndicator = new CassandraDriverReactiveHealthIndicator(session);
Mono<Health> health = healthIndicator.health();
StepVerifier.create(health).consumeNextWith((h) -> assertThat(h.getStatus()).isEqualTo(Status.DOWN)).verifyComplete();
}
use of com.datastax.oss.driver.api.core.CqlSession in project spring-boot by spring-projects.
the class CassandraDriverReactiveHealthIndicatorTests method healthWithOneForcedDownNodeShouldReturnDown.
@Test
void healthWithOneForcedDownNodeShouldReturnDown() {
CqlSession session = mockCqlSessionWithNodeState(NodeState.FORCED_DOWN);
CassandraDriverReactiveHealthIndicator healthIndicator = new CassandraDriverReactiveHealthIndicator(session);
Mono<Health> health = healthIndicator.health();
StepVerifier.create(health).consumeNextWith((h) -> assertThat(h.getStatus()).isEqualTo(Status.DOWN)).verifyComplete();
}
Aggregations