use of com.datastax.oss.driver.api.testinfra.CassandraRequirement in project java-driver by datastax.
the class ProtocolVersionInitialNegotiationIT method should_use_explicitly_provided_v3_oss.
@CassandraRequirement(min = "2.1", description = "Only C* in [2.1,*[ has V3 supported")
@Test
public void should_use_explicitly_provided_v3_oss() {
Assume.assumeFalse("This test is only for OSS C*", ccm.getDseVersion().isPresent());
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");
}
}
use of com.datastax.oss.driver.api.testinfra.CassandraRequirement in project java-driver by datastax.
the class ProtocolVersionInitialNegotiationIT method should_fail_if_provided_v5_is_not_supported_oss.
@CassandraRequirement(min = "2.1", max = "4.0-rc1", description = "Only C* in [2.1,4.0-rc1[ has V5 unsupported or supported as beta")
@Test
public void should_fail_if_provided_v5_is_not_supported_oss() {
Assume.assumeFalse("This test is only for OSS C*", ccm.getDseVersion().isPresent());
DriverConfigLoader loader = SessionUtils.configLoaderBuilder().withString(DefaultDriverOption.PROTOCOL_VERSION, "V5").build();
try (CqlSession ignored = SessionUtils.newSession(ccm, loader)) {
fail("Expected an AllNodesFailedException");
} catch (AllNodesFailedException anfe) {
Throwable cause = anfe.getAllErrors().values().iterator().next().get(0);
assertThat(cause).isInstanceOf(UnsupportedProtocolVersionException.class);
UnsupportedProtocolVersionException unsupportedException = (UnsupportedProtocolVersionException) cause;
assertThat(unsupportedException.getAttemptedVersions()).containsOnly(DefaultProtocolVersion.V5);
}
}
use of com.datastax.oss.driver.api.testinfra.CassandraRequirement in project java-driver by datastax.
the class ProtocolVersionInitialNegotiationIT method should_use_explicitly_provided_v4_oss.
@CassandraRequirement(min = "2.2", description = "Only C* in [2.2,*[ has V4 supported")
@Test
public void should_use_explicitly_provided_v4_oss() {
Assume.assumeFalse("This test is only for OSS C*", ccm.getDseVersion().isPresent());
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");
}
}
use of com.datastax.oss.driver.api.testinfra.CassandraRequirement in project java-driver by datastax.
the class ProtocolVersionInitialNegotiationIT method should_downgrade_to_v3_oss.
@CassandraRequirement(min = "2.1", max = "2.2", description = "Only C* in [2.1,2.2[ has V3 as its highest version")
@Test
public void should_downgrade_to_v3_oss() {
Assume.assumeFalse("This test is only for OSS C*", ccm.getDseVersion().isPresent());
try (CqlSession session = SessionUtils.newSession(ccm)) {
assertThat(session.getContext().getProtocolVersion().getCode()).isEqualTo(3);
session.execute("select * from system.local");
}
}
use of com.datastax.oss.driver.api.testinfra.CassandraRequirement in project java-driver by datastax.
the class SchemaIT method should_get_virtual_metadata.
@CassandraRequirement(min = "4.0", description = "virtual tables introduced in 4.0")
@Test
public void should_get_virtual_metadata() {
skipIfDse60();
DriverConfigLoader loader = SessionUtils.configLoaderBuilder().withStringList(DefaultDriverOption.METADATA_SCHEMA_REFRESHED_KEYSPACES, Collections.singletonList("system_views")).build();
try (CqlSession session = SessionUtils.newSession(ccmRule, loader)) {
Metadata md = session.getMetadata();
KeyspaceMetadata kmd = md.getKeyspace("system_views").get();
// Keyspace name should be set, marked as virtual, and have at least sstable_tasks table.
// All other values should be defaulted since they are not defined in the virtual schema
// tables.
assertThat(kmd.getTables().size()).isGreaterThanOrEqualTo(1);
assertThat(kmd.isVirtual()).isTrue();
assertThat(kmd.isDurableWrites()).isFalse();
assertThat(kmd.getName().asCql(true)).isEqualTo("system_views");
// Virtual tables lack User Types, Functions, Views and Aggregates
assertThat(kmd.getUserDefinedTypes().size()).isEqualTo(0);
assertThat(kmd.getFunctions().size()).isEqualTo(0);
assertThat(kmd.getViews().size()).isEqualTo(0);
assertThat(kmd.getAggregates().size()).isEqualTo(0);
assertThat(kmd.describe(true)).isEqualTo("/* VIRTUAL KEYSPACE system_views WITH replication = { 'class' : 'null' } " + "AND durable_writes = false; */");
// Table name should be set, marked as virtual, and it should have columns set.
// indexes, views, clustering column, clustering order and id are not defined in the virtual
// schema tables.
TableMetadata tm = kmd.getTable("sstable_tasks").get();
assertThat(tm).isNotNull();
assertThat(tm.getName().toString()).isEqualTo("sstable_tasks");
assertThat(tm.isVirtual()).isTrue();
// DSE 6.8+ reports 7 columns, Cassandra 4+ reports 8 columns
assertThat(tm.getColumns().size()).isGreaterThanOrEqualTo(7);
assertThat(tm.getIndexes().size()).isEqualTo(0);
assertThat(tm.getPartitionKey().size()).isEqualTo(1);
assertThat(tm.getPartitionKey().get(0).getName().toString()).isEqualTo("keyspace_name");
assertThat(tm.getClusteringColumns().size()).isEqualTo(2);
assertThat(tm.getId().isPresent()).isFalse();
assertThat(tm.getOptions().size()).isEqualTo(0);
assertThat(tm.getKeyspace()).isEqualTo(kmd.getName());
assertThat(tm.describe(true)).isIn(// DSE 6.8+
"/* VIRTUAL TABLE system_views.sstable_tasks (\n" + " keyspace_name text,\n" + " table_name text,\n" + " task_id uuid,\n" + " kind text,\n" + " progress bigint,\n" + " total bigint,\n" + " unit text,\n" + " PRIMARY KEY (keyspace_name, table_name, task_id)\n" + "); */", // Cassandra 4.0
"/* VIRTUAL TABLE system_views.sstable_tasks (\n" + " keyspace_name text,\n" + " table_name text,\n" + " task_id uuid,\n" + " completion_ratio double,\n" + " kind text,\n" + " progress bigint,\n" + " total bigint,\n" + " unit text,\n" + " PRIMARY KEY (keyspace_name, table_name, task_id)\n" + "); */");
// ColumnMetadata is as expected
ColumnMetadata cm = tm.getColumn("progress").get();
assertThat(cm).isNotNull();
assertThat(cm.getParent()).isEqualTo(tm.getName());
assertThat(cm.getType()).isEqualTo(DataTypes.BIGINT);
assertThat(cm.getName().toString()).isEqualTo("progress");
}
}
Aggregations