def test_adjust_tasks_with_legacy(self, adapter_mock, objects_mock):
        cluster_obj = objects_mock.Cluster
        tasks = [
            {'id': 'tasks2', 'type': consts.ORCHESTRATOR_TASK_TYPES.group},
        ]
        graph = {'tasks': tasks[:], 'type': 'provision'}
        cluster_obj.is_propagate_task_deploy_enabled.return_value = True
        adapter_mock.adapt_legacy_tasks.return_value = tasks

        cluster = mock.MagicMock()
        resolver = mock.MagicMock()
        manager._adjust_graph_tasks(graph, cluster, resolver, None)
        self.assertEqual(tasks, graph['tasks'])

        cluster_obj.is_propagate_task_deploy_enabled.assert_called_once_with(
            cluster
        )
        adapter_mock.adapt_legacy_tasks.assert_called_once_with(
            graph['tasks'], None, resolver
        )
        graph2 = {
            'tasks': tasks[:], 'type': consts.DEFAULT_DEPLOYMENT_GRAPH_TYPE
        }
        manager._adjust_graph_tasks(graph2, cluster, resolver, None)
        self.assertEqual(tasks, graph2['tasks'])

        cluster_obj.get_legacy_plugin_tasks.assert_called_once_with(cluster)
        adapter_mock.adapt_legacy_tasks.assert_called_with(
            tasks, cluster_obj.get_legacy_plugin_tasks.return_value, resolver
        )
예제 #2
0
    def test_adjust_tasks_with_legacy(self, adapter_mock, objects_mock):
        cluster_obj = objects_mock.Cluster
        tasks = [
            {
                'id': 'tasks2',
                'type': consts.ORCHESTRATOR_TASK_TYPES.group
            },
        ]
        graph = {'tasks': tasks[:], 'type': 'provision'}
        cluster_obj.is_propagate_task_deploy_enabled.return_value = True
        adapter_mock.adapt_legacy_tasks.return_value = tasks

        cluster = mock.MagicMock()
        resolver = mock.MagicMock()
        manager._adjust_graph_tasks(graph, cluster, resolver, None)
        self.assertEqual(tasks, graph['tasks'])

        cluster_obj.is_propagate_task_deploy_enabled.assert_called_once_with(
            cluster)
        adapter_mock.adapt_legacy_tasks.assert_called_once_with(
            graph['tasks'], None, resolver)
        graph2 = {
            'tasks': tasks[:],
            'type': consts.DEFAULT_DEPLOYMENT_GRAPH_TYPE
        }
        manager._adjust_graph_tasks(graph2, cluster, resolver, None)
        self.assertEqual(tasks, graph2['tasks'])

        cluster_obj.get_legacy_plugin_tasks.assert_called_once_with(cluster)
        adapter_mock.adapt_legacy_tasks.assert_called_with(
            tasks, cluster_obj.get_legacy_plugin_tasks.return_value, resolver)
예제 #3
0
    def test_adjust_tasks_if_no_legacy(self, objects_mock):
        cluster_obj = objects_mock.Cluster
        tasks = [{
            'id': 'task1',
            'type': consts.ORCHESTRATOR_TASK_TYPES.puppet
        }, {
            'id': 'task2',
            'type': consts.ORCHESTRATOR_TASK_TYPES.group
        }, {
            'id': 'task3',
            'type': consts.ORCHESTRATOR_TASK_TYPES.shell
        }, {
            'id': 'task4',
            'type': consts.ORCHESTRATOR_TASK_TYPES.skipped
        }]
        graph = {'tasks': tasks[:]}
        cluster_obj.is_propagate_task_deploy_enabled.return_value = False

        cluster = mock.MagicMock()
        manager._adjust_graph_tasks(graph, cluster, None, None)
        self.assertEqual(tasks, graph['tasks'])
        cluster_obj.is_propagate_task_deploy_enabled.assert_called_once_with(
            cluster)
        # filter result
        manager._adjust_graph_tasks(graph, cluster, None, ['task1'])
        tasks[2]['type'] = consts.ORCHESTRATOR_TASK_TYPES.skipped
        self.assertEqual(tasks, graph['tasks'])
    def test_adjust_tasks_if_no_legacy(self, objects_mock):
        cluster_obj = objects_mock.Cluster
        tasks = [
            {'id': 'task1', 'type': consts.ORCHESTRATOR_TASK_TYPES.puppet},
            {'id': 'task2', 'type': consts.ORCHESTRATOR_TASK_TYPES.group},
            {'id': 'task3', 'type': consts.ORCHESTRATOR_TASK_TYPES.shell},
            {'id': 'task4', 'type': consts.ORCHESTRATOR_TASK_TYPES.skipped}
        ]
        graph = {'tasks': tasks[:]}
        cluster_obj.is_propagate_task_deploy_enabled.return_value = False

        cluster = mock.MagicMock()
        manager._adjust_graph_tasks(graph, cluster, None, None)
        self.assertEqual(tasks, graph['tasks'])
        cluster_obj.is_propagate_task_deploy_enabled.assert_called_once_with(
            cluster
        )
        # filter result
        manager._adjust_graph_tasks(graph, cluster, None, ['task1'])
        tasks[2]['type'] = consts.ORCHESTRATOR_TASK_TYPES.skipped
        self.assertEqual(tasks, graph['tasks'])