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

test test_topology_task in TLS mode #754

Merged
merged 2 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions shotover-proxy/tests/cassandra_int_tests/cluster.rs
Original file line number Diff line number Diff line change
@@ -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(),
Expand Down
59 changes: 31 additions & 28 deletions shotover-proxy/tests/cassandra_int_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,46 +121,49 @@ async fn test_cluster() {
native_types::test(&connection2).await;
}

cluster::test().await;
cluster::test_topology_task(None).await;
}

#[tokio::test(flavor = "multi_thread")]
#[serial]
#[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")]
Expand Down