Skip to content

Commit 7a20743

Browse files
committed
tests: fail the test itself in case of Fatal/sanitizer alerts
Previously it was reported at the end of the all tests, and even code was not changed, and this hide errors and makes debugging way harder.
1 parent bcfdc15 commit 7a20743

File tree

1 file changed

+23
-38
lines changed

1 file changed

+23
-38
lines changed

tests/clickhouse-test

Lines changed: 23 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,7 @@ class TestCase:
16091609
stdout = str(stdfd.read(), errors="replace", encoding="utf-8")
16101610

16111611
stderr = kill_output
1612+
stderr += str(self.fatal_sanitizer_log.read(), errors="replace", encoding="utf-8")
16121613
if os.path.exists(self.stderr_file):
16131614
with open(self.stderr_file, "rb") as stdfd:
16141615
stderr += str(stdfd.read(), errors="replace", encoding="utf-8")
@@ -1872,28 +1873,28 @@ class TestCase:
18721873
client = args.testcase_client
18731874
start_time = args.testcase_start_time
18741875
database = args.testcase_database
1875-
1876-
if args.client_log:
1877-
log_opt = " --client_logs_file=" + args.client_log + " "
1878-
client_options += log_opt
1879-
1880-
for env_name in [
1881-
"TSAN_OPTIONS",
1882-
"ASAN_OPTIONS",
1883-
"MSAN_OPTIONS",
1884-
"UBSAN_OPTIONS",
1885-
]:
1886-
current_options = os.environ.get(env_name, None)
1887-
if current_options is None:
1888-
os.environ[env_name] = f"log_path={args.client_log}"
1889-
elif "log_path=" not in current_options:
1890-
os.environ[env_name] += f":log_path={args.client_log}"
1891-
1892-
os.environ["CLICKHOUSE_CLIENT_OPT"] = (
1893-
os.environ["CLICKHOUSE_CLIENT_OPT"]
1894-
if "CLICKHOUSE_CLIENT_OPT" in os.environ
1895-
else ""
1896-
) + log_opt
1876+
self.fatal_sanitizer_log = tempfile.NamedTemporaryFile("rb", prefix="clickhouse-test-", suffix=".log", dir=args.test_tmp_dir)
1877+
1878+
log_opt = " --client_logs_file=" + self.fatal_sanitizer_log.name + " "
1879+
client_options += log_opt
1880+
1881+
for env_name in [
1882+
"TSAN_OPTIONS",
1883+
"ASAN_OPTIONS",
1884+
"MSAN_OPTIONS",
1885+
"UBSAN_OPTIONS",
1886+
]:
1887+
current_options = os.environ.get(env_name, None)
1888+
if current_options is None:
1889+
os.environ[env_name] = f"log_path={self.fatal_sanitizer_log.name}"
1890+
elif "log_path=" not in current_options:
1891+
os.environ[env_name] += f":log_path={self.fatal_sanitizer_log.name}"
1892+
1893+
os.environ["CLICKHOUSE_CLIENT_OPT"] = (
1894+
os.environ["CLICKHOUSE_CLIENT_OPT"]
1895+
if "CLICKHOUSE_CLIENT_OPT" in os.environ
1896+
else ""
1897+
) + log_opt
18971898

18981899
# This is for .sh tests
18991900
os.environ["CLICKHOUSE_LOG_COMMENT"] = args.testcase_basename
@@ -3459,17 +3460,6 @@ def main(args):
34593460
else:
34603461
print(colored("\nNo queries hung.", args, "green", attrs=["bold"]))
34613462

3462-
if args.client_log:
3463-
for log_file in [args.client_log, *glob.glob(f"{args.client_log}.*")]:
3464-
if not os.path.exists(log_file):
3465-
continue
3466-
with open(log_file, "rb") as stream:
3467-
content = stream.read().decode()
3468-
if len(content):
3469-
print(f"Has fatal logs from client in '{log_file}':\n")
3470-
print(content)
3471-
os.remove(log_file)
3472-
34733463
if len(restarted_tests) > 0:
34743464
print("\nSome tests were restarted:\n")
34753465

@@ -3889,11 +3879,6 @@ def parse_args():
38893879
help="Replace *Log and Memory engines with MergeTree",
38903880
)
38913881

3892-
parser.add_argument(
3893-
"--client-log",
3894-
default="./client.fatal.log",
3895-
help="Path to file for fatal logs from client",
3896-
)
38973882
parser.add_argument(
38983883
"--capture-client-stacktrace",
38993884
action="store_true",

0 commit comments

Comments
 (0)