From ed31f1129b1006107e6ab4e9c11127ea23e3adce Mon Sep 17 00:00:00 2001 From: Celso Providelo Date: Thu, 22 Jan 2015 16:44:18 -0200 Subject: [PATCH] Cosmetic changes for adding excuse labels (html) and more readable image manifest path. --- boottest.py | 14 +++++++++++--- britney.py | 10 ++++++---- tests/test_boottest.py | 28 ++++++++++++++++++---------- 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/boottest.py b/boottest.py index 1ad4eb5..1f576ba 100644 --- a/boottest.py +++ b/boottest.py @@ -24,7 +24,7 @@ class TouchManifest(object): Assumes the deployment is arranged in a way the manifest is available and fresh on: - 'data/boottest/{distribution}/{series}/manifest' + '{britney_cwd}/boottest/images/{distribution}/{series}/manifest' Only binary name matters, version is ignored, so callsites can: @@ -37,7 +37,7 @@ class TouchManifest(object): """ def __init__(self, distribution, series): - self.path = 'data/boottest/{}/{}/manifest'.format( + self.path = 'boottest/images/{}/{}/manifest'.format( distribution, series) self._manifest = self._load() @@ -66,6 +66,14 @@ class BootTest(object): TBD! """ + VALID_STATUSES = ('PASS', 'SKIPPED') + + EXCUSE_LABELS = { + "PASS": 'Pass', + "SKIPPED": 'Skipped', + "FAIL": 'Regression', + "RUNNING": 'Test in progress', + } def __init__(self, britney, distribution, series, debug=False): self.britney = britney @@ -86,7 +94,7 @@ class BootTest(object): return 'PASS' return 'FAIL' - return 'IN PROGRESS' + return 'RUNNING' def update(self, excuse): """Update given 'excuse' and yields testing status. diff --git a/britney.py b/britney.py index 993f38a..b9c182d 100755 --- a/britney.py +++ b/britney.py @@ -1897,17 +1897,19 @@ class Britney(object): # Skip already invalid excuses. if not excuse.is_valid: continue - labels = set() + statuses = set() # Update valid excuses from the boottest context and if they # have failed, block their migration. - for binary_name, label in boottest.update(excuse): + for binary_name, status in boottest.update(excuse): + label = BootTest.EXCUSE_LABELS.get( + status, 'UNKNOWN STATUS') excuse.addhtml("boottest for %s %s: %s" % (binary_name, excuse.ver[1], label)) - labels.add(label) + statuses.add(status) # If all boottests passed or were skipped, the excuse is # clean and promotion can proceed, according to the # boottest criteria. Otherwise block the promotion. - if not labels.issubset(set(['PASS', 'SKIPPED'])): + if not statuses.issubset(set(BootTest.VALID_STATUSES)): excuse.addhtml("Not considered") excuse.addreason("boottest") excuse.is_valid = False diff --git a/tests/test_boottest.py b/tests/test_boottest.py index 8f2d2bb..c15d0ed 100644 --- a/tests/test_boottest.py +++ b/tests/test_boottest.py @@ -17,7 +17,10 @@ PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, PROJECT_DIR) from tests import TestBase -from boottest import TouchManifest +from boottest import ( + BootTest, + TouchManifest, +) def create_manifest(manifest_dir, lines): @@ -33,8 +36,8 @@ class TestTouchManifest(unittest.TestCase): super(TestTouchManifest, self).setUp() self.path = tempfile.mkdtemp(prefix='boottest') os.chdir(self.path) - self.datadir = os.path.join(self.path, 'data/boottest/') - os.makedirs(self.datadir) + self.imagesdir = os.path.join(self.path, 'boottest/images') + os.makedirs(self.imagesdir) self.addCleanup(shutil.rmtree, self.path) def test_missing(self): @@ -45,7 +48,7 @@ class TestTouchManifest(unittest.TestCase): def test_simple(self): # Existing manifest file allows callsites to properly check presence. - manifest_dir = os.path.join(self.datadir, 'ubuntu/vivid') + manifest_dir = os.path.join(self.imagesdir, 'ubuntu/vivid') manifest_lines = [ 'bar 1234', 'foo:armhf 1~beta1', @@ -91,7 +94,7 @@ class TestBoottestEnd2End(TestBase): """Create a manifest for this britney run context.""" path = os.path.join( self.data.path, - 'data/boottest/ubuntu/{}'.format(self.data.series)) + 'boottest/images/ubuntu/{}'.format(self.data.series)) create_manifest(path, lines) def do_test(self, context, expect=None, no_expect=None): @@ -121,8 +124,10 @@ class TestBoottestEnd2End(TestBase): self.do_test( context, [r'\bgreen\b.*>1 to .*>1.1~beta<', - '
  • boottest for green 1.1~beta: IN PROGRESS', - '
  • boottest for libgreen1 1.1~beta: SKIPPED', + '
  • boottest for green 1.1~beta: {}'.format( + BootTest.EXCUSE_LABELS['RUNNING']), + '
  • boottest for libgreen1 1.1~beta: {}'.format( + BootTest.EXCUSE_LABELS['SKIPPED']), '
  • Not considered']) def test_pass(self): @@ -135,7 +140,8 @@ class TestBoottestEnd2End(TestBase): self.do_test( context, [r'\bpyqt5-src\b.*\(- to .*>1.1~beta<', - '
  • boottest for pyqt5 1.1~beta: PASS', + '
  • boottest for pyqt5 1.1~beta: {}'.format( + BootTest.EXCUSE_LABELS['PASS']), '
  • Valid candidate']) def test_fail(self): @@ -148,7 +154,8 @@ class TestBoottestEnd2End(TestBase): self.do_test( context, [r'\bpyqt5-src\b.*\(- to .*>1.1<', - '
  • boottest for pyqt5 1.1: FAIL', + '
  • boottest for pyqt5 1.1: {}'.format( + BootTest.EXCUSE_LABELS['FAIL']), '
  • Not considered']) def test_skipped(self): @@ -162,7 +169,8 @@ class TestBoottestEnd2End(TestBase): self.do_test( context, [r'\bapache2-src\b.*\(- to .*>2.4.8-1ubuntu1<', - '
  • boottest for apache2 2.4.8-1ubuntu1: SKIPPED', + '
  • boottest for apache2 2.4.8-1ubuntu1: {}'.format( + BootTest.EXCUSE_LABELS['SKIPPED']), '
  • Valid candidate'])