class TestHostSystemUpgrader(BaseTestCase):

    def setUp(self):
        self.upgrader = HostSystemUpgrader(self.fake_config)

    @mock.patch(
        'fuel_upgrade.engines.host_system.HostSystemUpgrader.update_repo')
    @mock.patch(
        'fuel_upgrade.engines.host_system.HostSystemUpgrader.run_puppet')
    def test_upgrade(self, run_puppet_mock, update_repo_mock):
        self.upgrader.upgrade()

        self.called_once(run_puppet_mock)
        self.called_once(update_repo_mock)

    @mock.patch('fuel_upgrade.engines.host_system.utils')
    def test_update_repo(self, utils_mock):
        self.upgrader.update_repo()
        templates_path = os.path.abspath(
            os.path.join(os.path.dirname(__file__), '../templates'))
        utils_mock.render_template_to_file.assert_called_once_with(
            '{0}/nailgun.repo'.format(templates_path),
            '/etc/yum.repos.d/9999_nailgun.repo',
            {'version': '9999',
             'repo_path': '/tmp/upgrade_path/repos/centos/x86_64'})

    @mock.patch('fuel_upgrade.engines.host_system.utils')
    def test_run_puppet(self, utils_mock):
        self.upgrader.run_puppet()
        utils_mock.exec_cmd.assert_called_once_with(
            'puppet apply -d -v '
            '/tmp/upgrade_path/puppet/modules/nailgun/examples/host-only.pp '
            '--modulepath=/tmp/upgrade_path/puppet/modules/')

    @mock.patch(
        'fuel_upgrade.engines.host_system.'
        'HostSystemUpgrader.remove_repo_config')
    def test_rollback(self, remove_repo_config_mock):
        self.upgrader.rollback()
        self.called_once(remove_repo_config_mock)

    @mock.patch('fuel_upgrade.engines.host_system.utils')
    def test_remove_repo_config(self, utils_mock):
        self.upgrader.remove_repo_config()
        utils_mock.remove_if_exists.assert_called_once_with(
            '/etc/yum.repos.d/9999_nailgun.repo')

    def test_required_free_space(self):
        self.assertEqual(
            self.upgrader.required_free_space,
            {'/etc/yum.repos.d/9999_nailgun.repo': 10})
    def test_hostsystem_rollback_is_first(self, _):
        args = self.default_args()

        hostsystem = HostSystemUpgrader(args['config'])
        hostsystem.upgrade = mock.Mock()
        hostsystem.rollback = mock.Mock()

        def check_call():
            hostsystem.rollback.assert_called_once_with()

        # there's no way to check call order of different mocks, so
        # let's use this trick - check that all mock calls were
        # after hostsystem rollback call.
        args['upgraders'] = [
            hostsystem,
            mock.Mock(rollback=mock.Mock(side_effect=check_call)),
            mock.Mock(rollback=mock.Mock(side_effect=check_call))]

        upgrader = UpgradeManager(**args)
        upgrader._used_upgraders = args['upgraders']
        upgrader.rollback()
Пример #3
0
    def test_hostsystem_rollback_is_first(self, _):
        args = self.default_args()

        hostsystem = HostSystemUpgrader(args['config'])
        hostsystem.upgrade = mock.Mock()
        hostsystem.rollback = mock.Mock()

        def check_call():
            hostsystem.rollback.assert_called_once_with()

        # there's no way to check call order of different mocks, so
        # let's use this trick - check that all mock calls were
        # after hostsystem rollback call.
        args['upgraders'] = [
            hostsystem,
            mock.Mock(rollback=mock.Mock(side_effect=check_call)),
            mock.Mock(rollback=mock.Mock(side_effect=check_call))
        ]

        upgrader = UpgradeManager(**args)
        upgrader._used_upgraders = args['upgraders']
        upgrader.rollback()
Пример #4
0
 def setUp(self):
     self.upgrader = HostSystemUpgrader(self.fake_config)
