예제 #1
0
    def test_schedule_two_actions(self):
        default_planner = pbase.DefaultPlanner()
        audit = db_utils.create_test_audit(uuid=utils.generate_uuid())
        solution = dsol.DefaultSolution()

        parameters = {
            "src_uuid_hypervisor": "server1",
            "dst_uuid_hypervisor": "server2",
        }
        solution.add_action(action_type="migrate",
                            resource_id="b199db0c-1408-4d52-b5a5-5ca14de0ff36",
                            input_parameters=parameters)

        solution.add_action(action_type="nop",
                            resource_id="",
                            input_parameters={})

        with mock.patch.object(
                pbase.DefaultPlanner,
                "create_action",
                wraps=default_planner.create_action) as m_create_action:
            action_plan = default_planner.schedule(self.context, audit.id,
                                                   solution)
        self.assertIsNotNone(action_plan.uuid)
        self.assertEqual(2, m_create_action.call_count)
        # check order
        filters = {'action_plan_id': action_plan.id}
        actions = objects.Action.dbapi.get_action_list(self.context, filters)
        self.assertEqual("nop", actions[0].action_type)
        self.assertEqual("migrate", actions[1].action_type)
예제 #2
0
    def setUp(self):
        super(TestDefaultPlanner, self).setUp()
        self.default_planner = pbase.DefaultPlanner()
        obj_utils.create_test_audit_template(self.context)

        p = mock.patch.object(db_api.BaseConnection, 'create_action_plan')
        self.mock_create_action_plan = p.start()
        self.mock_create_action_plan.side_effect = (
            self._simulate_action_plan_create)
        self.addCleanup(p.stop)

        q = mock.patch.object(db_api.BaseConnection, 'create_action')
        self.mock_create_action = q.start()
        self.mock_create_action.side_effect = (self._simulate_action_create)
        self.addCleanup(q.stop)
예제 #3
0
    def setUp(self):
        super(TestDefaultPlanner, self).setUp()
        self.default_planner = pbase.DefaultPlanner(mock.Mock())
        self.default_planner.config.weights = {
            'nop': 0,
            'sleep': 1,
            'change_nova_service_state': 2,
            'migrate': 3
        }

        obj_utils.create_test_audit_template(self.context)
        self.strategy = obj_utils.create_test_strategy(self.context)

        p = mock.patch.object(db_api.BaseConnection, 'create_action_plan')
        self.mock_create_action_plan = p.start()
        self.mock_create_action_plan.side_effect = (
            self._simulate_action_plan_create)
        self.addCleanup(p.stop)

        q = mock.patch.object(db_api.BaseConnection, 'create_action')
        self.mock_create_action = q.start()
        self.mock_create_action.side_effect = (self._simulate_action_create)
        self.addCleanup(q.stop)
예제 #4
0
 def setUp(self):
     super(TestActionScheduling, self).setUp()
     self.strategy = db_utils.create_test_strategy(name="dummy")
     self.audit = db_utils.create_test_audit(uuid=utils.generate_uuid(),
                                             strategy_id=self.strategy.id)
     self.default_planner = pbase.DefaultPlanner(mock.Mock())