diff --git a/shotover-proxy/tests/cassandra_int_tests/cluster.rs b/shotover-proxy/tests/cassandra_int_tests/cluster.rs index 6fe0aac75..734b852fb 100644 --- a/shotover-proxy/tests/cassandra_int_tests/cluster.rs +++ b/shotover-proxy/tests/cassandra_int_tests/cluster.rs @@ -1,17 +1,26 @@ use cassandra_protocol::frame::Version; use shotover_proxy::frame::{CassandraFrame, CassandraOperation, Frame}; use shotover_proxy::message::Message; +use shotover_proxy::tls::{TlsConnector, TlsConnectorConfig}; use shotover_proxy::transforms::cassandra::sink_cluster::{create_topology_task, TaskHandshake}; use std::net::IpAddr; use std::sync::Arc; use tokio::sync::{mpsc, RwLock}; -pub async fn test() { +pub async fn test_topology_task(ca_path: Option<&str>) { // Directly test the internal topology task let nodes_shared = Arc::new(RwLock::new(vec![])); let (task_handshake_tx, task_handshake_rx) = mpsc::channel(1); + let tls = ca_path.map(|ca_path| { + TlsConnector::new(TlsConnectorConfig { + certificate_authority_path: ca_path.into(), + certificate_path: None, + private_key_path: None, + }) + .unwrap() + }); create_topology_task( - None, + tls, nodes_shared.clone(), task_handshake_rx, "dc1".to_string(), diff --git a/shotover-proxy/tests/cassandra_int_tests/mod.rs b/shotover-proxy/tests/cassandra_int_tests/mod.rs index 7d34077d7..b29e191fb 100644 --- a/shotover-proxy/tests/cassandra_int_tests/mod.rs +++ b/shotover-proxy/tests/cassandra_int_tests/mod.rs @@ -121,7 +121,7 @@ async fn test_cluster() { native_types::test(&connection2).await; } - cluster::test().await; + cluster::test_topology_task(None).await; } #[tokio::test(flavor = "multi_thread")] @@ -129,38 +129,41 @@ async fn test_cluster() { #[cfg(feature = "alpha-transforms")] async fn test_source_tls_and_cluster_tls() { test_helpers::cert::generate_cassandra_test_certs(); + let ca_cert = "example-configs/cassandra-tls/certs/localhost_CA.crt"; let _compose = DockerCompose::new("example-configs/cassandra-cluster-tls/docker-compose.yml"); + { + let shotover_manager = ShotoverManager::from_topology_file( + "example-configs/cassandra-cluster-tls/topology.yaml", + ); + + { + // Run a quick test straight to Cassandra to check our assumptions that Shotover and Cassandra TLS are behaving exactly the same + let direct_connection = + shotover_manager.cassandra_connection_tls("172.16.1.2", 9042, ca_cert); + assert_query_result( + &direct_connection, + "SELECT bootstrapped FROM system.local", + &[&[ResultValue::Varchar("COMPLETED".into())]], + ) + .await; + } - let shotover_manager = - ShotoverManager::from_topology_file("example-configs/cassandra-cluster-tls/topology.yaml"); - - let ca_cert = "example-configs/cassandra-tls/certs/localhost_CA.crt"; + let mut connection = shotover_manager.cassandra_connection_tls("127.0.0.1", 9042, ca_cert); + connection + .enable_schema_awaiter("172.16.1.2:9042", Some(ca_cert)) + .await; - { - // Run a quick test straight to Cassandra to check our assumptions that Shotover and Cassandra TLS are behaving exactly the same - let direct_connection = - shotover_manager.cassandra_connection_tls("172.16.1.2", 9042, ca_cert); - assert_query_result( - &direct_connection, - "SELECT bootstrapped FROM system.local", - &[&[ResultValue::Varchar("COMPLETED".into())]], - ) - .await; + keyspace::test(&connection).await; + table::test(&connection).await; + udt::test(&connection).await; + native_types::test(&connection).await; + functions::test(&connection).await; + collections::test(&connection).await; + prepared_statements::test(&connection).await; + batch_statements::test(&connection).await; } - let mut connection = shotover_manager.cassandra_connection_tls("127.0.0.1", 9042, ca_cert); - connection - .enable_schema_awaiter("172.16.1.2:9042", Some(ca_cert)) - .await; - - keyspace::test(&connection).await; - table::test(&connection).await; - udt::test(&connection).await; - native_types::test(&connection).await; - functions::test(&connection).await; - collections::test(&connection).await; - prepared_statements::test(&connection).await; - batch_statements::test(&connection).await; + cluster::test_topology_task(Some(ca_cert)).await; } #[tokio::test(flavor = "multi_thread")]