Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: support set log file when running test harness #314

Merged
merged 2 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/harness.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
bind_addr = "0.0.0.0"
http_port = 5440
grpc_port = 8831
log_level = "info"
log_level = "debug"
enable_cluster = true

[query]
Expand Down
2 changes: 2 additions & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export CERESDB_CONFIG_PATH ?= $(ROOT)/../docs/harness.toml
export CERESDB_SERVER_ENDPOINT ?= 127.0.0.1:8831
export CERESDB_TEST_CASE_PATH ?= $(ROOT)/cases
export CERESDB_TEST_HARNESS ?= $(ROOT)/../target/$(MODE)/ceresdb-test
export CERESDB_STDOUT_FILE ?= /tmp/ceresdb-stdout.log
export CERESDB_STDERR_FILE ?= /tmp/ceresdb-stderr.log

clean:
rm -rf $(DATA_DIR)
Expand Down
14 changes: 10 additions & 4 deletions tests/harness/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

use std::{
env,
process::{Child, Command, Stdio},
fs::File,
process::{Child, Command},
};

use ceresdb_client_rs::{client::Client, Builder};
Expand All @@ -11,6 +12,8 @@ const BINARY_PATH_ENV: &str = "CERESDB_BINARY_PATH";
const CONFIG_PATH_ENV: &str = "CERESDB_CONFIG_PATH";
const SERVER_ENDPOINT_ENV: &str = "CERESDB_SERVER_ENDPOINT";
const CASE_ROOT_PATH_ENV: &str = "CERESDB_TEST_CASE_PATH";
const CERESDB_STDOUT_FILE: &str = "CERESDB_STDOUT_FILE";
const CERESDB_STDERR_FILE: &str = "CERESDB_STDERR_FILE";

pub struct Environment {
server_process: Child,
Expand All @@ -20,12 +23,15 @@ impl Environment {
pub fn start_server() -> Self {
let bin = env::var(BINARY_PATH_ENV).expect("Cannot parse binary path env");
let config = env::var(CONFIG_PATH_ENV).expect("Cannot parse config path env");
let stdout = env::var(CERESDB_STDOUT_FILE).expect("Cannot parse stdout env");
let stderr = env::var(CERESDB_STDERR_FILE).expect("Cannot parse stderr env");

// TODO: support config stdout/stderr
let stdout = File::create(stdout).expect("Cannot create stdout");
let stderr = File::create(stderr).expect("Cannot create stderr");
let server_process = Command::new(&bin)
.args(["--config", &config])
.stdout(Stdio::null())
.stderr(Stdio::null())
.stdout(stdout)
.stderr(stderr)
.spawn()
.unwrap_or_else(|_| panic!("Failed to start server at {:?}", bin));
println!("Server from {:?} is starting ...", bin);
Expand Down