From bb4afea4f16c593d693a6c17949ca0cc18de2f6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Mon, 23 May 2016 15:23:12 +0200 Subject: [PATCH] [image-build] Allow using external install trees MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is needed for the twoweek Fedora atomic release to point to regular nightly composes. Signed-off-by: Lubomír Sedlář --- pungi/phases/image_build.py | 2 ++ tests/test_imagebuildphase.py | 60 +++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/pungi/phases/image_build.py b/pungi/phases/image_build.py index b45dae3f..dcd74d3f 100644 --- a/pungi/phases/image_build.py +++ b/pungi/phases/image_build.py @@ -57,6 +57,8 @@ class ImageBuildPhase(base.ImageConfigMixin, base.ConfigGuardedPhase): dict. """ install_tree_from = image_conf.pop('install_tree_from', variant.uid) + if '://' in install_tree_from: + return install_tree_from install_tree_source = self.compose.variants.get(install_tree_from) if not install_tree_source: raise RuntimeError( diff --git a/tests/test_imagebuildphase.py b/tests/test_imagebuildphase.py index 87fa84bb..33933c31 100755 --- a/tests/test_imagebuildphase.py +++ b/tests/test_imagebuildphase.py @@ -309,6 +309,66 @@ class TestImageBuildPhase(PungiTestCase): "scratch": False, }) + @mock.patch('pungi.phases.image_build.ThreadPool') + def test_image_build_set_external_install_tree(self, ThreadPool): + compose = DummyCompose(self.topdir, { + 'image_build': { + '^Server$': [ + { + 'image-build': { + 'format': [('docker', 'tar.xz')], + 'name': 'Fedora-Docker-Base', + 'target': 'f24', + 'version': 'Rawhide', + 'ksurl': 'git://git.fedorahosted.org/git/spin-kickstarts.git', + 'kickstart': "fedora-docker-base.ks", + 'distro': 'Fedora-20', + 'disk_size': 3, + 'arches': ['x86_64'], + 'install_tree_from': 'http://example.com/install-tree/', + } + } + ] + }, + 'koji_profile': 'koji', + }) + + phase = ImageBuildPhase(compose) + + phase.run() + + # assert at least one thread was started + self.assertTrue(phase.pool.add.called) + + self.assertTrue(phase.pool.queue_put.called_once) + args, kwargs = phase.pool.queue_put.call_args + self.assertEqual(args[0][0], compose) + self.maxDiff = None + self.assertDictEqual(args[0][1], { + "format": [('docker', 'tar.xz')], + "image_conf": { + 'image-build': { + 'install_tree': 'http://example.com/install-tree/', + 'kickstart': 'fedora-docker-base.ks', + 'format': 'docker', + 'repo': ','.join([self.topdir + '/compose/Server/$arch/os']), + 'variant': compose.variants['Server'], + 'target': 'f24', + 'disk_size': 3, + 'name': 'Fedora-Docker-Base', + 'arches': 'x86_64', + 'version': 'Rawhide', + 'ksurl': 'git://git.fedorahosted.org/git/spin-kickstarts.git', + 'distro': 'Fedora-20', + } + }, + "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, + }) + @mock.patch('pungi.phases.image_build.ThreadPool') def test_image_build_create_release(self, ThreadPool): compose = DummyCompose(self.topdir, {