Merge #381 Automatically generate missing image version

This commit is contained in:
Dennis Gilmore 2016-09-06 15:19:55 +00:00
commit 6aeab9ee9d
11 changed files with 141 additions and 16 deletions

View file

@ -37,6 +37,7 @@ class DummyCompose(object):
self.compose_label = None
self.compose_label_major_version = None
self.image_release = '20151203.t.0'
self.image_version = '25'
self.ci_base = mock.Mock(
release_id='Test-1.0',
release=mock.Mock(

View file

@ -127,12 +127,12 @@ class ComposeTestCase(unittest.TestCase):
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'
ci.return_value.compose.type_suffix = ''
ci.return_value.compose.label = None
compose = Compose(conf, self.tmp_dir)
self.assertEqual(compose.image_release, '20160107.n.2')
self.assertEqual(compose.image_release, '20160107.2')
@mock.patch('pungi.compose.ComposeInfo')
def test_image_release_from_label(self, ci):
@ -147,6 +147,48 @@ class ComposeTestCase(unittest.TestCase):
self.assertEqual(compose.image_release, '1.2')
@mock.patch('pungi.compose.ComposeInfo')
def test_image_version_without_label(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'
ci.return_value.compose.label = None
ci.return_value.release.version = '25'
compose = Compose(conf, self.tmp_dir)
self.assertEqual(compose.image_version, '25')
@mock.patch('pungi.compose.ComposeInfo')
def test_image_version_with_label(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'
ci.return_value.compose.label = 'Alpha-1.2'
ci.return_value.release.version = '25'
compose = Compose(conf, self.tmp_dir)
self.assertEqual(compose.image_version, '25_Alpha')
@mock.patch('pungi.compose.ComposeInfo')
def test_image_version_with_label_rc(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'
ci.return_value.compose.label = 'RC-1.2'
ci.return_value.release.version = '25'
compose = Compose(conf, self.tmp_dir)
self.assertEqual(compose.image_version, '25')
@mock.patch('pungi.compose.ComposeInfo')
def test_get_variant_arches_without_filter(self, ci):
conf = ConfigWrapper(

View file

@ -169,6 +169,65 @@ class TestImageBuildPhase(PungiTestCase):
self.assertItemsEqual(phase.pool.queue_put.mock_calls,
[mock.call((compose, server_args))])
@mock.patch('pungi.phases.image_build.ThreadPool')
def test_image_build_phase_missing_version(self, ThreadPool):
compose = DummyCompose(self.topdir, {
'image_build_ksurl': 'git://git.fedorahosted.org/git/spin-kickstarts.git',
'image_build_release': None,
'image_build_target': 'f24',
'image_build': {
'^Server$': [
{
'image-build': {
'format': [('docker', 'tar.xz')],
'name': 'Fedora-Docker-Base',
'kickstart': "fedora-docker-base.ks",
'distro': 'Fedora-20',
'disk_size': 3
}
}
]
},
'koji_profile': 'koji',
})
phase = ImageBuildPhase(compose)
phase.run()
self.maxDiff = None
# assert at least one thread was started
self.assertTrue(phase.pool.add.called)
server_args = {
"format": [('docker', 'tar.xz')],
"image_conf": {
'image-build': {
'install_tree': self.topdir + '/compose/Server/$arch/os',
'kickstart': 'fedora-docker-base.ks',
'format': 'docker',
'repo': self.topdir + '/compose/Server/$arch/os',
'variant': compose.variants['Server'],
'target': 'f24',
'disk_size': 3,
'name': 'Fedora-Docker-Base',
'arches': 'amd64,x86_64',
'version': '25',
'ksurl': 'git://git.fedorahosted.org/git/spin-kickstarts.git',
'distro': 'Fedora-20',
'release': '20151203.t.0',
}
},
"conf_file": self.topdir + '/work/image-build/Server/docker_Fedora-Docker-Base.cfg',
"image_dir": self.topdir + '/compose/Server/%(arch)s/images',
"relative_image_dir": 'Server/%(arch)s/images',
"link_type": 'hardlink-or-copy',
"scratch": False,
"failable_arches": [],
}
self.maxDiff = None
self.assertItemsEqual(phase.pool.queue_put.mock_calls,
[mock.call((compose, server_args))])
@mock.patch('pungi.phases.image_build.ThreadPool')
def test_image_build_filter_all_variants(self, ThreadPool):
compose = DummyCompose(self.topdir, {

View file

@ -53,7 +53,7 @@ class TestLiveImagesPhase(PungiTestCase):
'label': '',
'name': None,
'filename': 'image-name',
'version': None,
'version': '25',
'specfile': None,
'sign': False,
'type': 'live',
@ -104,7 +104,7 @@ class TestLiveImagesPhase(PungiTestCase):
'label': '',
'name': None,
'filename': 'image-name',
'version': None,
'version': '25',
'specfile': None,
'sign': False,
'type': 'live',
@ -152,7 +152,7 @@ class TestLiveImagesPhase(PungiTestCase):
'label': '',
'name': None,
'filename': None,
'version': None,
'version': '25',
'specfile': None,
'sign': False,
'type': 'live',
@ -202,7 +202,7 @@ class TestLiveImagesPhase(PungiTestCase):
'label': '',
'name': None,
'filename': 'image-name',
'version': None,
'version': '25',
'specfile': None,
'sign': False,
'type': 'live',
@ -223,7 +223,7 @@ class TestLiveImagesPhase(PungiTestCase):
'label': '',
'name': None,
'filename': 'image-name',
'version': None,
'version': '25',
'specfile': None,
'sign': False,
'type': 'live',
@ -274,7 +274,7 @@ class TestLiveImagesPhase(PungiTestCase):
'label': '',
'name': None,
'filename': 'image-name',
'version': None,
'version': '25',
'specfile': None,
'sign': False,
'type': 'appliance',
@ -434,7 +434,7 @@ class TestLiveImagesPhase(PungiTestCase):
'label': '',
'name': None,
'filename': 'image-name',
'version': None,
'version': '25',
'specfile': None,
'sign': False,
'type': 'live',

View file

@ -331,7 +331,6 @@ class TestLiveMediaPhase(PungiTestCase):
'arches': ['x86_64'],
'ksversion': '24',
'release': None,
'version': 'Rawhide',
'install_tree_from': 'Everything',
'subvariant': 'Something',
'failable': ['*'],
@ -366,7 +365,7 @@ class TestLiveMediaPhase(PungiTestCase):
'target': 'f24',
'title': 'Custom Title',
'install_tree': self.topdir + '/compose/Everything/$basearch/os',
'version': 'Rawhide',
'version': '25',
'subvariant': 'Something',
'failable_arches': ['*'],
}))])