ClickHouse/docker/test/sqlancer/process_sqlancer_result.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

94 lines
2.9 KiB
Python
Raw Normal View History

2021-02-26 11:43:58 +00:00
#!/usr/bin/env python3
import os
import logging
import argparse
import csv
def process_result(result_folder):
status = "success"
summary = []
paths = []
tests = [
2022-10-25 10:34:55 +00:00
"TLPAggregate",
"TLPDistinct",
2021-02-26 11:43:58 +00:00
"TLPGroupBy",
"TLPHaving",
2022-10-25 10:34:55 +00:00
"TLPWhere",
"NoREC",
2021-02-26 11:43:58 +00:00
]
2022-10-19 17:16:41 +00:00
failed_tests = []
2022-10-19 17:02:49 +00:00
2021-02-26 11:43:58 +00:00
for test in tests:
err_path = "{}/{}.err".format(result_folder, test)
out_path = "{}/{}.out".format(result_folder, test)
if not os.path.exists(err_path):
logging.info("No output err on path %s", err_path)
summary.append((test, "SKIPPED"))
elif not os.path.exists(out_path):
logging.info("No output log on path %s", out_path)
else:
paths.append(err_path)
paths.append(out_path)
with open(err_path, "r") as f:
if "AssertionError" in f.read():
summary.append((test, "FAIL"))
2022-10-19 17:02:49 +00:00
failed_tests.append(test)
2021-03-23 04:26:30 +00:00
status = "failure"
2021-02-26 11:43:58 +00:00
else:
summary.append((test, "OK"))
stdout_path = "{}/stdout.log".format(result_folder)
if not os.path.exists(stdout_path):
logging.info("No stdout log on path %s", stdout_path)
else:
paths.append(stdout_path)
stderr_path = "{}/stderr.log".format(result_folder)
if not os.path.exists(stderr_path):
logging.info("No stderr log on path %s", stderr_path)
else:
paths.append(stderr_path)
2022-10-19 17:02:49 +00:00
description = "SQLancer run successfully"
if status == "failure":
description = f"Failed oracles: {failed_tests}"
2021-02-26 11:43:58 +00:00
return status, description, summary, paths
2022-10-19 17:16:41 +00:00
def write_results(
results_file, status_file, description_file, results, status, description
):
2021-02-26 11:43:58 +00:00
with open(results_file, "w") as f:
out = csv.writer(f, delimiter="\t")
out.writerows(results)
with open(status_file, "w") as f:
2022-10-19 17:16:41 +00:00
f.write(status + "\n")
2022-10-19 17:02:49 +00:00
with open(description_file, "w") as f:
2022-10-19 17:16:41 +00:00
f.write(description + "\n")
2021-02-26 11:43:58 +00:00
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(message)s")
parser = argparse.ArgumentParser(
description="ClickHouse script for parsing results of sqlancer test"
)
2022-10-17 16:30:36 +00:00
parser.add_argument("--in-results-dir", default="/workspace/")
2022-10-19 17:02:49 +00:00
parser.add_argument("--out-results-file", default="/workspace/summary.tsv")
parser.add_argument("--out-description-file", default="/workspace/description.txt")
parser.add_argument("--out-status-file", default="/workspace/status.txt")
2021-02-26 11:43:58 +00:00
args = parser.parse_args()
2022-10-19 17:02:49 +00:00
status, description, summary, logs = process_result(args.in_results_dir)
2021-02-26 11:43:58 +00:00
logging.info("Result parsed")
2022-10-19 17:16:41 +00:00
write_results(
args.out_results_file,
args.out_status_file,
args.out_description_file,
summary,
status,
description,
)
2021-02-26 11:43:58 +00:00
logging.info("Result written")