Exemplo n.º 1
0
class TestPluginsPreDeploymentHooksSerializer(
        TestPluginsDeploymentEnvironment):

    def setUp(self):
        super(TestPluginsPreDeploymentHooksSerializer, self).setUp()
        self.hook = PluginsPreDeploymentHooksSerializer(
            self.cluster,
            self.nodes,
            role_resolver=NullResolver([x['id'] for x in self.nodes]))

    @mock.patch(
        'nailgun.orchestrator.plugins_serializers.'
        'templates.make_ubuntu_sources_task',
        return_value={'task_type': 'ubuntu_sources_task',
                      'parameters': {}})
    @mock.patch(
        'nailgun.orchestrator.plugins_serializers.'
        'templates.make_ubuntu_preferences_task',
        return_value=None)
    @mock.patch(
        'nailgun.orchestrator.plugins_serializers.'
        'templates.make_apt_update_task',
        return_value={'task_type': 'apt_update_task',
                      'parameters': {}})
    def test_create_repositories_ubuntu_does_not_generate_prefences_if_none(
            self, *_):
        self.cluster.release.operating_system = consts.RELEASE_OS.ubuntu
        tasks = self.hook.create_repositories(self.plugins)
        self.assertItemsEqual(
            map(lambda t: t['task_type'], tasks),
            ['ubuntu_sources_task',
             'apt_update_task'])

    @mock.patch('nailgun.plugins.manager.PluginManager.'
                'get_enabled_plugins', return_value=[])
    @mock.patch('nailgun.orchestrator.plugins_serializers.'
                'PluginsPreDeploymentHooksSerializer.create_repositories')
    @mock.patch('nailgun.orchestrator.plugins_serializers.'
                'PluginsPreDeploymentHooksSerializer.sync_scripts')
    def test_serialize_begin_tasks(self,
                                   m_sync_scripts,
                                   m_create_repositories,
                                   m_get_enabled_plugins):
        self.hook.serialize_begin_tasks()
        m_get_enabled_plugins.assert_called_once_with(self.cluster)
        m_create_repositories.assert_called_once_with([])
        m_sync_scripts.assert_called_once_with([])

    @mock.patch('nailgun.plugins.manager.PluginManager.'
                'get_enabled_plugins', return_value=[])
    @mock.patch('nailgun.orchestrator.plugins_serializers.'
                'PluginsPreDeploymentHooksSerializer.deployment_tasks')
    def test_serialize_end_tasks(self,
                                 m_deployment_tasks,
                                 m_get_enabled_plugins):
        self.hook.serialize_end_tasks()
        m_get_enabled_plugins.assert_called_once_with(self.cluster)
        m_deployment_tasks.assert_called_once_with([])
