From 6258c4a3f639ca6462209752888c7159bf132e86 Mon Sep 17 00:00:00 2001 From: discord9 Date: Wed, 11 Dec 2024 11:30:10 +0800 Subject: [PATCH] fix: normal sqlness --- tests/runner/src/env.rs | 21 +++++++++++++++------ tests/runner/src/main.rs | 6 ++++-- tests/runner/src/util.rs | 4 ++-- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/tests/runner/src/env.rs b/tests/runner/src/env.rs index 86afea0ca63b..6ed1152ab618 100644 --- a/tests/runner/src/env.rs +++ b/tests/runner/src/env.rs @@ -135,7 +135,7 @@ impl Env { self.build_db(); self.setup_wal(); - let db_ctx = GreptimeDBContext::new(self.wal.clone()); + let db_ctx = GreptimeDBContext::new(self.wal.clone(), self.store_config.clone()); let server_process = self.start_server("standalone", &db_ctx, true).await; @@ -156,7 +156,7 @@ impl Env { self.setup_wal(); self.setup_etcd(); - let db_ctx = GreptimeDBContext::new(self.wal.clone()); + let db_ctx = GreptimeDBContext::new(self.wal.clone(), self.store_config.clone()); // start a distributed GreptimeDB let meta_server = self.start_server("metasrv", &db_ctx, true).await; @@ -263,6 +263,7 @@ impl Env { time: 0, datanode_id: Default::default(), wal: self.wal.clone(), + store_config: self.store_config.clone(), }, is_standalone: false, env: self.clone(), @@ -360,7 +361,7 @@ impl Env { ) } "metasrv" => { - let args = vec![ + let mut args = vec![ DEFAULT_LOG_LEVEL.to_string(), subcommand.to_string(), "start".to_string(), @@ -368,8 +369,6 @@ impl Env { "127.0.0.1:29302".to_string(), "--server-addr".to_string(), "127.0.0.1:29302".to_string(), - // "--backend".to_string(), - //"memory-store".to_string(), "--enable-region-failover".to_string(), "false".to_string(), "--http-addr=127.0.0.1:29502".to_string(), @@ -380,6 +379,9 @@ impl Env { "-c".to_string(), self.generate_config_file(subcommand, db_ctx), ]; + if !db_ctx.store_config().setup_etcd { + args.extend(vec!["--backend".to_string(), "memory-store".to_string()]) + } (args, vec![METASRV_ADDR.to_string()]) } _ => panic!("Unexpected subcommand: {subcommand}"), @@ -512,6 +514,7 @@ impl Env { .replace(metasrv); // wait for metasrv to start + // since it seems older version of db might take longer to complete election tokio::time::sleep(Duration::from_secs(5)).await; } @@ -871,14 +874,16 @@ struct GreptimeDBContext { time: i64, datanode_id: AtomicU32, wal: WalConfig, + store_config: StoreConfig, } impl GreptimeDBContext { - pub fn new(wal: WalConfig) -> Self { + pub fn new(wal: WalConfig, store_config: StoreConfig) -> Self { Self { time: common_time::util::current_time_millis(), datanode_id: AtomicU32::new(0), wal, + store_config, } } @@ -906,6 +911,10 @@ impl GreptimeDBContext { fn reset_datanode_id(&self) { self.datanode_id.store(0, Ordering::Relaxed); } + + fn store_config(&self) -> StoreConfig { + self.store_config.clone() + } } struct ResultDisplayer { diff --git a/tests/runner/src/main.rs b/tests/runner/src/main.rs index aed0de953531..8ce2f7213030 100644 --- a/tests/runner/src/main.rs +++ b/tests/runner/src/main.rs @@ -171,8 +171,10 @@ async fn main() { // clean up and exit if !args.preserve_state { - println!("Stopping etcd"); - util::stop_etcd(); + if args.setup_etcd { + println!("Stopping etcd"); + util::stop_rm_etcd(); + } println!("Removing state in {:?}", sqlness_home); tokio::fs::remove_dir_all(sqlness_home).await.unwrap(); } diff --git a/tests/runner/src/util.rs b/tests/runner/src/util.rs index 9dd0bf4eb1c9..1376bfbcdcab 100644 --- a/tests/runner/src/util.rs +++ b/tests/runner/src/util.rs @@ -279,8 +279,8 @@ pub fn setup_etcd(client_ports: Vec, peer_port: Option, etcd_version: } } -/// Stop the etcd container -pub fn stop_etcd() { +/// Stop and remove the etcd container +pub fn stop_rm_etcd() { let status = std::process::Command::new("docker") .args(["container", "stop", "etcd"]) .status();