Move buildinstall results to final directories if using pungi-buildinstall Koji plugin.

If Koji pungi-buildinstall is used, then the buildinstall results are
stored in the `output_dir` dir, but in "results" and "logs" subdirectories.
We need to move them to final_output_dir.

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
This commit is contained in:
Jan Kaluza 2020-03-03 08:07:42 +01:00
parent 3cd94a4aa5
commit 145c3adbef
4 changed files with 80 additions and 2 deletions

View file

@ -1200,8 +1200,9 @@ class BuildinstallThreadTestCase(PungiTestCase):
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
@mock.patch("pungi.wrappers.kojiwrapper.get_buildroot_rpms")
@mock.patch("pungi.phases.buildinstall.run")
@mock.patch("pungi.phases.buildinstall.move_all")
def test_buildinstall_thread_with_lorax_using_koji_plugin(
self, run, get_buildroot_rpms, KojiWrapperMock, mock_tweak, mock_link
self, move_all, run, get_buildroot_rpms, KojiWrapperMock, mock_tweak, mock_link
):
compose = BuildInstallCompose(
self.topdir,
@ -1284,6 +1285,17 @@ class BuildinstallThreadTestCase(PungiTestCase):
mock_link.call_args_list,
[mock.call(compose, "x86_64", compose.variants["Server"], False)],
)
self.assertEqual(
move_all.call_args_list,
[
mock.call(os.path.join(destdir, "results"), destdir, rm_src_dir=True),
mock.call(
os.path.join(destdir, "logs"),
os.path.join(self.topdir, "logs/x86_64/buildinstall-Server-logs"),
rm_src_dir=True,
),
],
)
@mock.patch("pungi.phases.buildinstall.link_boot_iso")
@mock.patch("pungi.phases.buildinstall.tweak_buildinstall")

View file

@ -1008,6 +1008,30 @@ class TestCopyAll(PungiTestCase):
self.assertEqual(os.readlink(os.path.join(self.dst, "symlink")), "broken")
class TestMoveAll(PungiTestCase):
def setUp(self):
super(TestMoveAll, self).setUp()
self.src = os.path.join(self.topdir, "src")
self.dst = os.path.join(self.topdir, "dst")
util.makedirs(self.src)
def test_move_all(self):
touch(os.path.join(self.src, "target"))
util.move_all(self.src, self.dst)
self.assertTrue(os.path.isfile(os.path.join(self.dst, "target")))
self.assertTrue(os.path.exists(os.path.join(self.src)))
self.assertFalse(os.path.isfile(os.path.join(self.src, "target")))
def test_move_all_rm_src_dir(self):
touch(os.path.join(self.src, "target"))
util.move_all(self.src, self.dst, rm_src_dir=True)
self.assertTrue(os.path.isfile(os.path.join(self.dst, "target")))
self.assertFalse(os.path.exists(os.path.join(self.src)))
self.assertFalse(os.path.isfile(os.path.join(self.src, "target")))
@mock.patch("six.moves.urllib.request.urlretrieve")
class TestAsLocalFile(PungiTestCase):
def test_local_file(self, urlretrieve):