Skip to content

Commit

Permalink
fix: normal sqlness
Browse files Browse the repository at this point in the history
  • Loading branch information
discord9 committed Dec 11, 2024
1 parent 6fefa6c commit 6258c4a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
21 changes: 15 additions & 6 deletions tests/runner/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -360,16 +361,14 @@ impl Env {
)
}
"metasrv" => {
let args = vec![
let mut args = vec![
DEFAULT_LOG_LEVEL.to_string(),
subcommand.to_string(),
"start".to_string(),
"--bind-addr".to_string(),
"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(),
Expand All @@ -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}"),
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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,
}
}

Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions tests/runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions tests/runner/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ pub fn setup_etcd(client_ports: Vec<u16>, peer_port: Option<u16>, 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();
Expand Down

0 comments on commit 6258c4a

Please sign in to comment.