Search in sources :

Example 1 with LogCapture

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)");
}
Also used : Node(com.datastax.oss.driver.api.core.metadata.Node) IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) TestAssertions.assertThat(com.datastax.oss.dsbulk.tests.assertions.TestAssertions.assertThat) TokenMap(com.datastax.oss.driver.api.core.metadata.TokenMap) DriverUtils(com.datastax.oss.dsbulk.tests.driver.DriverUtils) Mockito.when(org.mockito.Mockito.when) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) LogCapture(com.datastax.oss.dsbulk.tests.logging.LogCapture) DriverUtils.mockNode(com.datastax.oss.dsbulk.tests.driver.DriverUtils.mockNode) ImmutableMap(com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap) Test(org.junit.jupiter.api.Test) DEBUG(org.slf4j.event.Level.DEBUG) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) CqlSession(com.datastax.oss.driver.api.core.CqlSession) Map(java.util.Map) Metadata(com.datastax.oss.driver.api.core.metadata.Metadata) LogInterceptingExtension(com.datastax.oss.dsbulk.tests.logging.LogInterceptingExtension) Collections(java.util.Collections) LogInterceptor(com.datastax.oss.dsbulk.tests.logging.LogInterceptor) Node(com.datastax.oss.driver.api.core.metadata.Node) DriverUtils.mockNode(com.datastax.oss.dsbulk.tests.driver.DriverUtils.mockNode) Metadata(com.datastax.oss.driver.api.core.metadata.Metadata) TokenMap(com.datastax.oss.driver.api.core.metadata.TokenMap) UUID(java.util.UUID) CqlSession(com.datastax.oss.driver.api.core.CqlSession) Test(org.junit.jupiter.api.Test)

Aggregations

CqlSession (com.datastax.oss.driver.api.core.CqlSession)1 Metadata (com.datastax.oss.driver.api.core.metadata.Metadata)1 Node (com.datastax.oss.driver.api.core.metadata.Node)1 TokenMap (com.datastax.oss.driver.api.core.metadata.TokenMap)1 ImmutableMap (com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap)1 TestAssertions.assertThat (com.datastax.oss.dsbulk.tests.assertions.TestAssertions.assertThat)1 DriverUtils (com.datastax.oss.dsbulk.tests.driver.DriverUtils)1 DriverUtils.mockNode (com.datastax.oss.dsbulk.tests.driver.DriverUtils.mockNode)1 LogCapture (com.datastax.oss.dsbulk.tests.logging.LogCapture)1 LogInterceptingExtension (com.datastax.oss.dsbulk.tests.logging.LogInterceptingExtension)1 LogInterceptor (com.datastax.oss.dsbulk.tests.logging.LogInterceptor)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Map (java.util.Map)1 UUID (java.util.UUID)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 Test (org.junit.jupiter.api.Test)1 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)1 Mockito.when (org.mockito.Mockito.when)1