From e412932daf0d3744bc2114eaa81b91b7673d7914 Mon Sep 17 00:00:00 2001 From: Robert Bruce Park Date: Tue, 19 Jan 2016 11:08:11 -0800 Subject: [PATCH 1/5] Set artifacts link if ADT_PPAS is defined. --- britney.py | 5 ++++- excuse.py | 17 +++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/britney.py b/britney.py index e62dd90..5688d10 100755 --- a/britney.py +++ b/britney.py @@ -1965,8 +1965,11 @@ class Britney(object): for arch, (status, log_url) in arch_status.items(): history_url = cloud_url % {'h': srchash(adtsrc), 's': adtsrc, 'r': self.options.series, 'a': arch} + artifact_url = None + if self.options.adt_ppas: + artifact_url = log_url.replace('log.gz', 'artifact.tar.gz') e.addtest('autopkgtest', '%s %s' % (adtsrc, adtver), - arch, status, log_url, history_url) + arch, status, log_url, history_url, artifact_url) # hints can override failures if not passed: diff --git a/excuse.py b/excuse.py index ab89b0c..0238798 100644 --- a/excuse.py +++ b/excuse.py @@ -182,9 +182,15 @@ class Excuse(object): for pkg in sorted(self.tests[testtype]): archmsg = [] for arch in sorted(self.tests[testtype][pkg]): - status, log_url, history_url = self.tests[testtype][pkg][arch] - archmsg.append('%s: %s' % - (history_url or log_url, arch, log_url, EXCUSES_LABELS[status])) + status, log_url, history_url, artifact_url = self.tests[testtype][pkg][arch] + label = EXCUSES_LABELS[status] + if artifact_url: + message = '{arch}: {label} [artifacts]' + elif history_url: + message = '{arch}: {label}' + else: + message = '{arch}: {label}' + archmsg.append(message.format(**locals())) res = res + ("
  • %s for %s: %s
  • \n" % (testtype, pkg, ', '.join(archmsg))) for x in self.htmlline: @@ -215,9 +221,9 @@ class Excuse(object): """"adding reason""" self.reason[reason] = 1 - def addtest(self, type_, package, arch, state, log_url, history_url=None): + def addtest(self, type_, package, arch, state, log_url, history_url=None, artifact_url=None): """Add test result""" - self.tests.setdefault(type_, {}).setdefault(package, {})[arch] = [state, log_url, history_url] + self.tests.setdefault(type_, {}).setdefault(package, {})[arch] = [state, log_url, history_url, artifact_url] # TODO merge with html() def text(self): @@ -276,4 +282,3 @@ class Excuse(object): excusedata["is-candidate"] = self.is_valid excusedata["tests"] = self.tests return excusedata - From b2ed1ce367901d96f9241bb543bd622ed015b999 Mon Sep 17 00:00:00 2001 From: Robert Bruce Park Date: Tue, 19 Jan 2016 11:25:04 -0800 Subject: [PATCH 2/5] Fix URL. --- britney.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/britney.py b/britney.py index 5688d10..d10a434 100755 --- a/britney.py +++ b/britney.py @@ -1967,7 +1967,7 @@ class Britney(object): 'r': self.options.series, 'a': arch} artifact_url = None if self.options.adt_ppas: - artifact_url = log_url.replace('log.gz', 'artifact.tar.gz') + artifact_url = log_url.replace('log.gz', 'artifacts.tar.gz') e.addtest('autopkgtest', '%s %s' % (adtsrc, adtver), arch, status, log_url, history_url, artifact_url) From 7478b80b8532029f992ecaa48db5dad82474def0 Mon Sep 17 00:00:00 2001 From: Robert Bruce Park Date: Tue, 19 Jan 2016 11:34:12 -0800 Subject: [PATCH 3/5] Iterate. --- britney.py | 12 +++++++----- excuse.py | 8 +++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/britney.py b/britney.py index d10a434..84c056f 100755 --- a/britney.py +++ b/britney.py @@ -1963,13 +1963,15 @@ class Britney(object): for passed, adtsrc, adtver, arch_status in autopkgtest.results( e.name, e.ver[1]): for arch, (status, log_url) in arch_status.items(): - history_url = cloud_url % {'h': srchash(adtsrc), 's': adtsrc, - 'r': self.options.series, 'a': arch} - artifact_url = None + kwargs = {} if self.options.adt_ppas: - artifact_url = log_url.replace('log.gz', 'artifacts.tar.gz') + kwargs['artifact_url'] = log_url.replace('log.gz', 'artifacts.tar.gz') + else: + kwargs['history_url'] = cloud_url % { + 'h': srchash(adtsrc), 's': adtsrc, + 'r': self.options.series, 'a': arch} e.addtest('autopkgtest', '%s %s' % (adtsrc, adtver), - arch, status, log_url, history_url, artifact_url) + arch, status, log_url, **kwargs) # hints can override failures if not passed: diff --git a/excuse.py b/excuse.py index 0238798..3e05a06 100644 --- a/excuse.py +++ b/excuse.py @@ -184,12 +184,10 @@ class Excuse(object): for arch in sorted(self.tests[testtype][pkg]): status, log_url, history_url, artifact_url = self.tests[testtype][pkg][arch] label = EXCUSES_LABELS[status] + message = '{arch}' if history_url else '{arch}' + message += ': {label}' if artifact_url: - message = '{arch}: {label} [artifacts]' - elif history_url: - message = '{arch}: {label}' - else: - message = '{arch}: {label}' + message += ' [artifacts]' archmsg.append(message.format(**locals())) res = res + ("
  • %s for %s: %s
  • \n" % (testtype, pkg, ', '.join(archmsg))) From fbb4293091af69f5ec0978b938d22881d610c6dc Mon Sep 17 00:00:00 2001 From: Robert Bruce Park Date: Tue, 19 Jan 2016 12:05:32 -0800 Subject: [PATCH 4/5] Stop setting artifacts link if log is running.shtml. --- britney.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/britney.py b/britney.py index 84c056f..03eef02 100755 --- a/britney.py +++ b/britney.py @@ -1965,7 +1965,8 @@ class Britney(object): for arch, (status, log_url) in arch_status.items(): kwargs = {} if self.options.adt_ppas: - kwargs['artifact_url'] = log_url.replace('log.gz', 'artifacts.tar.gz') + if log_url.endswith('log.gz'): + kwargs['artifact_url'] = log_url.replace('log.gz', 'artifacts.tar.gz') else: kwargs['history_url'] = cloud_url % { 'h': srchash(adtsrc), 's': adtsrc, From 7ad23cdfdda44502080b6660b01ca587c1635ae2 Mon Sep 17 00:00:00 2001 From: Robert Bruce Park Date: Tue, 19 Jan 2016 12:22:51 -0800 Subject: [PATCH 5/5] Add & fix tests. --- tests/test_autopkgtest.py | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/tests/test_autopkgtest.py b/tests/test_autopkgtest.py index 6ee3e60..833ec19 100755 --- a/tests/test_autopkgtest.py +++ b/tests/test_autopkgtest.py @@ -38,6 +38,7 @@ class T(TestBase): def setUp(self): super().setUp() + self.maxDiff = None self.fake_amqp = os.path.join(self.data.path, 'amqp') # Disable boottests and set fake AMQP and Swift server @@ -194,10 +195,12 @@ class T(TestBase): {'darkgreen 2': { 'amd64': ['RUNNING-ALWAYSFAIL', 'http://autopkgtest.ubuntu.com/running.shtml', - 'http://autopkgtest.ubuntu.com/packages/d/darkgreen/series/amd64'], + 'http://autopkgtest.ubuntu.com/packages/d/darkgreen/series/amd64', + None], 'i386': ['RUNNING-ALWAYSFAIL', 'http://autopkgtest.ubuntu.com/running.shtml', - 'http://autopkgtest.ubuntu.com/packages/d/darkgreen/series/i386']}}}) + 'http://autopkgtest.ubuntu.com/packages/d/darkgreen/series/i386', + None]}}}) self.assertEqual(self.pending_requests, {'darkgreen/2': {'darkgreen': ['amd64', 'i386']}}) @@ -1563,11 +1566,21 @@ class T(TestBase): else: sys.stdout.write(line) - self.do_test( + exc = self.do_test( [('lightgreen', {'Version': '2'}, 'autopkgtest')], {'lightgreen': (True, {'lightgreen 2': {'amd64': 'RUNNING-ALWAYSFAIL'}})}, {'lightgreen': [('old-version', '1'), ('new-version', '2')]} - ) + )[1] + self.assertEqual(exc['lightgreen']['tests'], {'autopkgtest': + {'lightgreen 2': { + 'amd64': ['RUNNING-ALWAYSFAIL', + 'http://autopkgtest.ubuntu.com/running.shtml', + None, + None], + 'i386': ['RUNNING-ALWAYSFAIL', + 'http://autopkgtest.ubuntu.com/running.shtml', + None, + None]}}}) for arch in ['i386', 'amd64']: self.assertTrue('debci-series-%s:lightgreen {"triggers": ["lightgreen/2"], "ppas": ["joe/foo", "awesome-developers/staging"]}' % arch in self.amqp_requests or @@ -1580,11 +1593,21 @@ class T(TestBase): 'series/amd64/l/lightgreen/20150101_100101@': (0, 'lightgreen 2', tr('lightgreen/2')), }}) - self.do_test( + exc = self.do_test( [], {'lightgreen': (True, {'lightgreen 2': {'i386': 'PASS', 'amd64': 'PASS'}})}, {'lightgreen': [('old-version', '1'), ('new-version', '2')]} - ) + )[1] + self.assertEqual(exc['lightgreen']['tests'], {'autopkgtest': + {'lightgreen 2': { + 'amd64': ['PASS', + 'http://localhost:18085/autopkgtest-series-awesome-developers-staging/series/amd64/l/lightgreen/20150101_100101@/log.gz', + None, + 'http://localhost:18085/autopkgtest-series-awesome-developers-staging/series/amd64/l/lightgreen/20150101_100101@/artifacts.tar.gz'], + 'i386': ['PASS', + 'http://localhost:18085/autopkgtest-series-awesome-developers-staging/series/i386/l/lightgreen/20150101_100100@/log.gz', + None, + 'http://localhost:18085/autopkgtest-series-awesome-developers-staging/series/i386/l/lightgreen/20150101_100100@/artifacts.tar.gz']}}}) self.assertEqual(self.amqp_requests, set()) self.assertEqual(self.pending_requests, {})