Пример #5
0
class TestHostSystemUpgrader(BaseTestCase):

    def setUp(self):
        self.upgrader = HostSystemUpgrader(self.fake_config)

    @mock.patch(
        'fuel_upgrade.engines.host_system.HostSystemUpgrader.update_repo')
    @mock.patch(
        'fuel_upgrade.engines.host_system.HostSystemUpgrader.run_puppet')
    @mock.patch(
        'fuel_upgrade.engines.host_system.utils')
    def test_upgrade(self, mock_utils, run_puppet_mock, update_repo_mock):
        self.upgrader.upgrade()

        mock_utils.copy.assert_called_once_with(
            '/tmp/upgrade_path/repos/2014.1.1-5.1/centos/x86_64',
            '/var/www/nailgun/2014.1.1-5.1/centos/x86_64')
        self.called_once(run_puppet_mock)
        self.called_once(update_repo_mock)

    @mock.patch('fuel_upgrade.engines.host_system.utils')
    def test_update_repo(self, utils_mock):
        self.upgrader.update_repo()
        templates_path = os.path.abspath(
            os.path.join(os.path.dirname(__file__), '../templates'))
        utils_mock.render_template_to_file.assert_called_once_with(
            '{0}/nailgun.repo'.format(templates_path),
            '/etc/yum.repos.d/9999_nailgun.repo',
            {'version': '9999',
             'repo_path': '/var/www/nailgun/2014.1.1-5.1/centos/x86_64'})

    @mock.patch('fuel_upgrade.engines.host_system.utils')
    def test_run_puppet(self, utils_mock):
        self.upgrader.run_puppet()
        utils_mock.exec_cmd.assert_called_once_with(
            'puppet apply -d -v '
            '/tmp/upgrade_path/puppet/2014.1.1-5.1/modules/nailgun/examples'
            '/host-upgrade.pp '
            '--modulepath=/tmp/upgrade_path/puppet/2014.1.1-5.1/modules')

    @mock.patch(
        'fuel_upgrade.engines.host_system.'
        'HostSystemUpgrader.remove_repo_config')
    def test_rollback(self, remove_repo_config_mock):
        self.upgrader.rollback()
        self.called_once(remove_repo_config_mock)

    def test_on_success_does_not_raise_exceptions(self):
        self.upgrader.on_success()

    @mock.patch('fuel_upgrade.engines.host_system.utils')
    def test_remove_repo_config(self, utils_mock):
        self.upgrader.remove_repo_config()
        utils_mock.remove_if_exists.assert_called_once_with(
            '/etc/yum.repos.d/9999_nailgun.repo')

    def test_required_free_space(self):
        self.assertEqual(
            self.upgrader.required_free_space,
            {'/etc/yum.repos.d/9999_nailgun.repo': 10})
 def setUp(self):
     with mock.patch('fuel_upgrade.engines.host_system.SupervisorClient'):
         self.upgrader = HostSystemUpgrader(self.fake_config)
     self.upgrader.supervisor = mock.Mock()
