use of com.datastax.oss.dsbulk.tests.logging.LogCapture in project dsbulk by datastax.
the class ClusterInformationUtilsTest method should_log_cluster_information_in_debug_mode.
@Test
void should_log_cluster_information_in_debug_mode(@LogCapture(value = ClusterInformationUtils.class, level = DEBUG) LogInterceptor interceptor) {
// given
CqlSession session = DriverUtils.mockSession();
Metadata metadata = session.getMetadata();
TokenMap tokenMap = metadata.getTokenMap().get();
when(tokenMap.getPartitionerName()).thenReturn("simple-partitioner");
Map<UUID, Node> nodes = IntStream.range(0, 110).mapToObj(i -> mockNode(UUID.randomUUID(), "1.2.3." + i, "dc1")).collect(Collectors.toMap(Node::getHostId, n -> n));
when(metadata.getNodes()).thenReturn(nodes);
// when
ClusterInformationUtils.printDebugInfoAboutCluster(session);
// then
assertThat(interceptor).hasMessageContaining("Partitioner: simple-partitioner");
assertThat(interceptor).hasMessageContaining("Total number of nodes: 110");
assertThat(interceptor).hasMessageContaining("Nodes:");
assertThat(interceptor).hasMessageContaining("(Other nodes omitted)");
}
Aggregations