Add compose type to release for images

Move getting of the precomputed value to a single place in Compose
class. The value now has format `date[.type_suffix].respin`.

Resolves: rhbz#1319924
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-03-22 08:56:51 +01:00
parent 4afd21952c
commit ecbf08c6f8
9 changed files with 41 additions and 9 deletions

View File

@ -340,3 +340,10 @@ class Compose(kobo.log.LoggingBase):
self.failed_deliverables.setdefault(variant_uid, {}).setdefault(arch, []).append(deliverable) self.failed_deliverables.setdefault(variant_uid, {}).setdefault(arch, []).append(deliverable)
return True return True
return False return False
@property
def image_release(self):
"""Generate a value to pass to Koji as image release. This includes
date, compose type and respin."""
return '%s%s.%s' % (self.compose_date, self.ci_base.compose.type_suffix,
self.compose_respin)

View File

@ -81,7 +81,7 @@ class ImageBuildPhase(PhaseBase):
def _set_release(self, image_conf): def _set_release(self, image_conf):
"""If release is set explicitly to None, replace it with date and respin.""" """If release is set explicitly to None, replace it with date and respin."""
if 'release' in image_conf and image_conf['release'] is None: if 'release' in image_conf and image_conf['release'] is None:
image_conf['release'] = '%s.%s' % (self.compose.compose_date, self.compose.compose_respin) image_conf['release'] = self.compose.image_release
def run(self): def run(self):
for variant in self.compose.get_variants(): for variant in self.compose.get_variants():

View File

@ -113,7 +113,7 @@ class LiveImagesPhase(PhaseBase):
def _get_release(self, image_conf): def _get_release(self, image_conf):
"""If release is set explicitly to None, replace it with date and respin.""" """If release is set explicitly to None, replace it with date and respin."""
if 'release' in image_conf and image_conf['release'] is None: if 'release' in image_conf and image_conf['release'] is None:
return '%s.%s' % (self.compose.compose_date, self.compose.compose_respin) return self.compose.image_release
return image_conf.get('release', None) return image_conf.get('release', None)
def run(self): def run(self):

View File

@ -91,7 +91,7 @@ class LiveMediaPhase(PhaseBase):
""" """
for key, conf in [('release', image_conf), ('live_media_release', self.compose.conf)]: for key, conf in [('release', image_conf), ('live_media_release', self.compose.conf)]:
if key in conf and conf[key] is None: if key in conf and conf[key] is None:
return '%s.%s' % (self.compose.compose_date, self.compose.compose_respin) return self.compose.image_release
return image_conf.get('release', self.compose.conf.get('live_media_release')) return image_conf.get('release', self.compose.conf.get('live_media_release'))
def _get_install_tree(self, image_conf, variant): def _get_install_tree(self, image_conf, variant):

View File

@ -26,6 +26,7 @@ class DummyCompose(object):
self.compose_respin = 0 self.compose_respin = 0
self.compose_id = 'Test-20151203.0.t' self.compose_id = 'Test-20151203.0.t'
self.compose_label = None self.compose_label = None
self.image_release = '20151203.t.0'
self.ci_base = mock.Mock( self.ci_base = mock.Mock(
release_id='Test-1.0', release_id='Test-1.0',
release=mock.Mock( release=mock.Mock(

View File

@ -99,6 +99,30 @@ class ComposeTestCase(unittest.TestCase):
'RC-1.0', '1', 'rel_short', '2', '.iso', 'nightly', 'RC-1.0', '1', 'rel_short', '2', '.iso', 'nightly',
'.n', 'Server', '3.0'])) '.n', 'Server', '3.0']))
@mock.patch('pungi.compose.ComposeInfo')
def test_image_release(self, ci):
conf = {}
ci.return_value.compose.respin = 2
ci.return_value.compose.date = '20160107'
ci.return_value.compose.type = 'nightly'
ci.return_value.compose.type_suffix = '.n'
compose = Compose(conf, self.tmp_dir)
self.assertEqual(compose.image_release, '20160107.n.2')
@mock.patch('pungi.compose.ComposeInfo')
def test_image_release_production(self, ci):
conf = {}
ci.return_value.compose.respin = 2
ci.return_value.compose.date = '20160107'
ci.return_value.compose.type = 'production'
ci.return_value.compose.type_suffix = '.n'
compose = Compose(conf, self.tmp_dir)
self.assertEqual(compose.image_release, '20160107.n.2')
class StatusTest(unittest.TestCase): class StatusTest(unittest.TestCase):
def setUp(self): def setUp(self):

