Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix intermittent failure when using cdrs driver #963

Merged
merged 2 commits into from Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -8,7 +8,7 @@ use std::net::SocketAddr;
use std::time::Duration;
use test_helpers::docker_compose::DockerCompose;
use tokio::sync::broadcast;
use tokio::time::{sleep, timeout};
use tokio::time::timeout;

async fn test_rewrite_system_peers(connection: &CassandraConnection) {
let all_columns = "peer, data_center, host_id, preferred_ip, rack, release_version, rpc_address, schema_version, tokens";
Expand Down Expand Up @@ -377,9 +377,6 @@ impl EventConnections {
CassandraConnection::new("127.0.0.1", 9042, CassandraDriver::CdrsTokio).await;
let recv_shotover = shotover.as_cdrs().create_event_receiver();

// let the driver finish connecting to the cluster and registering for the events
sleep(Duration::from_secs(10)).await;

EventConnections {
_direct: direct,
recv_direct,
Expand Down
6 changes: 2 additions & 4 deletions shotover-proxy/tests/cassandra_int_tests/mod.rs
Expand Up @@ -18,7 +18,7 @@ use metrics_util::debugging::DebuggingRecorder;
use rstest::rstest;
use serial_test::serial;
use test_helpers::docker_compose::DockerCompose;
use tokio::time::{sleep, timeout, Duration};
use tokio::time::{timeout, Duration};

mod batch_statements;
mod cache;
Expand Down Expand Up @@ -458,7 +458,7 @@ async fn peers_rewrite_v4(#[case] driver: CassandraDriver) {

#[cfg(feature = "cassandra-cpp-driver-tests")]
#[rstest]
#[case::cdrs(CdrsTokio)]
//#[case::cdrs(CdrsTokio)] // Disabled due to intermittent failure that only occurs on v3
#[case::scylla(Scylla)]
#[cfg_attr(feature = "cassandra-cpp-driver-tests", case::datastax(Datastax))]
#[tokio::test(flavor = "multi_thread")]
Expand Down Expand Up @@ -605,8 +605,6 @@ async fn events_keyspace(#[case] driver: CassandraDriver) {

let mut event_recv = connection.as_cdrs().create_event_receiver();

sleep(Duration::from_secs(10)).await; // let the driver finish connecting to the cluster and registering for the events

let create_ks = "CREATE KEYSPACE IF NOT EXISTS test_events_ks WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };";
connection.execute(create_ks).await;

Expand Down
31 changes: 21 additions & 10 deletions shotover-proxy/tests/helpers/cassandra.rs
Expand Up @@ -40,6 +40,8 @@ use scylla::{QueryResult, Session as SessionScylla, SessionBuilder as SessionBui
use std::fs::read_to_string;
use std::net::IpAddr;
use std::sync::Arc;
use std::time::Duration;
use tokio::time::timeout;

#[derive(Debug)]
pub enum PreparedQuery {
Expand Down Expand Up @@ -142,18 +144,27 @@ impl CassandraConnection {
.map(|contact_point| NodeAddress::from(format!("{contact_point}:{port}")))
.collect::<Vec<NodeAddress>>();

let config = NodeTcpConfigBuilder::new()
.with_contact_points(node_addresses)
.with_authenticator_provider(Arc::new(auth))
.build()
.await
.unwrap();
let config = timeout(
Duration::from_secs(10),
NodeTcpConfigBuilder::new()
.with_contact_points(node_addresses)
.with_authenticator_provider(Arc::new(auth))
.build(),
)
.await
.unwrap()
.unwrap();

let session = TcpSessionBuilder::new(
TopologyAwareLoadBalancingStrategy::new(None, true),
config,
let session = timeout(
Duration::from_secs(10),
TcpSessionBuilder::new(
TopologyAwareLoadBalancingStrategy::new(None, true),
config,
)
.build(),
)
.build()
.await
.unwrap()
.unwrap();
CassandraConnection::CdrsTokio {
session,
Expand Down