diff --git a/britney2/policies/autopkgtest.py b/britney2/policies/autopkgtest.py index 5018c3a..c48cd7c 100644 --- a/britney2/policies/autopkgtest.py +++ b/britney2/policies/autopkgtest.py @@ -254,6 +254,7 @@ class AutopkgtestPolicy(BasePolicy): for arch in sorted(arch_results): (status, log_url) = arch_results[arch] artifact_url = None + retry_url = None history_url = None if self.options.adt_ppas: if log_url.endswith('log.gz'): @@ -262,13 +263,20 @@ class AutopkgtestPolicy(BasePolicy): history_url = cloud_url % { 'h': srchash(testsrc), 's': testsrc, 'r': self.options.series, 'a': arch} + if status == 'REGRESSION': + retry_url = self.options.adt_ci_url + 'request.cgi?' + \ + urllib.parse.urlencode([('release', self.options.series), + ('arch', arch), + ('package', testsrc), + ('trigger', trigger)] + + [('ppa', p) for p in self.options.adt_ppas]) if testver: testname = '%s/%s' % (testsrc, testver) else: testname = testsrc tests_info.setdefault(testname, {})[arch] = \ - [status, log_url, history_url, artifact_url] + [status, log_url, history_url, artifact_url, retry_url] # render HTML snippet for testsrc entry for current arch if history_url: @@ -276,6 +284,8 @@ class AutopkgtestPolicy(BasePolicy): else: message = arch message += ': %s' % (log_url, EXCUSES_LABELS[status]) + if retry_url: + message += ' ' % retry_url if artifact_url: message += ' [artifacts]' % artifact_url html_archmsg.append(message) diff --git a/tests/test_autopkgtest.py b/tests/test_autopkgtest.py index ef9eb72..2af152f 100644 --- a/tests/test_autopkgtest.py +++ b/tests/test_autopkgtest.py @@ -212,10 +212,12 @@ class T(TestBase): 'amd64': ['RUNNING-ALWAYSFAIL', 'https://autopkgtest.ubuntu.com/status/pending', 'https://autopkgtest.ubuntu.com/packages/d/darkgreen/testing/amd64', + None, None], 'i386': ['RUNNING-ALWAYSFAIL', 'https://autopkgtest.ubuntu.com/status/pending', 'https://autopkgtest.ubuntu.com/packages/d/darkgreen/testing/i386', + None, None]}, 'verdict': 'PASS'}) @@ -500,6 +502,15 @@ class T(TestBase): 'https://autopkgtest.ubuntu.com/packages/l/lightgreen/testing/amd64', None]) + # should have retry link for the regressions (not a stable URL, test + # seaprately) + link = urllib.parse.urlparse(exc['green']['policy_info']['autopkgtest']['lightgreen/1']['amd64'][4]) + self.assertEqual(link.netloc, 'autopkgtest.ubuntu.com') + self.assertEqual(link.path, '/request.cgi') + self.assertEqual(urllib.parse.parse_qs(link.query), + {'release': ['testing'], 'arch': ['amd64'], + 'package': ['lightgreen'], 'trigger': ['green/2']}) + # we already had all results before the run, so this should not trigger # any new requests self.assertEqual(self.amqp_requests, set()) @@ -2220,10 +2231,12 @@ class T(TestBase): 'amd64': ['RUNNING-ALWAYSFAIL', 'https://autopkgtest.ubuntu.com/status/pending', None, + None, None], 'i386': ['RUNNING-ALWAYSFAIL', 'https://autopkgtest.ubuntu.com/status/pending', None, + None, None]}, 'verdict': 'PASS'}) @@ -2250,11 +2263,14 @@ class T(TestBase): 'amd64': ['PASS', 'http://localhost:18085/autopkgtest-testing-awesome-developers-staging/testing/amd64/l/lightgreen/20150101_100101@/log.gz', None, - 'http://localhost:18085/autopkgtest-testing-awesome-developers-staging/testing/amd64/l/lightgreen/20150101_100101@/artifacts.tar.gz'], + 'http://localhost:18085/autopkgtest-testing-awesome-developers-staging/testing/amd64/l/lightgreen/20150101_100101@/artifacts.tar.gz', + None], 'i386': ['REGRESSION', 'http://localhost:18085/autopkgtest-testing-awesome-developers-staging/testing/i386/l/lightgreen/20150101_100100@/log.gz', None, - 'http://localhost:18085/autopkgtest-testing-awesome-developers-staging/testing/i386/l/lightgreen/20150101_100100@/artifacts.tar.gz']}, + 'http://localhost:18085/autopkgtest-testing-awesome-developers-staging/testing/i386/l/lightgreen/20150101_100100@/artifacts.tar.gz', + 'https://autopkgtest.ubuntu.com/request.cgi?release=testing&arch=i386&package=lightgreen&' + 'trigger=lightgreen%2F2&ppa=joe%2Ffoo&ppa=awesome-developers%2Fstaging']}, 'verdict': 'REJECTED_PERMANENTLY'}) self.assertEqual(self.amqp_requests, set()) self.assertEqual(self.pending_requests, {}) @@ -2440,6 +2456,15 @@ class T(TestBase): ['https://autopkgtest.ubuntu.com/packages/l/lightgreen/testing/amd64', None]) + # should have retry link for the regressions (not a stable URL, test + # separately) + link = urllib.parse.urlparse(exc['green']['policy_info']['autopkgtest']['lightgreen/1']['amd64'][4]) + self.assertEqual(link.netloc, 'autopkgtest.ubuntu.com') + self.assertEqual(link.path, '/request.cgi') + self.assertEqual(urllib.parse.parse_qs(link.query), + {'release': ['testing'], 'arch': ['amd64'], + 'package': ['lightgreen'], 'trigger': ['green/2']}) + # we already had all results before the run, so this should not trigger # any new requests self.assertEqual(self.amqp_requests, set())