Search in sources :

Example 1 with Version

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

the class Schema method applyCqlFile.

static void applyCqlFile(String keyspace, CqlSession session, String resource) {
    Version version = ensureVersion(session.getMetadata());
    for (String cmd : resourceToString(resource).split(";", 100)) {
        cmd = cmd.trim().replace(" " + DEFAULT_KEYSPACE, " " + keyspace);
        if (cmd.isEmpty())
            continue;
        cmd = reviseCQL(version, cmd);
        session.execute(cmd);
    }
}
Also used : Version(com.datastax.oss.driver.api.core.Version) Resources.resourceToString(zipkin2.storage.cassandra.internal.Resources.resourceToString)

Example 2 with Version

use of com.datastax.oss.driver.api.core.Version 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();
}
Also used : Node(com.datastax.oss.driver.api.core.metadata.Node) Status(org.springframework.boot.actuate.health.Status) NodeState(com.datastax.oss.driver.api.core.metadata.NodeState) StepVerifier(reactor.test.StepVerifier) DriverTimeoutException(com.datastax.oss.driver.api.core.DriverTimeoutException) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) HashMap(java.util.HashMap) Mono(reactor.core.publisher.Mono) UUID(java.util.UUID) Health(org.springframework.boot.actuate.health.Health) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) Version(com.datastax.oss.driver.api.core.Version) List(java.util.List) CqlSession(com.datastax.oss.driver.api.core.CqlSession) BDDMockito.given(org.mockito.BDDMockito.given) Map(java.util.Map) Assertions.assertThatIllegalArgumentException(org.assertj.core.api.Assertions.assertThatIllegalArgumentException) Metadata(com.datastax.oss.driver.api.core.metadata.Metadata) Collections(java.util.Collections) Mockito.mock(org.mockito.Mockito.mock) Health(org.springframework.boot.actuate.health.Health) Node(com.datastax.oss.driver.api.core.metadata.Node) Metadata(com.datastax.oss.driver.api.core.metadata.Metadata) CqlSession(com.datastax.oss.driver.api.core.CqlSession) Test(org.junit.jupiter.api.Test)

Example 3 with Version

use of com.datastax.oss.driver.api.core.Version in project spring-boot by spring-projects.

the class CassandraDriverReactiveHealthIndicatorTests method healthWithoutNodeVersionShouldNotAddVersionDetail.

@Test
void healthWithoutNodeVersionShouldNotAddVersionDetail() {
    CqlSession session = mockCqlSessionWithNodeState(NodeState.UP);
    CassandraDriverReactiveHealthIndicator healthIndicator = new CassandraDriverReactiveHealthIndicator(session);
    Mono<Health> health = healthIndicator.health();
    StepVerifier.create(health).consumeNextWith((h) -> {
        assertThat(h.getStatus()).isEqualTo(Status.UP);
        assertThat(h.getDetails().get("version")).isNull();
    }).verifyComplete();
}
Also used : Node(com.datastax.oss.driver.api.core.metadata.Node) Status(org.springframework.boot.actuate.health.Status) NodeState(com.datastax.oss.driver.api.core.metadata.NodeState) StepVerifier(reactor.test.StepVerifier) DriverTimeoutException(com.datastax.oss.driver.api.core.DriverTimeoutException) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) HashMap(java.util.HashMap) Mono(reactor.core.publisher.Mono) UUID(java.util.UUID) Health(org.springframework.boot.actuate.health.Health) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) Version(com.datastax.oss.driver.api.core.Version) List(java.util.List) CqlSession(com.datastax.oss.driver.api.core.CqlSession) BDDMockito.given(org.mockito.BDDMockito.given) Map(java.util.Map) Assertions.assertThatIllegalArgumentException(org.assertj.core.api.Assertions.assertThatIllegalArgumentException) Metadata(com.datastax.oss.driver.api.core.metadata.Metadata) Collections(java.util.Collections) Mockito.mock(org.mockito.Mockito.mock) Health(org.springframework.boot.actuate.health.Health) CqlSession(com.datastax.oss.driver.api.core.CqlSession) Test(org.junit.jupiter.api.Test)

Aggregations

Version (com.datastax.oss.driver.api.core.Version)3 CqlSession (com.datastax.oss.driver.api.core.CqlSession)2 DriverTimeoutException (com.datastax.oss.driver.api.core.DriverTimeoutException)2 Metadata (com.datastax.oss.driver.api.core.metadata.Metadata)2 Node (com.datastax.oss.driver.api.core.metadata.Node)2 NodeState (com.datastax.oss.driver.api.core.metadata.NodeState)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 UUID (java.util.UUID)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Assertions.assertThatIllegalArgumentException (org.assertj.core.api.Assertions.assertThatIllegalArgumentException)2 Test (org.junit.jupiter.api.Test)2 BDDMockito.given (org.mockito.BDDMockito.given)2 Mockito.mock (org.mockito.Mockito.mock)2 Health (org.springframework.boot.actuate.health.Health)2 Status (org.springframework.boot.actuate.health.Status)2 Mono (reactor.core.publisher.Mono)2