Skip to content

Commit

Permalink
Merge branch 'main' into remove_unused_messagevalue
Browse files Browse the repository at this point in the history
  • Loading branch information
rukai authored Sep 6, 2022
2 parents 1a1205e + 04a744e commit 728f0b7
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 30 deletions.
1 change: 0 additions & 1 deletion docs/src/examples/cassandra-cluster-shotover-sidecar.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ and use the same query again. You should see the following results returned, not

If everything has worked, you will be able to use Cassandra, with your connection going through Shotover!


#### Adding Rate Limiting

The next section of this tutorial will cover adding rate limiting to your Cassandra cluster with Shotover. We will add the `RequestThrottling` transform to our `topology.yaml` as shown below. This transform should go at the front of the chain to prevent any unnecessary operations from occurring if a query is going to be rate limited.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,33 @@ networks:

services:
cassandra-one:
image: bitnami/cassandra:4.0
image: bitnami/cassandra:4.0.6
networks:
cassandra_subnet:
ipv4_address: 172.16.1.2
healthcheck: &healthcheck
healthcheck:
&healthcheck
test: [ "CMD", "cqlsh", "-e", "describe keyspaces" ]
interval: 5s
timeout: 5s
retries: 60
environment: &environment
environment:
&environment
CASSANDRA_SEEDS: "cassandra-one,cassandra-two"
MAX_HEAP_SIZE: "400M"
MIN_HEAP_SIZE: "400M"
HEAP_NEWSIZE: "48M"

cassandra-two:
image: bitnami/cassandra:4.0
image: bitnami/cassandra:4.0.6
networks:
cassandra_subnet:
ipv4_address: 172.16.1.3
healthcheck: *healthcheck
environment: *environment

cassandra-three:
image: bitnami/cassandra:4.0
image: bitnami/cassandra:4.0.6
networks:
cassandra_subnet:
ipv4_address: 172.16.1.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ networks:

services:
cassandra-one:
image: bitnami/cassandra:3.11
image: bitnami/cassandra:4.0.6
networks:
cluster_subnet:
ipv4_address: 172.16.1.2
Expand All @@ -35,7 +35,7 @@ services:
CASSANDRA_ENABLE_USER_DEFINED_FUNCTIONS: "true"

cassandra-two:
image: bitnami/cassandra:3.11
image: bitnami/cassandra:4.0.6
networks:
cluster_subnet:
ipv4_address: 172.16.1.3
Expand All @@ -54,7 +54,7 @@ services:
CASSANDRA_ENABLE_USER_DEFINED_FUNCTIONS: "true"

