示例#1
0
    def install_image_task_failed_return_code_test(self, exec_with_redirect,
                                                   create_rescue_image_mock):
        """Test installation from an image task with bad return code."""
        dest_path = "/destination/path"
        kernel_version_list = ["kernel-v1.fc2000.x86_64", "kernel-sad-kernel"]
        source = Mock()
        exec_with_redirect.return_value = 11

        with self.assertLogs(level="INFO") as cm:
            with self.assertRaises(InstallError):
                InstallFromImageTask(dest_path, kernel_version_list,
                                     source).run()

            self.assertTrue(
                any(map(lambda x: "exited with code 11" in x, cm.output)))

        expected_rsync_args = [
            "-pogAXtlHrDx", "--exclude", "/dev/", "--exclude", "/proc/",
            "--exclude", "/tmp/*", "--exclude", "/sys/", "--exclude", "/run/",
            "--exclude", "/boot/*rescue*", "--exclude", "/boot/loader/",
            "--exclude", "/boot/efi/loader/", "--exclude", "/etc/machine-id",
            INSTALL_TREE + "/", dest_path
        ]

        exec_with_redirect.assert_called_once_with("rsync",
                                                   expected_rsync_args)
        create_rescue_image_mock.assert_not_called()
示例#2
0
    def install_with_tasks(self):
        """Install the payload."""
        self._check_source_availability(
            "Installation task failed - source is not available!")

        return [
            InstallFromImageTask(self._image_source, conf.target.system_root)
        ]
示例#3
0
    def install_with_tasks(self):
        """Install the payload."""
        if url_target_is_tarfile(self._url):
            task = InstallFromTarTask(
                self.image_path,
                conf.target.system_root,
                self.kernel_version_list
            )
        else:
            task = InstallFromImageTask(
                conf.target.system_root,
                self.kernel_version_list
            )

        return [task]
    def install_image_task_source_unready_test(self, exec_with_redirect):
        """Test installation from an image task when source is not ready."""
        dest_path = "/destination/path"
        source = Mock()
        exec_with_redirect.return_value = 0

        InstallFromImageTask(dest_path, source).run()

        expected_rsync_args = ["-pogAXtlHrDx", "--exclude", "/dev/", "--exclude", "/proc/",
                               "--exclude", "/tmp/*", "--exclude", "/sys/", "--exclude", "/run/",
                               "--exclude", "/boot/*rescue*", "--exclude", "/boot/loader/",
                               "--exclude", "/boot/efi/loader/",
                               "--exclude", "/etc/machine-id", INSTALL_TREE + "/", dest_path]

        exec_with_redirect.assert_called_once_with("rsync", expected_rsync_args)
    def install_image_task_failed_exception_test(self, exec_with_redirect):
        """Test installation from an image task with exception."""
        dest_path = "/destination/path"
        source = Mock()
        exec_with_redirect.side_effect = OSError("mock exception")

        with self.assertLogs(level="ERROR") as cm:
            with self.assertRaises(InstallError):
                InstallFromImageTask(dest_path, source).run()

            self.assertTrue(any(map(lambda x: "mock exception" in x, cm.output)))

        expected_rsync_args = ["-pogAXtlHrDx", "--exclude", "/dev/", "--exclude", "/proc/",
                               "--exclude", "/tmp/*", "--exclude", "/sys/", "--exclude", "/run/",
                               "--exclude", "/boot/*rescue*", "--exclude", "/boot/loader/",
                               "--exclude", "/boot/efi/loader/",
                               "--exclude", "/etc/machine-id", INSTALL_TREE + "/", dest_path]

        exec_with_redirect.assert_called_once_with("rsync", expected_rsync_args)
示例#6
0
    def install_image_task_test(self, exec_with_redirect,
                                create_rescue_image_mock):
        """Test installation from an image task."""
        dest_path = "/destination/path"
        kernel_version_list = ["kernel-v1.fc2000.x86_64", "kernel-sad-kernel"]
        source = Mock()
        exec_with_redirect.return_value = 0

        InstallFromImageTask(dest_path, kernel_version_list, source).run()

        expected_rsync_args = [
            "-pogAXtlHrDx", "--exclude", "/dev/", "--exclude", "/proc/",
            "--exclude", "/tmp/*", "--exclude", "/sys/", "--exclude", "/run/",
            "--exclude", "/boot/*rescue*", "--exclude", "/boot/loader/",
            "--exclude", "/boot/efi/loader/", "--exclude", "/etc/machine-id",
            INSTALL_TREE + "/", dest_path
        ]

        exec_with_redirect.assert_called_once_with("rsync",
                                                   expected_rsync_args)
        create_rescue_image_mock.assert_called_once_with(
            dest_path, kernel_version_list)
示例#7
0
    def test_install_image_task_failed_return_code(self, exec_with_redirect):
        """Test installation from an image task with bad return code."""
        dest_path = "/destination/path"
        source = Mock()
        exec_with_redirect.return_value = 11

        with self.assertLogs(level="INFO") as cm:
            with self.assertRaises(PayloadInstallationError):
                InstallFromImageTask(dest_path, source).run()

            self.assertTrue(
                any(map(lambda x: "exited with code 11" in x, cm.output)))

        expected_rsync_args = [
            "-pogAXtlHrDx", "--exclude", "/dev/", "--exclude", "/proc/",
            "--exclude", "/tmp/*", "--exclude", "/sys/", "--exclude", "/run/",
            "--exclude", "/boot/*rescue*", "--exclude", "/boot/loader/",
            "--exclude", "/boot/efi/loader/", "--exclude", "/etc/machine-id",
            INSTALL_TREE + "/", dest_path
        ]

        exec_with_redirect.assert_called_once_with("rsync",
                                                   expected_rsync_args)