From 913539ffe9f1e21b598aac92523ee4ae484177d8 Mon Sep 17 00:00:00 2001 From: Celso Providelo Date: Fri, 23 Jan 2015 10:17:10 -0200 Subject: [PATCH] Allow hints for ignoring boottest results (force and force-skiptest). --- britney.py | 15 +++++++++++++++ tests/test_boottest.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/britney.py b/britney.py index 2b98eb4..ca00745 100755 --- a/britney.py +++ b/britney.py @@ -1911,6 +1911,21 @@ class Britney(object): status, 'UNKNOWN STATUS') excuse.addhtml("boottest for %s %s: %s" % (binary_name, excuse.ver[1], label)) + # Allows hints to force boottest failures/attempts + # to be ignored. + hints = self.hints.search('force', package=excuse.name) + hints.extend( + self.hints.search( + 'force-skiptest', package=excuse.name)) + forces = [ + x for x in hints + if same_source(excuse.ver[1], x.version)] + if forces: + e.addhtml( + "Should wait for %s %s boottest, but forced by " + "%s" % (binary_name, excuse.ver[1], + forces[0].user)) + status = 'PASS' statuses.add(status) # No boottest attemps requested, it's not relevant in this # context, rely on other checks to judge promotion. diff --git a/tests/test_boottest.py b/tests/test_boottest.py index 2b80de6..0b9815c 100644 --- a/tests/test_boottest.py +++ b/tests/test_boottest.py @@ -164,6 +164,48 @@ class TestBoottestEnd2End(TestBase): BootTest.EXCUSE_LABELS['FAIL']), '
  • Not considered']) + def create_hint(self, username, content): + """Populates a hint file for the given 'username' with 'content'.""" + hints_path = os.path.join( + self.data.path, + 'data/{}-proposed/Hints/{}'.format(self.data.series, username)) + with open(hints_path, 'w') as fd: + fd.write(content) + + def test_fail_but_forced_by_hints(self): + # `Britney` allows boottests results to be ignored by hinting the + # corresponding source with 'force' or 'force-skiptest'. The boottest + # attempt will still be requested and its results would be considered + # for other non-forced sources. + context = [ + ('pyqt5', {'Source': 'pyqt5-src', 'Version': '1.1', + 'Architecture': 'all'}), + ] + self.create_hint('cjwatson', 'force pyqt5-src/1.1') + self.do_test( + context, + [r'\bpyqt5-src\b.*\(- to .*>1.1<', + '
  • boottest for pyqt5 1.1: {}'.format( + BootTest.EXCUSE_LABELS['FAIL']), + '
  • Should wait for pyqt5 1.1 boottest, but forced by cjwatson', + '
  • Valid candidate']) + + def test_fail_but_skipped_by_hints(self): + # See `test_fail_but_forced_by_hints`. + context = [ + ('green', {'Source': 'green', 'Version': '1.1~beta', + 'Architecture': 'armhf', 'Depends': 'libc6 (>= 0.9)'}), + ] + self.create_hint('cjwatson', 'force-skiptest green/1.1~beta') + self.do_test( + context, + [r'\bgreen\b.*>1 to .*>1.1~beta<', + '
  • boottest for green 1.1~beta: {}'.format( + BootTest.EXCUSE_LABELS['RUNNING']), + '
  • Should wait for green 1.1~beta boottest, but forced ' + 'by cjwatson', + '
  • Valid candidate']) + def test_skipped_not_on_phone(self): # `Britney` updates boottesting information in excuses when the # package was skipped and marks the package as a valid candidate for