class TestHostSystemUpgrader(BaseTestCase):

    def setUp(self):
        with mock.patch('fuel_upgrade.engines.host_system.SupervisorClient'):
            self.upgrader = HostSystemUpgrader(self.fake_config)
        self.upgrader.supervisor = mock.Mock()

    @mock.patch.multiple(
        'fuel_upgrade.engines.host_system.HostSystemUpgrader',
        install_repos=mock.DEFAULT,
        update_repo=mock.DEFAULT,
        run_puppet=mock.DEFAULT,
        remove_repo_config=mock.DEFAULT
    )
    @mock.patch('fuel_upgrade.engines.host_system.utils')
    def test_upgrade(self, mock_utils, install_repos, update_repo,
                     run_puppet, remove_repo_config):
        self.upgrader.upgrade()
        self.called_once(install_repos)
        self.called_once(run_puppet)
        self.called_once(update_repo)
        self.called_once(remove_repo_config)
        self.called_once(self.upgrader.supervisor.stop_all_services)
        mock_utils.exec_cmd.assert_called_with(
            'yum install -v -y fuel-9999.0.0')

    @mock.patch('fuel_upgrade.engines.host_system.utils')
    def test_update_repo(self, utils_mock):
        self.upgrader.update_repo()
        templates_path = os.path.abspath(
            os.path.join(os.path.dirname(__file__), '../templates'))
        utils_mock.render_template_to_file.assert_called_once_with(
            '{0}/nailgun.repo'.format(templates_path),
            '/etc/yum.repos.d/9999_nailgun.repo',
            {
                'name': '9999_nailgun',
                'baseurl': 'file:/var/www/nailgun/2014.1.1-5.1/centos/x86_64',
                'gpgcheck': 0,
                'skip_if_unavailable': 0,
            })

    @mock.patch('fuel_upgrade.engines.host_system.utils')
    def test_run_puppet(self, utils_mock):
        self.upgrader.run_puppet()
        utils_mock.exec_cmd.assert_called_once_with(
            'puppet apply -d -v '
            '/etc/puppet/2014.1.1-5.1/modules/nailgun/examples'
            '/host-upgrade.pp '
            '--modulepath=/etc/puppet/2014.1.1-5.1/modules')

    @mock.patch.multiple(
        'fuel_upgrade.engines.host_system.HostSystemUpgrader',
        remove_repos=mock.DEFAULT,
        remove_repo_config=mock.DEFAULT,
    )
    def test_rollback(self, remove_repos, remove_repo_config):
        self.upgrader.rollback()
        self.called_once(remove_repos)
        self.called_once(remove_repo_config)
        self.called_once(self.upgrader.supervisor.start_all_services)

    @mock.patch('fuel_upgrade.engines.host_system.utils.remove_if_exists')
    def test_remove_repo_config(self, remove_mock):
        self.upgrader.config.from_version = '6.0'
        self.upgrader.remove_repo_config()
        self.assertEqual(remove_mock.call_args_list, [
            mock.call('/etc/yum.repos.d/9999_nailgun.repo'),
            mock.call('/etc/yum.repos.d/auxiliary.repo'),
        ])

    @mock.patch('fuel_upgrade.engines.host_system.utils.remove_if_exists')
    def test_remove_repo_config_for_fuel_ge_61(self, remove_mock):
        self.upgrader.config.from_version = '6.1'
        self.upgrader.config.new_version = '7.0'
        self.upgrader.remove_repo_config()
        self.assertEqual(remove_mock.call_args_list, [
            mock.call('/etc/yum.repos.d/9999_nailgun.repo'),
            mock.call('/etc/yum.repos.d/7.0_auxiliary.repo'),
        ])

    @mock.patch('fuel_upgrade.engines.host_system.utils.copy')
    @mock.patch('fuel_upgrade.engines.host_system.glob.glob')
    def test_install_repos(self, glob, copy):
        glob.return_value = ['one', 'two']
        self.upgrader.install_repos()

        self.called_times(copy, 2)

        copy.assert_has_calls([
            mock.call('one', '/var/www/nailgun/one'),
            mock.call('two', '/var/www/nailgun/two')])
        glob.assert_called_with('/tmp/upgrade_path/repos/[0-9.-]*')

    @mock.patch('fuel_upgrade.engines.host_system.utils.remove')
    @mock.patch('fuel_upgrade.engines.host_system.glob.glob')
    def test_remove_repos(self, glob, remove):
        glob.return_value = ['one', 'two']
        self.upgrader.remove_repos()

        self.called_times(remove, 2)

        remove.assert_has_calls([
            mock.call('/var/www/nailgun/one'),
            mock.call('/var/www/nailgun/two')])
        glob.assert_called_with('/tmp/upgrade_path/repos/[0-9.-]*')

    @mock.patch(
        'fuel_upgrade.engines.openstack.utils.os.path.isdir',
        return_value=True)
    @mock.patch(
        'fuel_upgrade.engines.openstack.utils.dir_size', return_value=42)
    @mock.patch(
        'fuel_upgrade.engines.openstack.glob.glob', return_value=['1', '2'])
    def test_required_free_space(self, glob, __, ___):
        self.assertEqual(
            self.upgrader.required_free_space,
            {'/etc/yum.repos.d/9999_nailgun.repo': 10,
             '/var/www/nailgun': 84})
        glob.assert_called_with('/tmp/upgrade_path/repos/[0-9.-]*')
