use of com.datastax.oss.driver.api.core.metadata.Node in project zipkin by openzipkin.
the class SchemaTest method ensureKeyspaceMetadata_failsWhenVersionLessThan3_11_3.
@Test
public void ensureKeyspaceMetadata_failsWhenVersionLessThan3_11_3() {
CqlSession session = mock(CqlSession.class);
Metadata metadata = mock(Metadata.class);
Node node = mock(Node.class);
when(session.getMetadata()).thenReturn(metadata);
when(metadata.getNodes()).thenReturn(Collections.singletonMap(UUID.fromString("11111111-1111-1111-1111-111111111111"), node));
when(node.getCassandraVersion()).thenReturn(Version.parse("3.11.2"));
assertThatThrownBy(() -> Schema.ensureKeyspaceMetadata(session, "zipkin2")).isInstanceOf(RuntimeException.class).hasMessage("Node 11111111-1111-1111-1111-111111111111 is running Cassandra 3.11.2, but minimum version is 3.11.3");
}
use of com.datastax.oss.driver.api.core.metadata.Node 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 com.datastax.oss.driver.api.core.metadata.Node 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.metadata.Node in project zipkin by openzipkin.
the class SchemaTest method ensureKeyspaceMetadata_failsWhenOneVersionLessThan3_11_3.
@Test
public void ensureKeyspaceMetadata_failsWhenOneVersionLessThan3_11_3() {
CqlSession session = mock(CqlSession.class);
Metadata metadata = mock(Metadata.class);
Node node1 = mock(Node.class);
Node node2 = mock(Node.class);
Map<UUID, Node> nodes = new LinkedHashMap<>();
nodes.put(UUID.fromString("11111111-1111-1111-1111-111111111111"), node1);
nodes.put(UUID.fromString("22222222-2222-2222-2222-222222222222"), node2);
when(session.getMetadata()).thenReturn(metadata);
when(metadata.getNodes()).thenReturn(nodes);
when(node1.getCassandraVersion()).thenReturn(Version.parse("3.11.3"));
when(node2.getCassandraVersion()).thenReturn(Version.parse("3.11.2"));
assertThatThrownBy(() -> Schema.ensureKeyspaceMetadata(session, "zipkin2")).isInstanceOf(RuntimeException.class).hasMessage("Node 22222222-2222-2222-2222-222222222222 is running Cassandra 3.11.2, but minimum version is 3.11.3");
}
use of com.datastax.oss.driver.api.core.metadata.Node in project zipkin by openzipkin.
the class SchemaTest method ensureKeyspaceMetadata_passesWhenVersion3_11_3AndKeyspaceMetadataIsNotNull.
@Test
public void ensureKeyspaceMetadata_passesWhenVersion3_11_3AndKeyspaceMetadataIsNotNull() {
CqlSession session = mock(CqlSession.class);
Metadata metadata = mock(Metadata.class);
Node node = mock(Node.class);
KeyspaceMetadata keyspaceMetadata = mock(KeyspaceMetadata.class);
when(session.getMetadata()).thenReturn(metadata);
when(metadata.getNodes()).thenReturn(Collections.singletonMap(UUID.fromString("11111111-1111-1111-1111-111111111111"), node));
when(node.getCassandraVersion()).thenReturn(Version.parse("3.11.3"));
when(metadata.getKeyspace("zipkin2")).thenReturn(Optional.of(keyspaceMetadata));
assertThat(Schema.ensureKeyspaceMetadata(session, "zipkin2")).isSameAs(keyspaceMetadata);
}
Aggregations