Search in sources :

Example 11 with Metadata

use of com.datastax.oss.driver.api.core.metadata.Metadata in project janusgraph by JanusGraph.

the class CQLStoreTest method testExistKeyspaceSession.

@Test
public void testExistKeyspaceSession() {
    Metadata metadata = mock(Metadata.class);
    KeyspaceMetadata keyspaceMetadata = mock(KeyspaceMetadata.class);
    Optional<KeyspaceMetadata> keyspaceMetadataOptional = Optional.of(keyspaceMetadata);
    when(session.getMetadata()).thenReturn(metadata);
    when(metadata.getKeyspace(TEST_KEYSPACE_NAME)).thenReturn(keyspaceMetadataOptional);
    mockManager.initializeKeyspace();
    verify(session, never()).execute(any(Statement.class));
}
Also used : Statement(com.datastax.oss.driver.api.core.cql.Statement) KeyspaceMetadata(com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata) Metadata(com.datastax.oss.driver.api.core.metadata.Metadata) TableMetadata(com.datastax.oss.driver.api.core.metadata.schema.TableMetadata) KeyspaceMetadata(com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata) KeyColumnValueStoreTest(org.janusgraph.diskstorage.KeyColumnValueStoreTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 12 with Metadata

use of com.datastax.oss.driver.api.core.metadata.Metadata 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");
}
Also used : Node(com.datastax.oss.driver.api.core.metadata.Node) KeyspaceMetadata(com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata) Metadata(com.datastax.oss.driver.api.core.metadata.Metadata) UUID(java.util.UUID) CqlSession(com.datastax.oss.driver.api.core.CqlSession) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 13 with Metadata

use of com.datastax.oss.driver.api.core.metadata.Metadata 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);
}
Also used : Node(com.datastax.oss.driver.api.core.metadata.Node) KeyspaceMetadata(com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata) Metadata(com.datastax.oss.driver.api.core.metadata.Metadata) CqlSession(com.datastax.oss.driver.api.core.CqlSession) KeyspaceMetadata(com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata) Test(org.junit.Test)

Example 14 with Metadata

use of com.datastax.oss.driver.api.core.metadata.Metadata in project zipkin by openzipkin.

the class SchemaTest method ensureKeyspaceMetadata_passesWhenVersion3_11_4AndKeyspaceMetadataIsNotNull.

@Test
public void ensureKeyspaceMetadata_passesWhenVersion3_11_4AndKeyspaceMetadataIsNotNull() {
    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.4"));
    when(metadata.getKeyspace("zipkin2")).thenReturn(Optional.of(keyspaceMetadata));
    assertThat(Schema.ensureKeyspaceMetadata(session, "zipkin2")).isSameAs(keyspaceMetadata);
}
Also used : Node(com.datastax.oss.driver.api.core.metadata.Node) KeyspaceMetadata(com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata) Metadata(com.datastax.oss.driver.api.core.metadata.Metadata) CqlSession(com.datastax.oss.driver.api.core.CqlSession) KeyspaceMetadata(com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata) Test(org.junit.Test)

Aggregations

Metadata (com.datastax.oss.driver.api.core.metadata.Metadata)14 CqlSession (com.datastax.oss.driver.api.core.CqlSession)10 Node (com.datastax.oss.driver.api.core.metadata.Node)10 KeyspaceMetadata (com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata)10 Test (org.junit.jupiter.api.Test)6 TableMetadata (com.datastax.oss.driver.api.core.metadata.schema.TableMetadata)5 Test (org.junit.Test)5 Statement (com.datastax.oss.driver.api.core.cql.Statement)4 KeyColumnValueStoreTest (org.janusgraph.diskstorage.KeyColumnValueStoreTest)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 NodeState (com.datastax.oss.driver.api.core.metadata.NodeState)3 ArrayList (java.util.ArrayList)3 UUID (java.util.UUID)2 Health (org.springframework.boot.actuate.health.Health)2 DriverTimeoutException (com.datastax.oss.driver.api.core.DriverTimeoutException)1 Version (com.datastax.oss.driver.api.core.Version)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1