class TestHostSystemUpgrader(BaseTestCase):

    def setUp(self):
        self.upgrader = HostSystemUpgrader(self.fake_config)

    @mock.patch(
        'fuel_upgrade.engines.host_system.HostSystemUpgrader.update_repo')
    @mock.patch(
        'fuel_upgrade.engines.host_system.HostSystemUpgrader.run_puppet')
    @mock.patch(
        'fuel_upgrade.engines.host_system.utils')
    def test_upgrade(self, mock_utils, run_puppet_mock, update_repo_mock):
        self.upgrader.upgrade()

        mock_utils.copy.assert_called_once_with(
            '/tmp/upgrade_path/repos/2014.1.1-5.1/centos/x86_64',
            '/var/www/nailgun/2014.1.1-5.1/centos/x86_64')
        self.called_once(run_puppet_mock)
        self.called_once(update_repo_mock)
        mock_utils.exec_cmd.assert_called_with(
            'yum install -v -y fuel-release-9999.0.0')

    @mock.patch('fuel_upgrade.engines.host_system.utils')
    def test_update_repo(self, utils_mock):
        self.upgrader.update_repo()
        templates_path = os.path.abspath(
            os.path.join(os.path.dirname(__file__), '../templates'))
        utils_mock.render_template_to_file.assert_called_once_with(
            '{0}/nailgun.repo'.format(templates_path),
            '/etc/yum.repos.d/9999_nailgun.repo',
            {'version': '9999',
             'repo_path': '/var/www/nailgun/2014.1.1-5.1/centos/x86_64'})

    @mock.patch('fuel_upgrade.engines.host_system.utils')
    def test_run_puppet(self, utils_mock):
        self.upgrader.run_puppet()
        utils_mock.exec_cmd.assert_called_once_with(
            'puppet apply -d -v '
            '/etc/puppet/2014.1.1-5.1/modules/nailgun/examples'
            '/host-upgrade.pp '
            '--modulepath=/etc/puppet/2014.1.1-5.1/modules')

    @mock.patch(
        'fuel_upgrade.engines.host_system.'
        'HostSystemUpgrader.remove_repo_config')
    def test_rollback(self, remove_repo_config_mock):
        self.upgrader.rollback()
        self.called_once(remove_repo_config_mock)

    def test_on_success_does_not_raise_exceptions(self):
        self.upgrader.on_success()

    @mock.patch('fuel_upgrade.engines.host_system.utils')
    def test_remove_repo_config(self, utils_mock):
        self.upgrader.remove_repo_config()
        utils_mock.remove_if_exists.assert_called_once_with(
            '/etc/yum.repos.d/9999_nailgun.repo')

    def test_required_free_space(self):
        self.assertEqual(
            self.upgrader.required_free_space,
            {'/etc/yum.repos.d/9999_nailgun.repo': 10})
Пример #9
0
 def setUp(self):
     with mock.patch('fuel_upgrade.engines.host_system.SupervisorClient'):
         self.upgrader = HostSystemUpgrader(self.fake_config)
     self.upgrader.supervisor = mock.Mock()
