Search in sources :

Example 6 with DseRequirement

use of com.datastax.oss.driver.api.testinfra.DseRequirement in project java-driver by datastax.

the class NodeMetadataIT method should_expose_dse_node_properties.

@Test
@DseRequirement(min = "5.1")
public void should_expose_dse_node_properties() {
    try (CqlSession session = SessionUtils.newSession(ccmRule)) {
        Node node = getUniqueNode(session);
        // Basic checks as we want something that will work with a large range of DSE versions:
        assertThat(node.getExtras()).containsKeys(DseNodeProperties.DSE_VERSION, DseNodeProperties.DSE_WORKLOADS, DseNodeProperties.SERVER_ID);
        assertThat(node.getExtras().get(DseNodeProperties.DSE_VERSION)).isEqualTo(ccmRule.getDseVersion().get());
        assertThat(node.getExtras().get(DseNodeProperties.SERVER_ID)).isInstanceOf(String.class);
        assertThat(node.getExtras().get(DseNodeProperties.DSE_WORKLOADS)).isInstanceOf(Set.class);
    }
}
Also used : Node(com.datastax.oss.driver.api.core.metadata.Node) CqlSession(com.datastax.oss.driver.api.core.CqlSession) DseRequirement(com.datastax.oss.driver.api.testinfra.DseRequirement) Test(org.junit.Test)

Example 7 with DseRequirement

use of com.datastax.oss.driver.api.testinfra.DseRequirement in project java-driver by datastax.

the class CcmPaxExam method run.

@Override
public void run(RunNotifier notifier) {
    Description description = getDescription();
    CassandraRequirement cassandraRequirement = description.getAnnotation(CassandraRequirement.class);
    if (cassandraRequirement != null) {
        if (!cassandraRequirement.min().isEmpty()) {
            Version minVersion = Objects.requireNonNull(Version.parse(cassandraRequirement.min()));
            if (minVersion.compareTo(CCM_BRIDGE.getCassandraVersion()) > 0) {
                fireRequirementsNotMet(notifier, description, cassandraRequirement.min(), false, false);
                return;
            }
        }
        if (!cassandraRequirement.max().isEmpty()) {
            Version maxVersion = Objects.requireNonNull(Version.parse(cassandraRequirement.max()));
            if (maxVersion.compareTo(CCM_BRIDGE.getCassandraVersion()) <= 0) {
                fireRequirementsNotMet(notifier, description, cassandraRequirement.max(), true, false);
                return;
            }
        }
    }
    DseRequirement dseRequirement = description.getAnnotation(DseRequirement.class);
    if (dseRequirement != null) {
        Optional<Version> dseVersionOption = CCM_BRIDGE.getDseVersion();
        if (!dseVersionOption.isPresent()) {
            notifier.fireTestAssumptionFailed(new Failure(description, new AssumptionViolatedException("Test Requires DSE but C* is configured.")));
            return;
        } else {
            Version dseVersion = dseVersionOption.get();
            if (!dseRequirement.min().isEmpty()) {
                Version minVersion = Objects.requireNonNull(Version.parse(dseRequirement.min()));
                if (minVersion.compareTo(dseVersion) > 0) {
                    fireRequirementsNotMet(notifier, description, dseRequirement.min(), false, true);
                    return;
                }
            }
            if (!dseRequirement.max().isEmpty()) {
                Version maxVersion = Objects.requireNonNull(Version.parse(dseRequirement.max()));
                if (maxVersion.compareTo(dseVersion) <= 0) {
                    fireRequirementsNotMet(notifier, description, dseRequirement.min(), true, true);
                    return;
                }
            }
        }
    }
    super.run(notifier);
}
Also used : Description(org.junit.runner.Description) DseRequirement(com.datastax.oss.driver.api.testinfra.DseRequirement) Version(com.datastax.oss.driver.api.core.Version) AssumptionViolatedException(org.junit.AssumptionViolatedException) CassandraRequirement(com.datastax.oss.driver.api.testinfra.CassandraRequirement) Failure(org.junit.runner.notification.Failure)

Example 8 with DseRequirement

