Skip to content

Commit

Permalink
cassandra_int_tests test node up
Browse files Browse the repository at this point in the history
  • Loading branch information
rukai committed Nov 18, 2022
1 parent 0f599ee commit 43edfa9
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ services:
MIN_HEAP_SIZE: "400M"
HEAP_NEWSIZE: "48M"
volumes:
# Using volume instead of tmpfs adds 3 seconds to the runtime of the cassandra standard_test_suite but allows running tests that restart nodes
&volumes
- type: tmpfs
- type: volume
target: /var/lib/cassandra
command: &command cassandra -f -Dcassandra.initial_token="$$CASSANDRA_INITIAL_TOKENS" -Dcassandra.native_transport_port=9044

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cluster_name: 'Test Cluster'
#
# If you already have a cluster with 1 token per node, and wish to migrate to
# multiple tokens per node, see http://wiki.apache.org/cassandra/Operations
num_tokens: 256
num_tokens: 128

# Triggers automatic allocation of num_tokens tokens for this node. The allocation
# algorithm attempts to choose tokens in a way that optimizes replicated load over
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cluster_name: 'Test Cluster'
# See https://cassandra.apache.org/doc/latest/getting_started/production.html#tokens for
# best practice information about num_tokens.
#
#num_tokens: 16
num_tokens: 128

# Triggers automatic allocation of num_tokens tokens for this node. The allocation
# algorithm attempts to choose tokens in a way that optimizes replicated load over
Expand All @@ -47,7 +47,7 @@ allocate_tokens_for_local_replication_factor: 3
# vnodes (num_tokens > 1, above) -- in which case you should provide a
# comma-separated list -- it's primarily used when adding nodes to legacy clusters
# that do not have vnodes enabled.
initial_token: 0
#initial_token: 0

# May either be "true" or "false" to enable globally
hinted_handoff_enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cluster_name: 'Test Cluster'
# See https://cassandra.apache.org/doc/latest/getting_started/production.html#tokens for
# best practice information about num_tokens.
#
#num_tokens: 16
num_tokens: 128

# Triggers automatic allocation of num_tokens tokens for this node. The allocation
# algorithm attempts to choose tokens in a way that optimizes replicated load over
Expand All @@ -47,7 +47,7 @@ allocate_tokens_for_local_replication_factor: 3
# vnodes (num_tokens > 1, above) -- in which case you should provide a
# comma-separated list -- it's primarily used when adding nodes to legacy clusters
# that do not have vnodes enabled.
initial_token: 0
#initial_token: 0

# May either be "true" or "false" to enable globally
hinted_handoff_enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ pub async fn test_node_going_down(
.enable_schema_awaiter("172.16.1.2:9044", None)
.await;
// Use Replication 2 in case it ends up on the node that we kill
run_query(&connection_shotover, "CREATE KEYSPACE cluster_single_rack_node_going_down WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 2 };").await;
run_query(&connection_shotover, "CREATE KEYSPACE cluster_single_rack_node_going_down WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };").await;
run_query(&connection_shotover, "CREATE TABLE cluster_single_rack_node_going_down.test_table (pk varchar PRIMARY KEY, col1 int, col2 boolean);").await;

{
Expand Down Expand Up @@ -331,6 +331,14 @@ pub async fn test_node_going_down(

// test that shotover handles preexisting connections after node goes down
test_connection_handles_node_down(&connection_shotover).await;

compose.start_service("cassandra-two");

let new_new_connection = CassandraConnection::new("127.0.0.1", 9042, driver).await;

test_connection_handles_node_down(&new_new_connection).await;
test_connection_handles_node_down(&new_connection).await;
test_connection_handles_node_down(&connection_shotover).await;
}

std::mem::drop(connection_shotover);
Expand Down
11 changes: 11 additions & 0 deletions test-helpers/src/docker_compose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@ impl DockerCompose {
.unwrap();
}

/// Restarts the container with the provided service name
pub fn start_service(&self, service_name: &str) {
run_command(
"docker-compose",
&["-f", &self.file_path, "start", service_name],
)
.unwrap();
// TODO: this is a complete hack, need to land https://github.com/shotover/shotover-proxy/pull/917 before I can implement a better solution
self.wait_for_log("Startup complete", 4);
}

fn wait_for_containers_to_startup(&self) {
match self.file_path.as_ref() {
"tests/transforms/docker-compose-moto.yaml" => {
Expand Down

0 comments on commit 43edfa9

Please sign in to comment.