Merge pull request #45283 from azat/tests/binary-detection

tests: fix clickhouse binaries detection
This commit is contained in:
Alexey Milovidov 2023-01-16 01:18:37 +03:00 committed by GitHub
commit 0536c9b36d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 24 deletions

View File

@ -1958,19 +1958,22 @@ def main(args):
def find_binary(name):
if os.path.exists(name) and os.access(name, os.X_OK):
return True
if os.access(name, os.X_OK):
return name
paths = os.environ.get("PATH").split(":")
for path in paths:
if os.access(os.path.join(path, name), os.X_OK):
return True
bin_path = os.path.join(path, name)
if os.access(bin_path, os.X_OK):
return bin_path
# maybe it wasn't in PATH
if os.access(os.path.join("/usr/local/bin", name), os.X_OK):
return True
if os.access(os.path.join("/usr/bin", name), os.X_OK):
return True
return False
bin_path = os.path.join("/usr/local/bin", name)
if os.access(bin_path, os.X_OK):
return bin_path
bin_path = os.path.join("/usr/bin", name)
if os.access(bin_path, os.X_OK):
return bin_path
return None
def get_additional_client_options(args):
@ -2010,9 +2013,8 @@ if __name__ == "__main__":
parser.add_argument(
"-b",
"--binary",
default="clickhouse",
help="Path to clickhouse"
"binary or name of binary in PATH",
default=find_binary("clickhouse"),
help="Path to clickhouse binary or name of binary in PATH",
)
parser.add_argument(
@ -2282,18 +2284,13 @@ if __name__ == "__main__":
if args.tmp is None:
args.tmp = args.queries
if args.client is None:
if find_binary(args.binary + "-client"):
args.client = args.binary + "-client"
print("Using " + args.client + " as client program")
elif find_binary(args.binary):
client_bin = find_binary(args.binary + "-client")
if client_bin is not None:
args.client = client_bin
print("Using {args.client} as client program")
elif args.binary:
args.client = args.binary + " client"
print(
"Using "
+ args.client
+ " as client program (expecting monolithic build)"
)
print(f"Using {args.client} as client program (expecting monolithic build)")
else:
print(
"No 'clickhouse' or 'clickhouse-client' client binary found",

View File

@ -23,7 +23,7 @@ export CLICKHOUSE_TEST_UNIQUE_NAME="${CLICKHOUSE_TEST_NAME}_${CLICKHOUSE_DATABAS
[ -n "${CLICKHOUSE_DATABASE:-}" ] && CLICKHOUSE_BENCHMARK_OPT0+=" --database=${CLICKHOUSE_DATABASE} "
[ -n "${CLICKHOUSE_LOG_COMMENT:-}" ] && CLICKHOUSE_BENCHMARK_OPT0+=" --log_comment $(printf '%q' ${CLICKHOUSE_LOG_COMMENT}) "
export CLICKHOUSE_BINARY=${CLICKHOUSE_BINARY:="clickhouse"}
export CLICKHOUSE_BINARY=${CLICKHOUSE_BINARY:="$(command -v clickhouse)"}
# client
[ -x "$CLICKHOUSE_BINARY-client" ] && CLICKHOUSE_CLIENT_BINARY=${CLICKHOUSE_CLIENT_BINARY:=$CLICKHOUSE_BINARY-client}
[ -x "$CLICKHOUSE_BINARY" ] && CLICKHOUSE_CLIENT_BINARY=${CLICKHOUSE_CLIENT_BINARY:=$CLICKHOUSE_BINARY client}