Exemplo n.º 2
0
class TestPluginsPreDeploymentHooksSerializer(TestPluginsDeploymentEnvironment
                                              ):
    def setUp(self):
        super(TestPluginsPreDeploymentHooksSerializer, self).setUp()
        self.hook = PluginsPreDeploymentHooksSerializer(
            self.cluster,
            self.nodes,
            role_resolver=NullResolver([x['id'] for x in self.nodes]))

    @mock.patch('nailgun.orchestrator.plugins_serializers.'
                'templates.make_ubuntu_sources_task',
                return_value={
                    'task_type': 'ubuntu_sources_task',
                    'parameters': {}
                })
    @mock.patch('nailgun.orchestrator.plugins_serializers.'
                'templates.make_ubuntu_preferences_task',
                return_value=None)
    @mock.patch('nailgun.orchestrator.plugins_serializers.'
                'templates.make_apt_update_task',
                return_value={
                    'task_type': 'apt_update_task',
                    'parameters': {}
                })
    def test_create_repositories_ubuntu_does_not_generate_prefences_if_none(
            self, *_):
        self.cluster.release.operating_system = consts.RELEASE_OS.ubuntu
        tasks = self.hook.create_repositories(self.plugins)
        self.assertItemsEqual(map(lambda t: t['task_type'], tasks),
                              ['ubuntu_sources_task', 'apt_update_task'])

    @mock.patch('nailgun.plugins.manager.PluginManager.'
                'get_enabled_plugins',
                return_value=[])
    @mock.patch('nailgun.orchestrator.plugins_serializers.'
                'PluginsPreDeploymentHooksSerializer.create_repositories')
    @mock.patch('nailgun.orchestrator.plugins_serializers.'
                'PluginsPreDeploymentHooksSerializer.sync_scripts')
    def test_serialize_begin_tasks(self, m_sync_scripts, m_create_repositories,
                                   m_get_enabled_plugins):
        self.hook.serialize_begin_tasks()
        m_get_enabled_plugins.assert_called_once_with(self.cluster)
        m_create_repositories.assert_called_once_with([])
        m_sync_scripts.assert_called_once_with([])

    @mock.patch('nailgun.plugins.manager.PluginManager.'
                'get_enabled_plugins',
                return_value=[])
    @mock.patch('nailgun.orchestrator.plugins_serializers.'
                'PluginsPreDeploymentHooksSerializer.deployment_tasks')
    def test_serialize_end_tasks(self, m_deployment_tasks,
                                 m_get_enabled_plugins):
        self.hook.serialize_end_tasks()
        m_get_enabled_plugins.assert_called_once_with(self.cluster)
        m_deployment_tasks.assert_called_once_with([])
Exemplo n.º 3
0
 def setUp(self):
     super(TestPluginsPreDeploymentHooksSerializer, self).setUp()
     self.cluster = mock.Mock()
     self.cluster.release.operating_system = 'ubuntu'
     self.nodes = [{
         'id': 1,
         'role': 'controller'
     }, {
         'id': 2,
         'role': 'compute'
     }]
     self.hook = PluginsPreDeploymentHooksSerializer(
         self.cluster, self.nodes)
     self.plugins = [mock.Mock()]
Exemplo n.º 4
0
    def setUp(self):
        super(TestPluginsPreDeploymentHooksSerializer, self).setUp()
        self.cluster = mock.Mock()
        self.cluster.release.operating_system = 'ubuntu'
        self.nodes = [{
            'id': 1,
            'role': 'controller'
        }, {
            'id': 2,
            'role': 'compute'
        }]
        self.hook = PluginsPreDeploymentHooksSerializer(
            self.cluster,
            self.nodes,
            role_resolver=NullResolver([x['id'] for x in self.nodes]))

        plugin = mock.Mock(tasks=[], deployment_tasks=[])
        self.plugins = [plugin]
 def setUp(self):
     super(TestPluginsPreDeploymentHooksSerializer, self).setUp()
     self.cluster = mock.Mock()
     self.cluster.release.operating_system = 'ubuntu'
     self.nodes = [
         {'id': 1, 'role': 'controller'},
         {'id': 2, 'role': 'compute'}
     ]
     self.hook = PluginsPreDeploymentHooksSerializer(
         self.cluster,
         self.nodes)
     self.plugins = [mock.Mock()]
    def setUp(self):
        super(TestPluginsPreDeploymentHooksSerializer, self).setUp()
        self.cluster = mock.Mock()
        self.cluster.release.operating_system = 'ubuntu'
        self.nodes = [
            {'id': 1, 'role': 'controller'},
            {'id': 2, 'role': 'compute'}
        ]
        self.hook = PluginsPreDeploymentHooksSerializer(
            self.cluster,
            self.nodes,
            role_resolver=NullResolver([x['id'] for x in self.nodes])
        )

        plugin = mock.Mock(tasks=[], deployment_tasks=[])
        self.plugins = [plugin]