Пример #10
0
class TestHostSystemUpgrader(BaseTestCase):

    def setUp(self):
        with mock.patch('fuel_upgrade.engines.host_system.SupervisorClient'):
            self.upgrader = HostSystemUpgrader(self.fake_config)
        self.upgrader.supervisor = mock.Mock()

    @mock.patch(
        'fuel_upgrade.engines.host_system.HostSystemUpgrader.install_repos')
    @mock.patch(
        'fuel_upgrade.engines.host_system.HostSystemUpgrader.update_repo')
    @mock.patch(
        'fuel_upgrade.engines.host_system.HostSystemUpgrader.run_puppet')
    @mock.patch(
        'fuel_upgrade.engines.host_system.utils')
    def test_upgrade(self, mock_utils, run_puppet_mock, update_repo_mock,
                     install_repos_mock):
        self.upgrader.upgrade()

        self.called_once(install_repos_mock)
        self.called_once(run_puppet_mock)
        self.called_once(update_repo_mock)
        self.called_once(self.upgrader.supervisor.stop_all_services)
        mock_utils.exec_cmd.assert_called_with(
            'yum install -v -y fuel-9999.0.0')

    @mock.patch('fuel_upgrade.engines.host_system.utils')
    def test_update_repo(self, utils_mock):
        self.upgrader.update_repo()
        templates_path = os.path.abspath(
            os.path.join(os.path.dirname(__file__), '../templates'))
        utils_mock.render_template_to_file.assert_called_once_with(
            '{0}/nailgun.repo'.format(templates_path),
            '/etc/yum.repos.d/9999_nailgun.repo',
            {
                'name': '9999_nailgun',
                'baseurl': 'file:/var/www/nailgun/2014.1.1-5.1/centos/x86_64',
                'gpgcheck': 0,
                'skip_if_unavailable': 0,
            })

    @mock.patch('fuel_upgrade.engines.host_system.utils')
    def test_run_puppet(self, utils_mock):
        self.upgrader.run_puppet()
        utils_mock.exec_cmd.assert_called_once_with(
            'puppet apply -d -v '
            '/etc/puppet/2014.1.1-5.1/modules/nailgun/examples'
            '/host-upgrade.pp '
            '--modulepath=/etc/puppet/2014.1.1-5.1/modules')

    @mock.patch(
        'fuel_upgrade.engines.host_system.HostSystemUpgrader.remove_repos')
    @mock.patch(
        'fuel_upgrade.engines.host_system.'
        'HostSystemUpgrader.remove_repo_config')
    def test_rollback(self, remove_repo_config_mock, remove_repos_mock):
        self.upgrader.rollback()
        self.called_once(remove_repo_config_mock)
        self.called_once(remove_repos_mock)
        self.called_once(self.upgrader.supervisor.start_all_services)

    @mock.patch('fuel_upgrade.engines.host_system.utils.remove_if_exists')
    def test_remove_repo_config(self, remove_mock):
        self.upgrader.config.from_version = '6.0'
        self.upgrader.remove_repo_config()
        self.assertEqual(remove_mock.call_args_list, [
            mock.call('/etc/yum.repos.d/9999_nailgun.repo'),
            mock.call('/etc/yum.repos.d/auxiliary.repo'),
        ])

    @mock.patch('fuel_upgrade.engines.host_system.utils.remove_if_exists')
    def test_remove_repo_config_for_fuel_ge_61(self, remove_mock):
        self.upgrader.config.from_version = '6.1'
        self.upgrader.config.new_version = '7.0'
        self.upgrader.remove_repo_config()
        self.assertEqual(remove_mock.call_args_list, [
            mock.call('/etc/yum.repos.d/9999_nailgun.repo'),
            mock.call('/etc/yum.repos.d/7.0_auxiliary.repo'),
        ])

    @mock.patch('fuel_upgrade.engines.host_system.utils.copy')
    @mock.patch('fuel_upgrade.engines.host_system.glob.glob')
    def test_install_repos(self, glob, copy):
        glob.return_value = ['one', 'two']
        self.upgrader.install_repos()

        self.called_times(copy, 2)

        copy.assert_has_calls([
            mock.call('one', '/var/www/nailgun/one'),
            mock.call('two', '/var/www/nailgun/two')])
        glob.assert_called_with('/tmp/upgrade_path/repos/[0-9.-]*')

    @mock.patch('fuel_upgrade.engines.host_system.utils.remove')
    @mock.patch('fuel_upgrade.engines.host_system.glob.glob')
    def test_remove_repos(self, glob, remove):
        glob.return_value = ['one', 'two']
        self.upgrader.remove_repos()

        self.called_times(remove, 2)

        remove.assert_has_calls([
            mock.call('/var/www/nailgun/one'),
            mock.call('/var/www/nailgun/two')])
        glob.assert_called_with('/tmp/upgrade_path/repos/[0-9.-]*')

    @mock.patch(
        'fuel_upgrade.engines.openstack.utils.os.path.isdir',
        return_value=True)
    @mock.patch(
        'fuel_upgrade.engines.openstack.utils.dir_size', return_value=42)
    @mock.patch(
        'fuel_upgrade.engines.openstack.glob.glob', return_value=['1', '2'])
    def test_required_free_space(self, glob, __, ___):
        self.assertEqual(
            self.upgrader.required_free_space,
            {'/etc/yum.repos.d/9999_nailgun.repo': 10,
             '/var/www/nailgun': 84})
        glob.assert_called_with('/tmp/upgrade_path/repos/[0-9.-]*')
