def test_configuration_execute_by_node_id(self, mocked_rpc):
        task_manager = OpenstackConfigTaskManager(self.cluster.id)
        task = task_manager.execute({
            'cluster_id': self.cluster.id,
            'node_ids': [self.nodes[0].id],
        })

        self.assertEqual(task.status, consts.TASK_STATUSES.pending)

        all_node_ids = [self.nodes[0].id]
        self.assertEqual(task.cache['nodes'], all_node_ids)
Пример #2
0
    def test_configuration_execute_by_node_id(self, mocked_rpc):
        task_manager = OpenstackConfigTaskManager(self.cluster.id)
        task = task_manager.execute({
            'cluster_id': self.cluster.id,
            'node_ids': [self.nodes[0].id],
        })

        self.assertEqual(task.status, consts.TASK_STATUSES.pending)

        all_node_ids = [self.nodes[0].id]
        self.assertEqual(task.cache['nodes'], all_node_ids)
Пример #3
0
    def test_configuration_execute_w_custom_graph(self, mocked_rpc):
        custom_tasks = [{'id': 'custom-task', 'type': 'puppet', 'roles': '*'}]
        objects.DeploymentGraph.create_for_model({'tasks': custom_tasks},
                                                 self.cluster, 'custom-graph')
        task_manager = OpenstackConfigTaskManager(self.cluster.id)
        task = task_manager.execute({'cluster_id': self.cluster.id},
                                    graph_type='custom-graph')

        self.assertEqual(task.status, consts.TASK_STATUSES.pending)

        self.assertEqual(
            mocked_rpc.call_args[0][1]['args']['tasks'][0]['task_name'],
            'custom-task')
    def test_config_execute_fails_if_deployment_running(self, mocked_rpc):
        task_manager = OpenstackConfigTaskManager(self.cluster.id)
        task = task_manager.execute({'cluster_id': self.cluster.id})

        self.assertEqual(task.status, consts.TASK_STATUSES.pending)

        NailgunReceiver.deploy_resp(
            task_uuid=task.uuid,
            status=consts.TASK_STATUSES.running,
            progress=50,
            nodes=[{'uid': n.uid, 'status': consts.NODE_STATUSES.ready}
                   for n in self.env.nodes],
        )

        self.assertEqual(task.status, consts.TASK_STATUSES.running)
        task2 = OpenstackConfigTaskManager(self.cluster.id)
        self.assertRaises(errors.TaskAlreadyRunning,
                          task2.execute, {'cluster_id': self.cluster.id})
    def test_configuration_execute_w_custom_graph(self, mocked_rpc):
        custom_tasks = [
            {
                'id': 'custom-task',
                'type': 'puppet',
                'roles': '*'
            }
        ]
        objects.DeploymentGraph.create_for_model(
            {'tasks': custom_tasks}, self.cluster, 'custom-graph')
        task_manager = OpenstackConfigTaskManager(self.cluster.id)
        task = task_manager.execute(
            {'cluster_id': self.cluster.id}, graph_type='custom-graph')

        self.assertEqual(task.status, consts.TASK_STATUSES.pending)

        self.assertEqual(
            mocked_rpc.call_args[0][1]['args']['tasks'][0]['task_name'],
            'custom-task'
        )
Пример #6
0
    def test_configuration_execute(self, mocked_rpc):
        task_manager = OpenstackConfigTaskManager(self.cluster.id)
        task = task_manager.execute({'cluster_id': self.cluster.id})

        self.assertEqual(task.status, consts.TASK_STATUSES.pending)

        all_node_ids = [n.id for n in self.env.nodes[:3]]
        self.assertItemsEqual(task.cache['nodes'], all_node_ids)

        tasks = mocked_rpc.call_args[0][1]['args']['tasks']
        # 3 tasks for all ready nodes with cluster config
        # 1 task for node[0] with node specific config
        # 2 tasks (1 per each compute node)
        # 1 deployment task
        self.assertEqual(len(tasks), 7)

        cluster_uids = []
        role_uids = []
        node_uids = []
        deployment_tasks = []
        for task in tasks:
            if task['type'] == 'upload_file':
                if '/cluster' in task['parameters']['path']:
                    cluster_uids.extend(task['uids'])
                if '/role' in task['parameters']['path']:
                    role_uids.extend(task['uids'])
                if '/node' in task['parameters']['path']:
                    node_uids.extend(task['uids'])
            else:
                deployment_tasks.append(task)

        self.assertItemsEqual(cluster_uids, map(str, all_node_ids))
        self.assertItemsEqual(role_uids,
                              [self.nodes[1].uid, self.nodes[2].uid])
        self.assertItemsEqual([self.nodes[0].uid], node_uids)
        self.assertItemsEqual(
            deployment_tasks,
            [make_generic_task([self.nodes[0].uid], self.refreshable_task)])
    def test_configuration_execute(self, mocked_rpc):
        task_manager = OpenstackConfigTaskManager(self.cluster.id)
        task = task_manager.execute({'cluster_id': self.cluster.id})

        self.assertEqual(task.status, consts.TASK_STATUSES.pending)

        all_node_ids = [n.id for n in self.env.nodes[:3]]
        self.assertItemsEqual(task.cache['nodes'], all_node_ids)

        tasks = mocked_rpc.call_args[0][1]['args']['tasks']
        # 3 tasks for all ready nodes with cluster config
        # 1 task for node[0] with node specific config
        # 2 tasks (1 per each compute node)
        # 1 deployment task
        self.assertEqual(len(tasks), 7)

        cluster_uids = []
        role_uids = []
        node_uids = []
        deployment_tasks = []
        for task in tasks:
            if task['type'] == 'upload_file':
                if '/cluster' in task['parameters']['path']:
                    cluster_uids.extend(task['uids'])
                if '/role' in task['parameters']['path']:
                    role_uids.extend(task['uids'])
                if '/node' in task['parameters']['path']:
                    node_uids.extend(task['uids'])
            else:
                deployment_tasks.append(task)

        self.assertItemsEqual(cluster_uids, map(str, all_node_ids))
        self.assertItemsEqual(role_uids,
                              [self.nodes[1].uid, self.nodes[2].uid])
        self.assertItemsEqual([self.nodes[0].uid], node_uids)
        self.assertItemsEqual(deployment_tasks, [
            make_generic_task([self.nodes[0].uid], self.refreshable_task)])