diff --git a/britney.py b/britney.py index c6f7054..5751867 100755 --- a/britney.py +++ b/britney.py @@ -196,7 +196,7 @@ from functools import reduce, partial from itertools import chain, product from operator import attrgetter -from urllib.parse import quote +from urllib.parse import quote, urlencode from installability.builder import InstallabilityTesterBuilder from excuse import Excuse @@ -1971,6 +1971,12 @@ class Britney(object): kwargs['history_url'] = cloud_url % { 'h': srchash(adtsrc), 's': adtsrc, 'r': self.options.series, 'a': arch} + if status == 'REGRESSION': + kwargs['retry_url'] = 'https://autopkgtest.ubuntu.com/retry.cgi?' + \ + urlencode({'release': self.options.series, + 'arch': arch, + 'package': adtsrc, + 'trigger': '%s/%s' % (e.name, e.ver[1])}) e.addtest('autopkgtest', '%s %s' % (adtsrc, adtver), arch, status, log_url, **kwargs) diff --git a/excuse.py b/excuse.py index 49fec56..85900bf 100644 --- a/excuse.py +++ b/excuse.py @@ -182,13 +182,18 @@ class Excuse(object): for pkg in sorted(self.tests[testtype]): archmsg = [] for arch in sorted(self.tests[testtype][pkg]): - status, log_url, history_url, artifact_url = self.tests[testtype][pkg][arch] + status, log_url, history_url, artifact_url, retry_url = self.tests[testtype][pkg][arch] label = EXCUSES_LABELS[status] - message = '{arch}' if history_url else '{arch}' - message += ': {label}' + if history_url: + message = '%s' % (history_url, arch) + else: + message = arch + message += ': %s' % (log_url, label) + if retry_url: + message += ' ' % retry_url if artifact_url: - message += ' [artifacts]' - archmsg.append(message.format(**locals())) + message += ' [artifacts]' % artifact_url + archmsg.append(message) res = res + ("
  • %s for %s: %s
  • \n" % (testtype, pkg, ', '.join(archmsg))) for x in self.htmlline: @@ -219,9 +224,10 @@ class Excuse(object): """"adding reason""" self.reason[reason] = 1 - def addtest(self, type_, package, arch, state, log_url, history_url=None, artifact_url=None): + def addtest(self, type_, package, arch, state, log_url, history_url=None, + artifact_url=None, retry_url=None): """Add test result""" - self.tests.setdefault(type_, {}).setdefault(package, {})[arch] = [state, log_url, history_url, artifact_url] + self.tests.setdefault(type_, {}).setdefault(package, {})[arch] = [state, log_url, history_url, artifact_url, retry_url] # TODO merge with html() def text(self): diff --git a/tests/test_autopkgtest.py b/tests/test_autopkgtest.py index 2f6eccd..8a3fee4 100755 --- a/tests/test_autopkgtest.py +++ b/tests/test_autopkgtest.py @@ -12,6 +12,7 @@ import fileinput import unittest import json import pprint +import urllib.parse import apt_pkg import yaml @@ -195,10 +196,12 @@ class T(TestBase): 'amd64': ['RUNNING-ALWAYSFAIL', 'http://autopkgtest.ubuntu.com/running.shtml', 'http://autopkgtest.ubuntu.com/packages/d/darkgreen/series/amd64', + None, None], 'i386': ['RUNNING-ALWAYSFAIL', 'http://autopkgtest.ubuntu.com/running.shtml', 'http://autopkgtest.ubuntu.com/packages/d/darkgreen/series/i386', + None, None]}}}) self.assertEqual(self.pending_requests, @@ -412,7 +415,7 @@ class T(TestBase): 'series/amd64/g/green/20150101_100201@': (4, 'green 2', tr('green/2')), }}) - out = self.do_test( + out, exc = self.do_test( [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')], {'green': (False, {'green 2': {'amd64': 'REGRESSION', 'i386': 'PASS'}, 'lightgreen 1': {'amd64': 'REGRESSION', 'i386': 'REGRESSION'}, @@ -420,7 +423,24 @@ class T(TestBase): }) }, {'green': [('old-version', '1'), ('new-version', '2')]} - )[0] + ) + + # should have links to log and history, but no artifacts (as this is + # not a PPA) + self.assertEqual(exc['green']['tests']['autopkgtest']['lightgreen 1']['amd64'][:4], + ['REGRESSION', + 'http://localhost:18085/autopkgtest-series/series/amd64/l/lightgreen/20150101_100101@/log.gz', + 'http://autopkgtest.ubuntu.com/packages/l/lightgreen/series/amd64', + None]) + + # should have retry link for the regressions (not a stable URL, test + # seaprately) + link = urllib.parse.urlparse(exc['green']['tests']['autopkgtest']['lightgreen 1']['amd64'][4]) + self.assertEqual(link.netloc, 'autopkgtest.ubuntu.com') + self.assertEqual(link.path, '/retry.cgi') + self.assertEqual(urllib.parse.parse_qs(link.query), + {'release': ['series'], 'arch': ['amd64'], + 'package': ['lightgreen'], 'trigger': ['green/2']}) # we already had all results before the run, so this should not trigger # any new requests @@ -1575,10 +1595,12 @@ class T(TestBase): 'amd64': ['RUNNING-ALWAYSFAIL', 'http://autopkgtest.ubuntu.com/running.shtml', None, + None, None], 'i386': ['RUNNING-ALWAYSFAIL', 'http://autopkgtest.ubuntu.com/running.shtml', None, + None, None]} }}) @@ -1603,11 +1625,13 @@ class T(TestBase): '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'], + 'http://localhost:18085/autopkgtest-series-awesome-developers-staging/series/amd64/l/lightgreen/20150101_100101@/artifacts.tar.gz', + None], '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']} + 'http://localhost:18085/autopkgtest-series-awesome-developers-staging/series/i386/l/lightgreen/20150101_100100@/artifacts.tar.gz', + None]} }}) self.assertEqual(self.amqp_requests, set()) self.assertEqual(self.pending_requests, {})