From f72b949243ef45b4ef85f76022e21ee64b786269 Mon Sep 17 00:00:00 2001 From: Shachar Langbeheim Date: Sun, 18 Jun 2023 17:55:20 +0000 Subject: [PATCH] Increase timeout for cluster creation. In some tests that failed, the server was ready only after 15 seconds. --- babushka-core/tests/utilities/cluster.rs | 30 ++++++++++++++++-------- babushka-core/tests/utilities/mod.rs | 1 - utils/cluster_manager.py | 2 +- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/babushka-core/tests/utilities/cluster.rs b/babushka-core/tests/utilities/cluster.rs index fab17a005a..8ec12c099a 100644 --- a/babushka-core/tests/utilities/cluster.rs +++ b/babushka-core/tests/utilities/cluster.rs @@ -69,8 +69,8 @@ impl RedisCluster { script_args.push("-r"); script_args.push(&replicas_num); } - let output: String = Self::execute_cluster_script(script_args, use_tls, None); - let (cluster_folder, addresses) = Self::parse_start_script_output(&output); + let (stdout, stderr) = Self::execute_cluster_script(script_args, use_tls, None); + let (cluster_folder, addresses) = Self::parse_start_script_output(&stdout, &stderr); let mut password: Option = None; if let Some(info) = conn_info { password = info.password.clone(); @@ -83,19 +83,21 @@ impl RedisCluster { } } - fn parse_start_script_output(output: &str) -> (String, Vec) { + fn parse_start_script_output(output: &str, errors: &str) -> (String, Vec) { let cluster_folder = output.split("CLUSTER_FOLDER=").collect::>(); assert!( !cluster_folder.is_empty() && cluster_folder.len() >= 2, - "{:?}", - cluster_folder + "Received output: {output}, stderr: {errors}" ); let cluster_folder = cluster_folder.get(1).unwrap().lines(); let cluster_folder = cluster_folder.collect::>(); let cluster_folder = cluster_folder.first().unwrap().to_string(); let output_parts = output.split("CLUSTER_NODES=").collect::>(); - assert!(!output_parts.is_empty() && output_parts.len() >= 2); + assert!( + !output_parts.is_empty() && output_parts.len() >= 2, + "Received output: {output}, stderr: {errors}" + ); let nodes = output_parts.get(1).unwrap().split(','); let mut address_vec: Vec = Vec::new(); for node in nodes { @@ -108,7 +110,11 @@ impl RedisCluster { (cluster_folder, address_vec) } - fn execute_cluster_script(args: Vec<&str>, use_tls: bool, password: Option) -> String { + fn execute_cluster_script( + args: Vec<&str>, + use_tls: bool, + password: Option, + ) -> (String, String) { let python_binary = which("python3").unwrap(); let mut script_path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")); script_path.push("../utils/cluster_manager.py"); @@ -137,11 +143,15 @@ impl RedisCluster { .output() .expect("failed to execute process") }; - let parsed_output = output.stdout; - std::str::from_utf8(&parsed_output) + let parsed_stdout = std::str::from_utf8(&output.stdout) + .unwrap() + .trim() + .to_string(); + let parsed_stderr = std::str::from_utf8(&output.stderr) .unwrap() .trim() - .to_string() + .to_string(); + (parsed_stdout, parsed_stderr) } pub fn get_server_addresses(&self) -> Vec { diff --git a/babushka-core/tests/utilities/mod.rs b/babushka-core/tests/utilities/mod.rs index b568f4b35f..81abe7a938 100644 --- a/babushka-core/tests/utilities/mod.rs +++ b/babushka-core/tests/utilities/mod.rs @@ -466,7 +466,6 @@ where } pub async fn setup_acl(addr: &ConnectionAddr, connection_info: &RedisConnectionInfo) { - println!("setup acl!"); let client = redis::Client::open(redis::ConnectionInfo { addr: addr.clone(), redis: RedisConnectionInfo::default(), diff --git a/utils/cluster_manager.py b/utils/cluster_manager.py index 28712fe820..f03cace898 100644 --- a/utils/cluster_manager.py +++ b/utils/cluster_manager.py @@ -379,7 +379,7 @@ def create_cluster( stderr=subprocess.PIPE, text=True, ) - output, err = p.communicate(timeout=10) + output, err = p.communicate(timeout=20) if err or "[OK] All 16384 slots covered." not in output: raise Exception(f"Failed to create cluster: {err if err else output}")