cassandra-three:
image: bitnami/cassandra:3.11
image: bitnami/cassandra:4.0.6
networks:
cluster_subnet:
ipv4_address: 172.16.1.4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.3"
services:
cassandra-one:
image: bitnami/cassandra:3.11
image: bitnami/cassandra:4.0.6
ports:
- "9043:9042"
environment:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.3"
services:
cassandra-one:
image: bitnami/cassandra:3.11
image: bitnami/cassandra:4.0.6
ports:
- "9043:9042"
environment:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.3"
services:
cassandra-one:
image: bitnami/cassandra:3.11
image: bitnami/cassandra:4.0.6
ports:
- "9043:9042"
environment:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
ports:
- "6379:6379"
cassandra-one:
image: bitnami/cassandra:3.11
image: bitnami/cassandra:4.0.6
ports:
- "9043:9042"
environment:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.3"
services:
cassandra-one:
image: bitnami/cassandra:3.11
image: bitnami/cassandra:4.0.6
ports:
- "9043:9042"
environment:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.3"
services:
cassandra-one:
image: bitnami/cassandra:3.11
image: bitnami/cassandra:4.0.6
ports:
- "9042:9042"
environment:
Expand Down
72 changes: 61 additions & 11 deletions shotover-proxy/tests/cassandra_int_tests/cluster_multi_rack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async fn test_rewrite_system_peers(connection: &CassandraConnection) {
ResultValue::Inet("255.255.255.255".into()),
// rack is non-determistic because we dont know which node this will be
ResultValue::Any,
ResultValue::Varchar("3.11.13".into()),
ResultValue::Varchar("4.0.6".into()),
ResultValue::Inet("255.255.255.255".into()),
// schema_version is non deterministic so we cant assert on it.
ResultValue::Any,
Expand All @@ -26,7 +26,7 @@ async fn test_rewrite_system_peers(connection: &CassandraConnection) {
ResultValue::Any,
ResultValue::Inet("255.255.255.255".into()),
ResultValue::Any,
ResultValue::Varchar("3.11.13".into()),
ResultValue::Varchar("4.0.6".into()),
ResultValue::Inet("255.255.255.255".into()),
// schema_version is non deterministic so we cant assert on it.
ResultValue::Any,
Expand Down Expand Up @@ -59,40 +59,89 @@ async fn test_rewrite_system_peers(connection: &CassandraConnection) {
.await;
}

async fn test_rewrite_system_peers_v2(connection: &CassandraConnection) {
let star_results = [
// peer is non-determistic because we dont know which node this will be
ResultValue::Any,
ResultValue::Int(7000),
ResultValue::Varchar("dc1".into()),
// host_id is non-determistic because we dont know which node this will be
ResultValue::Any,
// native_address is non-determistic because we dont know which node this will be
ResultValue::Any,
ResultValue::Int(9042),
ResultValue::Inet("255.255.255.255".into()),
ResultValue::Int(-1),
// rack is non-determistic because we dont know which node this will be
ResultValue::Any,
ResultValue::Varchar("4.0.6".into()),
// schema_version is non deterministic so we cant assert on it.
ResultValue::Any,
// Unfortunately token generation appears to be non-deterministic but we can at least assert that
// there are 128 tokens per node
ResultValue::Set(std::iter::repeat(ResultValue::Any).take(128).collect()),
];

let all_columns = "peer, peer_port, data_center, host_id, native_address, native_port, preferred_ip, preferred_port, rack, release_version, schema_version, tokens";
assert_query_result(
connection,
"SELECT * FROM system.peers_v2;",
&[&star_results, &star_results],
)
.await;
assert_query_result(
connection,
&format!("SELECT {all_columns} FROM system.peers_v2;"),
&[&star_results, &star_results],
)
.await;
assert_query_result(
connection,
&format!("SELECT {all_columns}, {all_columns} FROM system.peers_v2;"),
&[
&[star_results.as_slice(), star_results.as_slice()].concat(),
&[star_results.as_slice(), star_results.as_slice()].concat(),
],
)
.await;
}

async fn test_rewrite_system_local(connection: &CassandraConnection) {
let star_results = [
ResultValue::Varchar("local".into()),
ResultValue::Varchar("COMPLETED".into()),
// broadcast address is non-deterministic because we dont know which node this will be
ResultValue::Any,
ResultValue::Int(7000),
ResultValue::Varchar("TestCluster".into()),
ResultValue::Varchar("3.4.4".into()),
ResultValue::Varchar("3.4.5".into()),
ResultValue::Varchar("dc1".into()),
// gossip_generation is non deterministic cant assert on it
ResultValue::Any,
// host_id is non-deterministic because we dont know which node this will be
ResultValue::Any,
ResultValue::Inet("127.0.0.1".parse().unwrap()),
ResultValue::Varchar("4".into()),
ResultValue::Int(7000),
ResultValue::Varchar("5".into()),
ResultValue::Varchar("org.apache.cassandra.dht.Murmur3Partitioner".into()),
// rack is non-deterministic because we dont know which node this will be
ResultValue::Any,
ResultValue::Varchar("3.11.13".into()),
ResultValue::Varchar("4.0.6".into()),
ResultValue::Inet("0.0.0.0".parse().unwrap()),
ResultValue::Int(9042),
// schema_version is non deterministic so we cant assert on it.
ResultValue::Any,
// thrift_version isnt used anymore so I dont really care what it maps to
ResultValue::Any,
// Unfortunately token generation appears to be non-deterministic but we can at least assert that
// there are 128 tokens per node
ResultValue::Set(std::iter::repeat(ResultValue::Any).take(128).collect()),
ResultValue::Map(vec![]),
// truncated_at is non deterministic so we cant assert on it.
ResultValue::Any,
];

let all_columns =
"key, bootstrapped, broadcast_address, cluster_name, cql_version, data_center,
gossip_generation, host_id, listen_address, native_protocol_version, partitioner, rack,
release_version, rpc_address, schema_version, thrift_version, tokens, truncated_at";
"key, bootstrapped, broadcast_address, broadcast_port, cluster_name, cql_version, data_center,
gossip_generation, host_id, listen_address, listen_port, native_protocol_version, partitioner, rack,
release_version, rpc_address, rpc_port, schema_version, tokens, truncated_at";

assert_query_result(connection, "SELECT * FROM system.local;", &[&star_results]).await;
assert_query_result(
Expand All @@ -112,6 +161,7 @@ async fn test_rewrite_system_local(connection: &CassandraConnection) {
pub async fn test(connection: &CassandraConnection) {
test_rewrite_system_local(connection).await;
test_rewrite_system_peers(connection).await;
test_rewrite_system_peers_v2(connection).await;
}

pub async fn test_topology_task(ca_path: Option<&str>) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.3"
services:
cassandra-one:
image: bitnami/cassandra:3.11
image: bitnami/cassandra:4.0.6
ports:
- "9043:9042"
environment:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.3"
services:
cassandra-one:
image: bitnami/cassandra:3.11
image: bitnami/cassandra:4.0.6
ports:
- "9043:9042"
environment:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ networks:

services:
cassandra-one:
image: bitnami/cassandra:4.0
image: bitnami/cassandra:4.0.6
networks:
cluster_subnet:
ipv4_address: 172.16.1.2
Expand All @@ -36,7 +36,7 @@ services:
CASSANDRA_ENABLE_USER_DEFINED_FUNCTIONS: "true"

cassandra-two:
image: bitnami/cassandra:4.0
image: bitnami/cassandra:4.0.6
networks:
cluster_subnet:
ipv4_address: 172.16.1.3
Expand Down

0 comments on commit 728f0b7

Please sign in to comment.