Skip to content

Commit

Permalink
chore: remove '--mode'
Browse files Browse the repository at this point in the history
  • Loading branch information
zyy17 committed Nov 5, 2023
1 parent 95c368c commit 6ed4f83
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 48 deletions.
74 changes: 31 additions & 43 deletions tests/runner/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const DEFAULT_LOG_LEVEL: &str = "--log-level=debug,hyper=warn,tower=warn,datafus
pub struct Env {
data_home: PathBuf,
server_addr: Option<String>,
specified_mode: String,
}

#[allow(clippy::print_stdout)]
Expand All @@ -56,53 +55,43 @@ impl EnvController for Env {
async fn start(&self, mode: &str, _config: Option<&Path>) -> Self::DB {
match mode {
"standalone" => {
if self.specified_mode == "all" || self.specified_mode == "standalone" {
if let Some(server_addr) = self.server_addr.clone() {
let client = Client::with_urls(vec![server_addr.clone()]);
let db = DB::new(DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME, client);
GreptimeDB {
client: TokioMutex::new(db),
server_processes: None,
metasrv_process: None,
frontend_process: None,
ctx: GreptimeDBContext {
time: 0,
datanode_id: Default::default(),
},
is_standalone: false,
env: self.clone(),
}
} else {
self.start_standalone().await
if let Some(server_addr) = self.server_addr.clone() {
let client = Client::with_urls(vec![server_addr.clone()]);
let db = DB::new(DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME, client);
GreptimeDB {
client: TokioMutex::new(db),
server_processes: None,
metasrv_process: None,
frontend_process: None,
ctx: GreptimeDBContext {
time: 0,
datanode_id: Default::default(),
},
is_standalone: false,
env: self.clone(),
}
} else {
// Exit and do nothing.
std::process::exit(0);
self.start_standalone().await
}
}
"distributed" => {
if self.specified_mode == "all" || self.specified_mode == "distributed" {
if let Some(server_addr) = self.server_addr.clone() {
let client = Client::with_urls(vec![server_addr.clone()]);
let db = DB::new(DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME, client);
GreptimeDB {
client: TokioMutex::new(db),
server_processes: None,
metasrv_process: None,
frontend_process: None,
ctx: GreptimeDBContext {
time: 0,
datanode_id: Default::default(),
},
is_standalone: false,
env: self.clone(),
}
} else {
self.start_distributed().await
if let Some(server_addr) = self.server_addr.clone() {
let client = Client::with_urls(vec![server_addr.clone()]);
let db = DB::new(DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME, client);
GreptimeDB {
client: TokioMutex::new(db),
server_processes: None,
metasrv_process: None,
frontend_process: None,
ctx: GreptimeDBContext {
time: 0,
datanode_id: Default::default(),
},
is_standalone: false,
env: self.clone(),
}
} else {
// Exit and do nothing.
std::process::exit(0);
self.start_distributed().await
}
}
_ => panic!("Unexpected mode: {mode}"),
Expand All @@ -117,11 +106,10 @@ impl EnvController for Env {

#[allow(clippy::print_stdout)]
impl Env {
pub fn new(data_home: PathBuf, server_addr: Option<String>, specified_mode: String) -> Self {
pub fn new(data_home: PathBuf, server_addr: Option<String>) -> Self {
Self {
data_home,
server_addr,
specified_mode,
}
}

Expand Down
6 changes: 1 addition & 5 deletions tests/runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ struct Args {
/// Address of the server
#[clap(short, long)]
server_addr: Option<String>,

/// Test mode, can be 'all', 'standalone' and 'distributed'.
#[clap(short, long, default_value = "all")]
mode: String,
}

#[tokio::main]
Expand All @@ -67,6 +63,6 @@ async fn main() {
.env_config_file(args.env_config_file)
.build()
.unwrap();
let runner = Runner::new(config, Env::new(data_home, args.server_addr, args.mode));
let runner = Runner::new(config, Env::new(data_home, args.server_addr));
runner.run().await.unwrap();
}

0 comments on commit 6ed4f83

Please sign in to comment.