forked from h2oai/h2o-3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmr_unit_failure_report.py
58 lines (51 loc) · 2.63 KB
/
mr_unit_failure_report.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import sys
import MySQLdb
import traceback
import time
def failure_report(args):
mr_unit = MySQLdb.connect(host='172.16.2.178', user='root', passwd=args[1], db='mr_unit')
mr_unit.autocommit(False)
cursor = mr_unit.cursor()
# the jenkins job is scheduled to run every morning at 8 am (local). By default, we report the failures starting from
# 8 pm (local) of the previous day.
try:
start_time = args[2]
except IndexError:
yesterday = time.localtime(time.time() - 24 * 60 * 60)
start_time = time.mktime(yesterday) - yesterday.tm_hour*60*60 - yesterday.tm_min*60 - yesterday.tm_sec + 20*60*60
try:
end_time = args[3]
except IndexError:
end_time = time.time()
try:
cursor.execute('select * from perf where (`start_time` > {0} and `end_time` < {1} and '
'`pass` = 0);'.format(start_time, end_time))
failures = cursor.fetchall()
except:
cursor.close()
traceback.print_exc()
print "Failed to retrieve failures from the perf table in mr_unit database for the period from {0} to {1}"\
.format(time.strftime('%Y-%m-%d:%H:%M:%S', time.localtime(start_time)),
time.strftime('%Y-%m-%d:%H:%M:%S', time.localtime(end_time)))
raise
cursor.close()
print "***********************************************************************"
print "Failures for the period from {0} to {1}".format(time.strftime('%Y-%m-%d:%H:%M:%S', time.localtime(start_time)),
time.strftime('%Y-%m-%d:%H:%M:%S', time.localtime(end_time)))
print "***********************************************************************\n"
for idx, failure in enumerate(failures):
print '\nFAILURE {0}'.format(idx+1)
print '------------------------------------------------------------------------------'
print 'git branch: {0}'.format(failure[3])
print 'git hash: {0}'.format(failure[2])
print 'job name: {0}'.format(failure[11])
print 'build id: {0}'.format(failure[1])
print 'test name: {0}'.format(failure[5])
print 'duration (seconds): {0}'.format(failure[7] - failure[6])
print 'machine ip: {0}'.format(failure[4])
print 'operating system: {0}'.format(failure[10])
print 'number of cpus: {0}'.format(failure[9])
print 'datetime (%Y-%m-%d:%H:%M:%S): {0}'.format(time.strftime('%Y-%m-%d:%H:%M:%S', time.localtime(failure[6])))
print '------------------------------------------------------------------------------\n'
if __name__ == '__main__':
failure_report(sys.argv)