use of com.datastax.oss.driver.api.testinfra.DseRequirement in project java-driver by datastax.

the class ProtocolVersionInitialNegotiationIT method should_use_explicitly_provided_v5_dse.

@DseRequirement(min = "7.0", description = "Only DSE in [7.0,*[ has V5 supported")
@Test
public void should_use_explicitly_provided_v5_dse() {
    DriverConfigLoader loader = SessionUtils.configLoaderBuilder().withString(DefaultDriverOption.PROTOCOL_VERSION, "V5").build();
    try (CqlSession session = SessionUtils.newSession(ccm, loader)) {
        assertThat(session.getContext().getProtocolVersion().getCode()).isEqualTo(5);
        session.execute("select * from system.local");
    }
}
Also used : DriverConfigLoader(com.datastax.oss.driver.api.core.config.DriverConfigLoader) CqlSession(com.datastax.oss.driver.api.core.CqlSession) DseRequirement(com.datastax.oss.driver.api.testinfra.DseRequirement) Test(org.junit.Test)

Example 9 with DseRequirement

use of com.datastax.oss.driver.api.testinfra.DseRequirement in project java-driver by datastax.

the class ProtocolVersionInitialNegotiationIT method should_use_explicitly_provided_v4_dse.

@DseRequirement(min = "5.0", description = "Only DSE in [5.0,*[ has V4 supported")
@Test
public void should_use_explicitly_provided_v4_dse() {
    DriverConfigLoader loader = SessionUtils.configLoaderBuilder().withString(DefaultDriverOption.PROTOCOL_VERSION, "V4").build();
    try (CqlSession session = SessionUtils.newSession(ccm, loader)) {
        assertThat(session.getContext().getProtocolVersion().getCode()).isEqualTo(4);
        session.execute("select * from system.local");
    }
}
Also used : DriverConfigLoader(com.datastax.oss.driver.api.core.config.DriverConfigLoader) CqlSession(com.datastax.oss.driver.api.core.CqlSession) DseRequirement(com.datastax.oss.driver.api.testinfra.DseRequirement) Test(org.junit.Test)

Example 10 with DseRequirement

use of com.datastax.oss.driver.api.testinfra.DseRequirement in project java-driver by datastax.

the class ProtocolVersionInitialNegotiationIT method should_use_explicitly_provided_v3_dse.

@DseRequirement(min = "4.8", description = "Only DSE in [4.8,*[ has V3 supported")
@Test
public void should_use_explicitly_provided_v3_dse() {
    DriverConfigLoader loader = SessionUtils.configLoaderBuilder().withString(DefaultDriverOption.PROTOCOL_VERSION, "V3").build();
    try (CqlSession session = SessionUtils.newSession(ccm, loader)) {
        assertThat(session.getContext().getProtocolVersion().getCode()).isEqualTo(3);
        session.execute("select * from system.local");
    }
}
Also used : DriverConfigLoader(com.datastax.oss.driver.api.core.config.DriverConfigLoader) CqlSession(com.datastax.oss.driver.api.core.CqlSession) DseRequirement(com.datastax.oss.driver.api.testinfra.DseRequirement) Test(org.junit.Test)

Aggregations

DseRequirement (com.datastax.oss.driver.api.testinfra.DseRequirement)12 CqlSession (com.datastax.oss.driver.api.core.CqlSession)10 Test (org.junit.Test)10 DriverConfigLoader (com.datastax.oss.driver.api.core.config.DriverConfigLoader)5 Version (com.datastax.oss.driver.api.core.Version)2 CassandraRequirement (com.datastax.oss.driver.api.testinfra.CassandraRequirement)2 AssumptionViolatedException (org.junit.AssumptionViolatedException)2 DefaultProtocolVersion (com.datastax.oss.driver.api.core.DefaultProtocolVersion)1 ProtocolVersion (com.datastax.oss.driver.api.core.ProtocolVersion)1 Node (com.datastax.oss.driver.api.core.metadata.Node)1 Description (org.junit.runner.Description)1 Failure (org.junit.runner.notification.Failure)1 Statement (org.junit.runners.model.Statement)1