Exemplo n.º 1
0
    def test_upgrade_common(self, m_verify_package_version, m_get_system_type):
        expected_system_type = 'deb'

        def make_remote():
            remote = Mock()
            remote.arch = 'x86_64'
            remote.os = Mock()
            remote.os.name = 'ubuntu'
            remote.os.version = '14.04'
            remote.os.codename = 'trusty'
            remote.system_type = expected_system_type
            return remote

        ctx = Mock()

        class cluster:
            remote1 = make_remote()
            remote2 = make_remote()
            remotes = {
                remote1: ['client.0'],
                remote2: ['mon.a', 'osd.0'],
            }

            def only(self, role):
                result = Mock()
                if role in ('client.0', ):
                    result.remotes = {cluster.remote1: None}
                if role in ('osd.0', 'mon.a'):
                    result.remotes = {cluster.remote2: None}
                return result

        ctx.cluster = cluster()
        config = {
            'client.0': {
                'sha1': 'expectedsha1',
            },
        }
        ctx.config = {
            'roles': [['client.0'], ['mon.a', 'osd.0']],
            'tasks': [
                {
                    'install.upgrade': config,
                },
            ],
        }
        m_get_system_type.return_value = "deb"

        def upgrade(ctx, node, remote, pkgs, system_type):
            assert system_type == expected_system_type

        assert install.upgrade_common(ctx, config, upgrade) == 1
        expected_config = {
            'project': 'ceph',
            'sha1': 'expectedsha1',
        }
        m_verify_package_version.assert_called_with(ctx, expected_config,
                                                    cluster.remote1)
Exemplo n.º 2
0
    def test_upgrade_common(self,
                            m_get_upgrade_version,
                            m_verify_package_version,
                            m_get_system_type,
                            m_get_package_version):
        expected_system_type = 'deb'
        def make_remote():
            remote = Mock()
            remote.arch = 'x86_64'
            remote.os = Mock()
            remote.os.name = 'ubuntu'
            remote.os.version = '14.04'
            remote.os.codename = 'trusty'
            remote.system_type = expected_system_type
            return remote
        ctx = Mock()
        class cluster:
            remote1 = make_remote()
            remote2 = make_remote()
            remotes = {
                remote1: ['client.0'],
                remote2: ['mon.a','osd.0'],
            }
            def only(self, role):
                result = Mock()
                if role in ('client.0',):
                    result.remotes = { cluster.remote1: None }
                if role in ('osd.0', 'mon.a'):
                    result.remotes = { cluster.remote2: None }
                return result
        ctx.cluster = cluster()
        config = {
            'client.0': {
                'sha1': 'expectedsha1',
            },
        }
        ctx.config = {
            'roles': [ ['client.0'], ['mon.a','osd.0'] ],
            'tasks': [
                {
                    'install.upgrade': config,
                },
            ],
        }
	m_get_upgrade_version.return_value = "11.0.0"
        m_get_package_version.return_value = "10.2.4"
        m_get_system_type.return_value = "deb"
        def upgrade(ctx, node, remote, pkgs, system_type):
            assert system_type == expected_system_type
        assert install.upgrade_common(ctx, config, upgrade) == 1
        expected_config = {
            'project': 'ceph',
            'sha1': 'expectedsha1',
        }
        m_verify_package_version.assert_called_with(ctx,
                                                    expected_config,
                                                    cluster.remote1)