class TestHostSystemUpgrader(BaseTestCase):
    def setUp(self):
        with mock.patch("fuel_upgrade.engines.host_system.SupervisorClient"):
            self.upgrader = HostSystemUpgrader(self.fake_config)
        self.upgrader.supervisor = mock.Mock()

    @mock.patch("fuel_upgrade.engines.host_system.HostSystemUpgrader.install_repos")
    @mock.patch("fuel_upgrade.engines.host_system.HostSystemUpgrader.update_repo")
    @mock.patch("fuel_upgrade.engines.host_system.HostSystemUpgrader.run_puppet")
    @mock.patch("fuel_upgrade.engines.host_system.utils")
    def test_upgrade(self, mock_utils, run_puppet_mock, update_repo_mock, install_repos_mock):
        self.upgrader.upgrade()

        self.called_once(install_repos_mock)
        self.called_once(run_puppet_mock)
        self.called_once(update_repo_mock)
        self.called_once(self.upgrader.supervisor.stop_all_services)
        mock_utils.exec_cmd.assert_called_with("yum install -v -y fuel-9999.0.0")

    @mock.patch("fuel_upgrade.engines.host_system.utils")
    def test_update_repo(self, utils_mock):
        self.upgrader.update_repo()
        templates_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../templates"))
        utils_mock.render_template_to_file.assert_called_once_with(
            "{0}/nailgun.repo".format(templates_path),
            "/etc/yum.repos.d/9999_nailgun.repo",
            {
                "name": "9999_nailgun",
                "baseurl": "file:/var/www/nailgun/2014.1.1-5.1/centos/x86_64",
                "gpgcheck": 0,
                "skip_if_unavailable": 0,
            },
        )

    @mock.patch("fuel_upgrade.engines.host_system.utils")
    def test_run_puppet(self, utils_mock):
        self.upgrader.run_puppet()
        utils_mock.exec_cmd.assert_called_once_with(
            "puppet apply -d -v "
            "/etc/puppet/2014.1.1-5.1/modules/nailgun/examples"
            "/host-upgrade.pp "
            "--modulepath=/etc/puppet/2014.1.1-5.1/modules"
        )

    @mock.patch("fuel_upgrade.engines.host_system.HostSystemUpgrader.remove_repos")
    @mock.patch("fuel_upgrade.engines.host_system." "HostSystemUpgrader.remove_repo_config")
    def test_rollback(self, remove_repo_config_mock, remove_repos_mock):
        self.upgrader.rollback()
        self.called_once(remove_repo_config_mock)
        self.called_once(remove_repos_mock)
        self.called_once(self.upgrader.supervisor.start_all_services)

    @mock.patch("fuel_upgrade.engines.host_system.utils.remove_if_exists")
    def test_remove_repo_config(self, remove_mock):
        self.upgrader.config.from_version = "6.0"
        self.upgrader.remove_repo_config()
        self.assertEqual(
            remove_mock.call_args_list,
            [mock.call("/etc/yum.repos.d/9999_nailgun.repo"), mock.call("/etc/yum.repos.d/auxiliary.repo")],
        )

    @mock.patch("fuel_upgrade.engines.host_system.utils.remove_if_exists")
    def test_remove_repo_config_for_fuel_ge_61(self, remove_mock):
        self.upgrader.config.from_version = "6.1"
        self.upgrader.config.new_version = "7.0"
        self.upgrader.remove_repo_config()
        self.assertEqual(
            remove_mock.call_args_list,
            [mock.call("/etc/yum.repos.d/9999_nailgun.repo"), mock.call("/etc/yum.repos.d/7.0_auxiliary.repo")],
        )

    @mock.patch("fuel_upgrade.engines.host_system.utils.copy")
    @mock.patch("fuel_upgrade.engines.host_system.glob.glob")
    def test_install_repos(self, glob, copy):
        glob.return_value = ["one", "two"]
        self.upgrader.install_repos()

        self.called_times(copy, 2)

        copy.assert_has_calls([mock.call("one", "/var/www/nailgun/one"), mock.call("two", "/var/www/nailgun/two")])
        glob.assert_called_with("/tmp/upgrade_path/repos/[0-9.-]*")

    @mock.patch("fuel_upgrade.engines.host_system.utils.remove")
    @mock.patch("fuel_upgrade.engines.host_system.glob.glob")
    def test_remove_repos(self, glob, remove):
        glob.return_value = ["one", "two"]
        self.upgrader.remove_repos()

        self.called_times(remove, 2)

        remove.assert_has_calls([mock.call("/var/www/nailgun/one"), mock.call("/var/www/nailgun/two")])
        glob.assert_called_with("/tmp/upgrade_path/repos/[0-9.-]*")

    @mock.patch("fuel_upgrade.engines.openstack.utils.os.path.isdir", return_value=True)
    @mock.patch("fuel_upgrade.engines.openstack.utils.dir_size", return_value=42)
    @mock.patch("fuel_upgrade.engines.openstack.glob.glob", return_value=["1", "2"])
    def test_required_free_space(self, glob, __, ___):
        self.assertEqual(
            self.upgrader.required_free_space, {"/etc/yum.repos.d/9999_nailgun.repo": 10, "/var/www/nailgun": 84}
        )
        glob.assert_called_with("/tmp/upgrade_path/repos/[0-9.-]*")