Implementing boottest entry points for checking phone-image presence and test current status.

This commit is contained in:
Celso Providelo 2015-01-21 10:25:40 -02:00
parent fe5f4c09ac
commit f7e1fa67c0
3 changed files with 84 additions and 18 deletions

View File

@ -26,13 +26,45 @@ class BootTest(object):
self.series = series
self.debug = debug
def check(self, excuse):
"""Check and update given 'excuse' and return its label."""
label = 'IN PROGRESS'
def _source_in_image(self, name):
"""Whether or not the given source name is in the phone image."""
# XXX cprov 20150120: replace with a phone image manifest/content
# check.
if excuse.name == 'apache2':
label = 'SKIPPED'
excuse.is_valid = False
if name == 'apache2':
return False
return label
return True
def _get_status_label(self, name, version):
"""Return the current boottest status label."""
# XXX cprov 20150120: replace with the test history latest
# record label.
if name == 'pyqt5':
if version == '1.1~beta':
return 'PASS'
return 'FAIL'
return 'IN PROGRESS'
def update(self, excuse):
"""Update given 'excuse' and return True if it has failed.
Annotate skipped packages (currently not in phone image) or add
the current testing status (see `_get_status_label`).
"""
if not self._source_in_image(excuse.name):
label = 'SKIPPED'
else:
label = self._get_status_label(excuse.name, excuse.ver[1])
excuse.addhtml("boottest for %s %s: %s" %
(excuse.name, excuse.ver[1], label))
if label in ['PASS', 'SKIPPED']:
return False
excuse.addhtml("Not considered")
excuse.addreason("boottest")
excuse.is_valid = False
return True

View File

@ -1887,16 +1887,21 @@ class Britney(object):
if (getattr(self.options, "boottest_enable", "no") == "yes" and
self.options.series):
# trigger autopkgtests for valid candidates
# trigger 'boottest'ing for valid candidates.
boottest_debug = getattr(
self.options, "boottest_debug", "no") == "yes"
boottest = BootTest(
self, self.options.distribution, self.options.series,
debug=boottest_debug)
for e in self.excuses:
boottest_label = boottest.check(e)
e.addhtml("boottest for %s %s: %s" %
(e.name, e.ver[1], boottest_label))
for excuse in self.excuses:
# Skip already invalid excuses.
if not excuse.is_valid:
continue
# Update valid excuses from the boottest context and if they
# have failed, block their migration.
if boottest.update(excuse):
upgrade_me.remove(excuse.name)
unconsidered.append(excuse.name)
# invalidate impossible excuses
for e in self.excuses:

View File

@ -17,10 +17,11 @@ sys.path.insert(0, PROJECT_DIR)
from tests import TestBase
class TestBoottest(TestBase):
class TestBoottestEnd2End(TestBase):
"""End2End tests (calling `britney`) for the BootTest criteria."""
def setUp(self):
super(TestBoottest, self).setUp()
super(TestBoottestEnd2End, self).setUp()
self.britney_conf = os.path.join(
PROJECT_DIR, 'britney_boottest.conf')
self.data.add('libc6', False)
@ -48,23 +49,51 @@ class TestBoottest(TestBase):
def test_runs(self):
# `Britney` runs and considers packages for boottesting when
# it is enabled in the configuration.
# it is enabled in the configuration and 'in progress' tests
# blocks package promotion.
context = []
context.append(
('green', {'Version': '1.1~beta', 'Depends': 'libc6 (>= 0.9)'}))
self.do_test(
context,
['<li>boottest for green 1.1~beta: IN PROGRESS'])
['<li>boottest for green 1.1~beta: IN PROGRESS',
'<li>Not considered'])
def test_pass(self):
# `Britney` updates boottesting information in excuses when the
# package test pass and marks the package as a valid candidate for
# promotion.
context = []
context.append(
('pyqt5', {'Version': '1.1~beta'}))
self.do_test(
context,
['<li>boottest for pyqt5 1.1~beta: PASS',
'<li>Valid candidate'])
def test_fail(self):
# `Britney` updates boottesting information in excuses when the
# package test fails and blocks the package promotion
# ('Not considered.')
context = []
context.append(
('pyqt5', {'Version': '1.1'}))
self.do_test(
context,
['<li>boottest for pyqt5 1.1: FAIL',
'<li>Not considered'])
def test_skipped(self):
# `Britney` updates boottesting information in excuses when the
# package was skipped.
# package was skipped and marks the package as a valid candidate for
# promotion.
context = []
context.append(
('apache2', {'Version': '2.4.8-1ubuntu1'}))
self.do_test(
context,
['<li>boottest for apache2 2.4.8-1ubuntu1: SKIPPED'])
['<li>boottest for apache2 2.4.8-1ubuntu1: SKIPPED',
'<li>Valid candidate'])
if __name__ == '__main__':