use of com.datastax.oss.simulacron.server.BoundCluster in project java-driver by datastax.
the class ProtocolVersionMixedClusterIT method should_not_downgrade_and_force_down_old_nodes_if_version_forced.
@Test
public void should_not_downgrade_and_force_down_old_nodes_if_version_forced() {
DriverConfigLoader loader = SessionUtils.configLoaderBuilder().withString(DefaultDriverOption.PROTOCOL_VERSION, "V4").withBoolean(DefaultDriverOption.METADATA_SCHEMA_ENABLED, false).build();
try (BoundCluster simulacron = mixedVersions("3.0.0", "2.2.0", "2.0.0");
BoundNode contactPoint = simulacron.node(0);
CqlSession session = (CqlSession) SessionUtils.baseBuilder().addContactPoint(contactPoint.inetSocketAddress()).withConfigLoader(loader).build()) {
assertThat(session.getContext().getProtocolVersion()).isEqualTo(DefaultProtocolVersion.V4);
assertThat(queries(simulacron)).hasSize(4);
assertThat(protocolQueries(contactPoint, 4)).containsExactly(// Initial connection with protocol v4
"SELECT cluster_name FROM system.local", "SELECT * FROM system.local", "SELECT * FROM system.peers_v2", "SELECT * FROM system.peers");
// Note: the 2.0.0 would be forced down if we try to open a connection to it. We can't check
// that here because Simulacron can't prime STARTUP requests.
}
}
use of com.datastax.oss.simulacron.server.BoundCluster in project java-driver by datastax.
the class ProtocolVersionMixedClusterIT method should_fail_if_peer_does_not_support_v3.
@Test
public void should_fail_if_peer_does_not_support_v3() {
Throwable t = catchThrowable(() -> {
try (BoundCluster simulacron = mixedVersions("3.0.0", "2.0.9", "3.11");
BoundNode contactPoint = simulacron.node(0);
CqlSession ignored = (CqlSession) SessionUtils.baseBuilder().addContactPoint(contactPoint.inetSocketAddress()).build()) {
fail("Cluster init should have failed");
}
});
assertThat(t).isInstanceOf(UnsupportedProtocolVersionException.class).hasMessageContaining("reports Cassandra version 2.0.9, but the driver only supports 2.1.0 and above");
}
Aggregations