3
from __future__ import print_function
6
from requests.packages.urllib3.exceptions import InsecureRequestWarning
9
from collections import defaultdict
10
from datetime import timedelta, datetime
11
from pystache import render
15
BASE = 'https://build.gluster.org'
16
TERM = blessings.Terminal()
18
summary = defaultdict(list)
22
def process_failure(url, node):
23
text = requests.get(url, verify=False).text
25
for t in text.split('\n'):
26
if t.find("Result: FAIL") != -1:
29
print(t2.encode('utf-8'))
30
if t2.find("Wstat") != -1:
31
test_case = re.search('\./tests/.*\.t', t2)
33
summary[test_case.group()].append((url, node))
35
elif t.find("cur_cores=/") != -1:
36
summary["core"].append([t.split("/")[1]])
37
summary["core"].append(url)
42
def print_summary(failed_builds, total_builds, html=False):
45
'{{failed}} of {{total}} regressions failed',
46
'<p><b>{{failed}}</b> of <b>{{total}}</b> regressions failed</p>'
49
'\tRegression Link: {{link}}\n'
51
'<p> Regression Link: {{link}}</p>'
52
'<p> Node: {{node}}</p>'
55
'\tComponent: {{comp}}',
56
'<p> Component: {{comp}}</p>'
61
'{{test}} ; Failed {{count}} times',
65
'<p><font color="red"><b>{{test}};</b> Failed <b>{{count}}'
66
'</b> times</font></p>'
75
{'failed': failed_builds, 'total': total_builds}
77
for k, v in summary.items():
79
print(''.join([TERM.red, "Found cores:", TERM.normal]))
80
for comp, link in zip(v[::2], v[1::2]):
81
print(render(component[template], {'comp': comp}))
83
regression_link[template],
84
{'link': link[0], 'node': link[1]}
87
print(render(failure_count[template], {'test': k, 'count': len(v)}))
90
regression_link[template],
91
{'link': link[0], 'node': link[1]}
95
def get_summary(cut_off_date, reg_link):
97
Get links to the failed jobs
101
for page in range(0, MAX_BUILDS, 100):
102
build_info = requests.get(''.join([
105
'api/json?depth=1&tree=allBuilds'
106
'[url,result,timestamp,builtOn]',
107
'{{{0},{1}}}'.format(page, page+100)
108
]), verify=False).json()
109
for build in build_info.get('allBuilds'):
110
if datetime.fromtimestamp(build['timestamp']/1000) < cut_off_date:
112
return failure_count, failure_count + success_count
113
if build['result'] in [None, 'SUCCESS']:
120
'FAILURE on {0}'.format(build['url']),
123
url = ''.join([build['url'], 'consoleText'])
125
process_failure(url, build['builtOn'])
126
return failure_count, failure_count + success_count
129
def main(num_days, regression_link, html_report):
130
cut_off_date = datetime.today() - timedelta(days=num_days)
133
for reg in regression_link:
135
reg_link = '/job/centos6-regression/'
136
elif reg == 'netbsd':
137
reg_link = '/job/netbsd7-regression/'
140
counts = get_summary(cut_off_date, reg_link)
143
print_summary(failure, total, html_report)
146
if __name__ == '__main__':
147
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
148
parser = argparse.ArgumentParser()
149
parser.add_argument("get-summary")
154
help="Regression summary of last number of days"
160
help="\"centos\" | \"netbsd\" | any other regression link"
166
help="Print a detailed report of each test case that is failed"
172
help="Print a brief report of failed regressions in html format"
174
args = parser.parse_args()
175
VERBOSE = args.verbose
177
num_days=args.last_no_of_days,
178
regression_link=args.regression_link,
179
html_report=args.html_report