From 2bfe25157faf7e60d493dd5998c701f19a2e65f7 Mon Sep 17 00:00:00 2001 From: Ben Baoyi <67940783+Gump9@users.noreply.github.com> Date: Wed, 12 Jul 2023 17:44:50 +0800 Subject: [PATCH] feat:add check port before start sqlness test (#1895) * feat:add check port before start sqlness test * cr comment * feat:remove redundant check_port * cr comment * cr comment * cr comment --- tests/runner/src/env.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/runner/src/env.rs b/tests/runner/src/env.rs index 2633c6a0e1..f5168760b0 100644 --- a/tests/runner/src/env.rs +++ b/tests/runner/src/env.rs @@ -183,12 +183,21 @@ impl Env { _ => panic!("Unexpected subcommand: {subcommand}"), }; + if util::check_port(check_ip_addr.parse().unwrap(), Duration::from_secs(1)).await { + panic!( + "Port {check_ip_addr} is already in use, please check and retry.", + check_ip_addr = check_ip_addr + ); + } + let mut process = Command::new("./greptime") .current_dir(util::get_binary_dir("debug")) .args(args) .stdout(log_file) .spawn() - .unwrap_or_else(|_| panic!("Failed to start the DB with subcommand {subcommand}")); + .unwrap_or_else(|error| { + panic!("Failed to start the DB with subcommand {subcommand},Error: {error}") + }); if !util::check_port(check_ip_addr.parse().unwrap(), Duration::from_secs(10)).await { Env::stop_server(&mut process);