Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit fe5fb29

Browse files
Add an issue bucketing script for query execution tests (#368)
1 parent 9edc9a9 commit fe5fb29

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

scripts/bucketing.py

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/bin/python3
2+
3+
import subprocess
4+
import argparse
5+
import pathlib
6+
from string import whitespace
7+
import yaml
8+
import signal
9+
10+
11+
def signal_to_name(sig: int):
12+
return signal.Signals(sig).name
13+
14+
15+
def generate_test_run_options(gtest_output: str):
16+
# Gtest prints a 'starting' string and a summary at the end
17+
# FIXME: The ending is specific to ArrowBasedExecuteTest
18+
lines = gtest_output.splitlines()[1:-2]
19+
run_opts = []
20+
base = lines[0]
21+
for line in lines:
22+
if line.startswith(tuple(w for w in whitespace)):
23+
run_opts += [base + line.strip()]
24+
else:
25+
base = line
26+
return run_opts
27+
28+
29+
parser = argparse.ArgumentParser(prog='bucketing',
30+
usage="""%(prog)s <filename> [options]\nExample: ./scripts/%(prog)s.py build/omniscidb/Tests/ArrowBasedExecuteTest -o report.yaml""",
31+
description="""This is an utility script to collect gtest
32+
tests and generate a status report by running tests one
33+
by one and bucketing any discovered issues.""")
34+
parser.add_argument('testname', help='Path to the gtest executable.')
35+
parser.add_argument('--no-run', default=False, action='store_true',
36+
help="Don't run the tests, just print their names.")
37+
parser.add_argument('-o', '--output', type=argparse.FileType('w'),
38+
help="Re-route output to a yaml file.")
39+
args = parser.parse_args()
40+
41+
executable = pathlib.Path(args.testname)
42+
if not executable.is_file():
43+
print('File not found:', executable)
44+
exit(1)
45+
46+
p = subprocess.run([executable, '--gtest_list_tests'],
47+
capture_output=True, encoding='utf-8')
48+
p.check_returncode()
49+
50+
tests = generate_test_run_options(p.stdout)
51+
52+
if args.no_run:
53+
if args.output:
54+
[args.output.write(str(t) + '\n') for t in tests]
55+
else:
56+
[print(t) for t in tests]
57+
exit(0)
58+
59+
60+
report = {}
61+
62+
63+
def add_to_report(bucket, test):
64+
if bucket not in report.keys():
65+
report[bucket] = [test]
66+
else:
67+
report[bucket].append(test)
68+
69+
70+
for test in tests:
71+
p = subprocess.run([executable, '--gtest_filter=' + test])
72+
if p.returncode < 0:
73+
add_to_report(signal_to_name(-p.returncode), test)
74+
elif p.returncode == 0:
75+
add_to_report('PASS', test)
76+
elif p.returncode > 0:
77+
add_to_report('ERROR', test)
78+
else:
79+
assert (False)
80+
81+
if args.output:
82+
yaml.dump(report, args.output)
83+
else:
84+
print(yaml.dump(report))

0 commit comments

Comments
 (0)