Add retry links to autopkgtest regressions

Generate https://autopkgtest.ubuntu.com/retry.cgi links for re-running tests
that regressed.

Change Excuse.html() back to usual % string formatting to be consistent with
the rest of the code.
This commit is contained in:
Martin Pitt 2016-01-25 11:21:16 +01:00
parent 80a9121f62
commit ec420195bc
3 changed files with 48 additions and 12 deletions

View File

@ -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)

View File

@ -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 = '<a href="{history_url}">{arch}</a>' if history_url else '{arch}'
message += ': <a href="{log_url}">{label}</a>'
if history_url:
message = '<a href="%s">%s</a>' % (history_url, arch)
else:
message = arch
message += ': <a href="%s">%s</a>' % (log_url, label)
if retry_url:
message += ' <a href="%s" style="text-decoration: none;">♻ </a> ' % retry_url
if artifact_url:
message += ' <a href="{artifact_url}">[artifacts]</a>'
archmsg.append(message.format(**locals()))
message += ' <a href="%s">[artifacts]</a>' % artifact_url
archmsg.append(message)
res = res + ("<li>%s for %s: %s</li>\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):

View File

@ -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, {})