View File

@ -284,7 +284,7 @@ class TestImageBuildPhase(PungiTestCase):
self.assertTrue(phase.pool.queue_put.called_once) self.assertTrue(phase.pool.queue_put.called_once)
args, kwargs = phase.pool.queue_put.call_args args, kwargs = phase.pool.queue_put.call_args
self.assertEqual(args[0][1].get('image_conf', {}).get('image-build', {}).get('release'), self.assertEqual(args[0][1].get('image_conf', {}).get('image-build', {}).get('release'),
'20151203.0') '20151203.t.0')
@mock.patch('pungi.phases.image_build.ThreadPool') @mock.patch('pungi.phases.image_build.ThreadPool')
def test_image_build_scratch_build(self, ThreadPool): def test_image_build_scratch_build(self, ThreadPool):

View File

@ -54,7 +54,7 @@ class TestLiveImagesPhase(PungiTestCase):
'specfile': None, 'specfile': None,
'sign': False, 'sign': False,
'type': 'live', 'type': 'live',
'release': '20151203.0', 'release': '20151203.t.0',
'subvariant': 'Client', 'subvariant': 'Client',
'ksurl': None}, 'ksurl': None},
compose.variants['Client'], compose.variants['Client'],
@ -102,7 +102,7 @@ class TestLiveImagesPhase(PungiTestCase):
'specfile': None, 'specfile': None,
'sign': False, 'sign': False,
'type': 'live', 'type': 'live',
'release': '20151203.0', 'release': '20151203.t.0',
'subvariant': 'Client', 'subvariant': 'Client',
'ksurl': None}, 'ksurl': None},
compose.variants['Client'], compose.variants['Client'],
@ -147,7 +147,7 @@ class TestLiveImagesPhase(PungiTestCase):
'specfile': None, 'specfile': None,
'sign': False, 'sign': False,
'type': 'live', 'type': 'live',
'release': '20151203.0', 'release': '20151203.t.0',
'subvariant': 'Client', 'subvariant': 'Client',
'ksurl': None}, 'ksurl': None},
compose.variants['Client'], compose.variants['Client'],
@ -309,7 +309,7 @@ class TestLiveImagesPhase(PungiTestCase):
'specfile': None, 'specfile': None,
'sign': False, 'sign': False,
'type': 'live', 'type': 'live',
'release': '20151203.0', 'release': '20151203.t.0',
'subvariant': 'Client', 'subvariant': 'Client',
'ksurl': None}, 'ksurl': None},
compose.variants['Client'], compose.variants['Client'],

View File

@ -259,7 +259,7 @@ class TestLiveMediaPhase(PungiTestCase):
'ksurl': 'resolved', 'ksurl': 'resolved',
'ksversion': '24', 'ksversion': '24',
'name': 'Fedora Server Live', 'name': 'Fedora Server Live',
'release': '20151203.0', 'release': '20151203.t.0',
'repo': ['http://example.com/extra_repo', 'repo': ['http://example.com/extra_repo',
self.topdir + '/compose/Everything/$basearch/os', self.topdir + '/compose/Everything/$basearch/os',
self.topdir + '/compose/Server/$basearch/os'], self.topdir + '/compose/Server/$basearch/os'],