class TestPluginsPreDeploymentHooksSerializer(base.BaseTestCase):

    def setUp(self):
        super(TestPluginsPreDeploymentHooksSerializer, self).setUp()
        self.cluster = mock.Mock()
        self.cluster.release.operating_system = 'ubuntu'
        self.nodes = [
            {'id': 1, 'role': 'controller'},
            {'id': 2, 'role': 'compute'}
        ]
        self.hook = PluginsPreDeploymentHooksSerializer(
            self.cluster,
            self.nodes)

        plugin = mock.Mock(tasks=[], deployment_tasks=[])
        self.plugins = [plugin]

    @mock.patch(
        'nailgun.orchestrator.plugins_serializers.get_uids_for_tasks',
        return_value=[1, 2])
    @mock.patch(
        'nailgun.orchestrator.plugins_serializers.'
        'templates.make_ubuntu_sources_task',
        return_value={'task_type': 'ubuntu_sources_task',
                      'parameters': {}})
    @mock.patch(
        'nailgun.orchestrator.plugins_serializers.'
        'templates.make_ubuntu_preferences_task',
        return_value=None)
    @mock.patch(
        'nailgun.orchestrator.plugins_serializers.'
        'templates.make_apt_update_task',
        return_value={'task_type': 'apt_update_task',
                      'parameters': {}})
    def test_create_repositories_ubuntu_does_not_generate_prefences_if_none(
            self, _, __, ___, ____):
        self.cluster.release.operating_system = consts.RELEASE_OS.ubuntu
        tasks = self.hook.create_repositories(self.plugins)
        self.assertItemsEqual(
            map(lambda t: t['task_type'], tasks),
            ['ubuntu_sources_task',
             'apt_update_task'])
Exemplo n.º 8
0
class TestPluginsPreDeploymentHooksSerializer(base.BaseTestCase):
    def setUp(self):
        super(TestPluginsPreDeploymentHooksSerializer, self).setUp()
        self.cluster = mock.Mock()
        self.cluster.release.operating_system = 'ubuntu'
        self.nodes = [{
            'id': 1,
            'role': 'controller'
        }, {
            'id': 2,
            'role': 'compute'
        }]
        self.hook = PluginsPreDeploymentHooksSerializer(
            self.cluster, self.nodes)

        plugin = mock.Mock(tasks=[], deployment_tasks=[])
        self.plugins = [plugin]

    @mock.patch('nailgun.orchestrator.plugins_serializers.get_uids_for_tasks',
                return_value=[1, 2])
    @mock.patch('nailgun.orchestrator.plugins_serializers.'
                'templates.make_ubuntu_sources_task',
                return_value={
                    'task_type': 'ubuntu_sources_task',
                    'parameters': {}
                })
    @mock.patch('nailgun.orchestrator.plugins_serializers.'
                'templates.make_ubuntu_preferences_task',
                return_value=None)
    @mock.patch('nailgun.orchestrator.plugins_serializers.'
                'templates.make_apt_update_task',
                return_value={
                    'task_type': 'apt_update_task',
                    'parameters': {}
                })
    def test_create_repositories_ubuntu_does_not_generate_prefences_if_none(
            self, _, __, ___, ____):
        self.cluster.release.operating_system = consts.RELEASE_OS.ubuntu
        tasks = self.hook.create_repositories(self.plugins)
        self.assertItemsEqual(map(lambda t: t['task_type'], tasks),
                              ['ubuntu_sources_task', 'apt_update_task'])
Exemplo n.º 9
0
 def setUp(self):
     super(TestPluginsPreDeploymentHooksSerializer, self).setUp()
     self.hook = PluginsPreDeploymentHooksSerializer(
         self.cluster,
         self.nodes,
         role_resolver=NullResolver([x['id'] for x in self.nodes]))
Exemplo n.º 10
0
 def setUp(self):
     super(TestPluginsPreDeploymentHooksSerializer, self).setUp()
     self.hook = PluginsPreDeploymentHooksSerializer(
         self.cluster,
         self.nodes,
         role_resolver=NullResolver([x['id'] for x in self.nodes]))