From 69e059122091ec0c9d5966b3f1eb6b5f8be09012 Mon Sep 17 00:00:00 2001 From: Sergio Durigan Junior Date: Mon, 4 Sep 2017 14:53:08 -0400 Subject: [PATCH] Fixing case when there are multiple tries to the same commit. --- lib/gdbcommand.py | 8 +++++++- lib/sumfiles.py | 32 +++++++++++++++++++++++++------- master.cfg | 27 +++++++++++++++++++-------- 3 files changed, 51 insertions(+), 16 deletions(-) diff --git a/lib/gdbcommand.py b/lib/gdbcommand.py index db3a0fd..32e40c0 100644 --- a/lib/gdbcommand.py +++ b/lib/gdbcommand.py @@ -39,7 +39,13 @@ def create_copy_command (props): return [ 'true' ] if istry and istry == 'yes': - to_path = os.path.join (get_web_base (), builder, 'try', rev[:2], rev) + con = sqlite3.connect (db_file) + c = con.cursor () + c.execute ('SELECT COUNT(*) FROM logs WHERE commitid = "%s" AND branch = "%s" AND trysched = 1' % (rev, branch)) + count = int (c.fetchone ()) + con.close () + + to_path = os.path.join (get_web_base (), builder, 'try', rev[:2], rev, count) else: to_path = os.path.join (get_web_base (), builder, rev[:2], rev) diff --git a/lib/sumfiles.py b/lib/sumfiles.py index ecc5d7c..a955bca 100644 --- a/lib/sumfiles.py +++ b/lib/sumfiles.py @@ -7,6 +7,7 @@ from StringIO import StringIO # the tests matters to us. from collections import OrderedDict import lzma +import sqlite3 # Helper regex for parse_sum_line. sum_matcher = re.compile('^(.?(PASS|FAIL)): (.*)$') @@ -69,11 +70,19 @@ class DejaResults(object): # and to the set. out_dict[1][result].add (test_name) - def _write_sum_file(self, sum_dict, builder, rev, filename, header = None, istry = False): + def _write_sum_file(self, sum_dict, builder, rev, filename, header = None, istry = False, branch = "master"): global gdb_web_base if istry: - bdir = os.path.join (gdb_web_base, builder, 'try', rev[:2], rev) + db_file = os.path.join (get_web_base (), builder, builder + '.db') + + con = sqlite3.connect (db_file) + c = con.cursor () + c.execute ('SELECT COUNT(*) FROM logs WHERE commitid = "%s" AND branch = "%s" AND trysched = 1' % (rev, branch)) + count = int (c.fetchone ()) + con.close () + + bdir = os.path.join (gdb_web_base, builder, 'try', rev[:2], rev, count) else: bdir = os.path.join (gdb_web_base, builder, rev[:2], rev) @@ -95,17 +104,26 @@ class DejaResults(object): os.umask (old_umask) def write_sum_file(self, sum_dict, builder, branch, rev, istry): - self._write_sum_file (sum_dict, builder, rev, 'gdb.sum', istry = istry) + if istry: + self.write_try_build_sum_file (self, sum_dict, builder, branch, rev) + else: + self._write_sum_file (sum_dict, builder, rev, 'gdb.sum', istry = False, + branch = branch) def write_try_build_sum_file (self, sum_dict, builder, branch, rev): self._write_sum_file (sum_dict, builder, rev, 'trybuild_gdb.sum', header = "### THIS SUM FILE WAS GENERATED BY A TRY BUILD ###\n\n", - istry = True) + istry = True, + branch = branch) def write_baseline(self, sum_dict, builder, branch, rev, istry): - self._write_sum_file(sum_dict, builder, rev, 'baseline', - header = "### THIS BASELINE WAS LAST UPDATED BY COMMIT %s ###\n\n" % rev, - istry = istry) + if istry: + return + else: + self._write_sum_file(sum_dict, builder, rev, 'baseline', + header = "### THIS BASELINE WAS LAST UPDATED BY COMMIT %s ###\n\n" % rev, + istry = False, + branch = branch) # Read a .sum file. # The builder name is BUILDER. diff --git a/master.cfg b/master.cfg index f9686b2..6471b09 100644 --- a/master.cfg +++ b/master.cfg @@ -33,6 +33,7 @@ from json import load import re import jinja2 import git +import sqlite3 #################################### #################################### @@ -142,11 +143,12 @@ from email.mime.text import MIMEText def SendRootMessageGDBTesters (branch, change, rev, istrysched = False, - try_to = None): + try_to = None, + try_count = 0) global GDB_MAIL_TO, GDB_MAIL_FROM if istrysched: - f = "/tmp/gdb-buildbot-%s-try.lock" % rev + f = "/tmp/gdb-buildbot-%s-try-%d.lock" % (rev, try_count) else: f = "/tmp/gdb-buildbot-%s.lock" % rev @@ -172,15 +174,17 @@ def SendRootMessageGDBTesters (branch, change, rev, text = text.encode ('ascii', 'ignore').decode ('ascii') else: text = "" - text += "*** TEST RESULTS FOR TRY BUILD ***\n\n" + text += "*** TEST RESULTS FOR TRY BUILD #%d ***\n\n" % try_count text += "Branch: %s\n" % branch text += "Commit tested against: %s\n\n" % rev + text += "There have been %d tries before this one.\n\n" % try_count + text += "Patch tested:\n\n" text += change - chg_title = "Try Build against commit %s" % rev + chg_title = "Try Build #%d against commit %s" % (try_count, rev) text = text.encode ('ascii', 'ignore').decode ('ascii') mail = MIMEText (text) @@ -198,7 +202,7 @@ def SendRootMessageGDBTesters (branch, change, rev, else: mail['To'] = try_to mailto = try_to - mail['Message-Id'] = "<%s-try@gdb-build>" % rev + mail['Message-Id'] = "<%s-try-%d@gdb-build>" % (rev, count) s = smtplib.SMTP ('localhost') s.sendmail (GDB_MAIL_FROM, [ mailto ], mail.as_string ()) @@ -436,11 +440,18 @@ send to the gdb-testers mailing list.""" cur_change = sourcestamp.patch[1] properties = build.getProperties () isrebuild = properties.getProperty ('isRebuild') + db_file = os.path.join (get_web_base (), name, name + '.db') + + con = sqlite3.connect (db_file) + c = con.cursor () + c.execute ('SELECT COUNT(*) FROM logs WHERE commitid = "%s" AND branch = "%s" AND trysched = 1' % (sourcestamp.revision, branch)) + count = int (c.fetchone ()) + con.close () try_to = build.getReason ().strip ("'try' job by user ") # Sending the root message to gdb-testers. SendRootMessageGDBTesters (branch, cur_change, properties.getProperty ('revision'), - istrysched = True, try_to = try_to) + istrysched = True, try_to = try_to, try_count = count) # Subject subj = "Try Build on %s, branch %s" % (name, branch) @@ -463,8 +474,8 @@ send to the gdb-testers mailing list.""" # URL to find more info about what went wrong. text += "\nTestsuite log (gdb.sum and gdb.log) URL(s):\n" - text += "\t<%s/%s/try/%s/%s/>\n" % (res_url, name, sourcestamp.revision[:2], - sourcestamp.revision) + text += "\t<%s/%s/try/%s/%s/%d/>\n\n" % (res_url, name, sourcestamp.revision[:2], + sourcestamp.revision, count) # commit_id = get_builder_commit_id (name, sourcestamp.revision, # sourcestamp.branch)