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

cassandra-cluster-tls int test #722

Merged
merged 2 commits into from
Aug 4, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
version: "3.3"
networks:
cluster_subnet:
name: cluster_subnet
driver: bridge
ipam:
driver: default
config:
- subnet: 172.16.1.0/24
gateway: 172.16.1.1

services:
cassandra-one:
image: bitnami/cassandra:3.11
networks:
cluster_subnet:
ipv4_address: 172.16.1.2
healthcheck:
&healthcheck
test: [ "CMD", "cqlsh", "-e", "describe keyspaces" ]
interval: 5s
timeout: 5s
retries: 60
environment:
&environment
CASSANDRA_SEEDS: "cassandra-one,cassandra-two"
CASSANDRA_CLUSTER_NAME: TestCluster
CASSANDRA_DC: dc1
CASSANDRA_RACK: rack1
CASSANDRA_ENDPOINT_SNITCH: GossipingPropertyFileSnitch
CASSANDRA_NUM_TOKENS: 128
MAX_HEAP_SIZE: "400M"
MIN_HEAP_SIZE: "400M"
HEAP_NEWSIZE: "48M"
CASSANDRA_ENABLE_SCRIPTED_USER_DEFINED_FUNCTIONS: "true"
CASSANDRA_ENABLE_USER_DEFINED_FUNCTIONS: "true"
CASSANDRA_KEYSTORE_PASSWORD: "password"
CASSANDRA_TRUSTSTORE_PASSWORD: "password"
CASSANDRA_CLIENT_ENCRYPTION: "true"
volumes:
&volumes
- ../cassandra-tls/certs/keystore.p12:/bitnami/cassandra/secrets/keystore
- ../cassandra-tls/certs/truststore.p12:/bitnami/cassandra/secrets/truststore

cassandra-two:
image: bitnami/cassandra:3.11
networks:
cluster_subnet:
ipv4_address: 172.16.1.3
healthcheck: *healthcheck
environment: *environment
volumes: *volumes

cassandra-three:
image: bitnami/cassandra:3.11
networks:
cluster_subnet:
ipv4_address: 172.16.1.4
healthcheck: *healthcheck
environment: *environment
volumes: *volumes
20 changes: 20 additions & 0 deletions shotover-proxy/example-configs/cassandra-cluster-tls/topology.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
sources:
cassandra_prod:
Cassandra:
listen_addr: "127.0.0.1:9042"
tls:
certificate_authority_path: "example-configs/cassandra-tls/certs/localhost_CA.crt"
certificate_path: "example-configs/cassandra-tls/certs/localhost.crt"
private_key_path: "example-configs/cassandra-tls/certs/localhost.key"
chain_config:
main_chain:
- CassandraSinkCluster:
first_contact_points: ["172.16.1.2:9042", "172.16.1.3:9042"]
data_center: "dc1"
tls:
certificate_authority_path: "example-configs/cassandra-tls/certs/localhost_CA.crt"
certificate_path: "example-configs/cassandra-tls/certs/localhost.crt"
private_key_path: "example-configs/cassandra-tls/certs/localhost.key"
source_to_chain_mapping:
cassandra_prod: main_chain
45 changes: 40 additions & 5 deletions shotover-proxy/tests/cassandra_int_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,40 @@ fn test_passthrough() {
batch_statements::test(&connection);
}

#[test]
#[serial]
fn test_source_tls_and_single_tls() {
test_helpers::cert::generate_cassandra_test_certs();
let _compose = DockerCompose::new("example-configs/cassandra-tls/docker-compose.yml");

let shotover_manager =
ShotoverManager::from_topology_file("example-configs/cassandra-tls/topology.yaml");

let ca_cert = "example-configs/cassandra-tls/certs/localhost_CA.crt";

{
// 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("127.0.0.1", 9042, ca_cert);
assert_query_result(
&direct_connection,
"SELECT bootstrapped FROM system.local",
&[&[ResultValue::Varchar("COMPLETED".into())]],
);
}

let connection = shotover_manager.cassandra_connection_tls("127.0.0.1", 9043, ca_cert);

keyspace::test(&connection);
table::test(&connection);
udt::test(&connection);
native_types::test(&connection);
collections::test(&connection);
functions::test(&connection);
prepared_statements::test(&connection);
batch_statements::test(&connection);
}

#[test]
#[serial]
#[cfg(feature = "alpha-transforms")]
Expand All @@ -70,27 +104,28 @@ fn test_cluster() {

#[test]
#[serial]
fn test_source_tls_and_single_tls() {
#[cfg(feature = "alpha-transforms")]
fn test_source_tls_and_cluster_tls() {
test_helpers::cert::generate_cassandra_test_certs();
let _compose = DockerCompose::new("example-configs/cassandra-tls/docker-compose.yml");
let _compose = DockerCompose::new("example-configs/cassandra-cluster-tls/docker-compose.yml");

let shotover_manager =
ShotoverManager::from_topology_file("example-configs/cassandra-tls/topology.yaml");
ShotoverManager::from_topology_file("example-configs/cassandra-cluster-tls/topology.yaml");

let ca_cert = "example-configs/cassandra-tls/certs/localhost_CA.crt";

{
// Run a quick test straight to Cassandra to check our assumptions that Shotover and Cassandra TLS are behaving exactly the same
rukai marked this conversation as resolved.
Show resolved Hide resolved
let direct_connection =
shotover_manager.cassandra_connection_tls("127.0.0.1", 9042, ca_cert);
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())]],
);
}

let connection = shotover_manager.cassandra_connection_tls("127.0.0.1", 9043, ca_cert);
let connection = shotover_manager.cassandra_connection_tls("127.0.0.1", 9042, ca_cert);

keyspace::test(&connection);
table::test(&connection);
Expand Down
3 changes: 2 additions & 1 deletion test-helpers/src/docker_compose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ impl DockerCompose {
self.wait_for_log("Startup complete", 2, 110)
}
"example-configs-docker/cassandra-peers-rewrite/docker-compose.yml"
| "example-configs/cassandra-cluster/docker-compose.yml" => {
| "example-configs/cassandra-cluster/docker-compose.yml"
| "example-configs/cassandra-cluster-tls/docker-compose.yml" => {
self.wait_for_log("Startup complete", 3, 180)
}
path => unimplemented!(
Expand Down