Merge "Rename Meta-Action to Action"

This commit is contained in:
Jenkins
2015-12-09 10:59:14 +00:00
committed by Gerrit Code Review
19 changed files with 137 additions and 200 deletions

View File

@@ -1,32 +0,0 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 b<>com
#
# Authors: Jean-Emile DARTOIS <jean-emile.dartois@b-com.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from watcher.decision_engine.meta_action.migrate import Migrate
from watcher.decision_engine.model.hypervisor import Hypervisor
from watcher.decision_engine.model.vm import VM
from watcher.tests import base
class TestMigtrate(base.BaseTestCase):
def test_set_get_bandwidth(self):
vm = VM()
hyp_src = Hypervisor()
hyp_dst = Hypervisor()
mig = Migrate(vm, hyp_src, hyp_dst)
mig.set_bandwidth(2)
self.assertEqual(mig.get_bandwidth(), 2)

View File

@@ -14,17 +14,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from watcher.decision_engine.meta_action.base import MetaAction
from watcher.decision_engine.actions.base import BaseAction
from watcher.tests import base
class TestMetaAction(base.TestCase):
class TestAction(base.TestCase):
def test_get_priority(self):
ma = MetaAction()
ma = BaseAction()
ma.priority = 3
self.assertEqual(ma.priority, 3)
def test_get_level(self):
ma = MetaAction()
ma = BaseAction()
ma.level = 5
self.assertEqual(ma.level, 5)

View File

@@ -23,11 +23,11 @@ from mock import MagicMock
from watcher.common import exception
from watcher.decision_engine.meta_action.hypervisor_state import \
from watcher.decision_engine.actions.hypervisor_state import \
ChangeHypervisorState
from watcher.decision_engine.meta_action.power_state import ChangePowerState
from watcher.decision_engine.actions.power_state import ChangePowerState
from watcher.decision_engine.meta_action.migrate import Migrate
from watcher.decision_engine.actions.migration import Migrate
from watcher.decision_engine.model.model_root import ModelRoot
from watcher.decision_engine.strategy.basic_consolidation import \
BasicConsolidation
@@ -151,24 +151,6 @@ class TestBasicConsolidation(base.BaseTestCase):
self.assertRaises(exception.ClusteStateNotDefined,
sercon.print_utilization, None)
def check_migration(self, array, indice, vm, src, dest):
"""Helper to check migration
:param array:
:param indice:
:param vm:
:param src:
:param dest:
:return:
"""
self.assertEqual(array[indice].get_vm().uuid, vm)
self.assertEqual(array[indice].get_source_hypervisor().uuid, src)
self.assertEqual(array[indice].get_dest_hypervisor().uuid, dest)
self.assertEqual(array[indice].get_bandwidth(), 0)
array[indice].set_bandwidth(5)
self.assertEqual(array[indice].get_bandwidth(), 5)
def test_check_migration(self):
sercon = BasicConsolidation()
fake_cluster = FakerModelCollector()
@@ -209,7 +191,7 @@ class TestBasicConsolidation(base.BaseTestCase):
self.fake_cluster.generate_scenario_3())
actions_counter = Counter(
[type(action) for action in solution.meta_actions])
[type(action) for action in solution.actions])
expected_num_migrations = 0
expected_power_state = 0

View File

@@ -19,7 +19,7 @@ from mock import MagicMock
from watcher.common.exception import MetaActionNotFound
from watcher.common import utils
from watcher.db import api as db_api
from watcher.decision_engine.meta_action.base import MetaAction
from watcher.decision_engine.actions.base import BaseAction
from watcher.decision_engine.planner.default import DefaultPlanner
from watcher.decision_engine.solution.default import DefaultSolution
from watcher.decision_engine.strategy.basic_consolidation import \
@@ -62,8 +62,8 @@ class TestActionScheduling(base.DbTestCase):
scenarios = [
(str(action_cls), {"fake_action": mock.Mock(spec=action_cls)})
for action_cls in MetaAction.__subclasses__()
]
for action_cls in BaseAction.__subclasses__()
]
def test_schedule_actions(self):
default_planner = DefaultPlanner()
@@ -119,7 +119,7 @@ class TestDefaultPlanner(base.DbTestCase):
def test_schedule_raise(self):
audit = db_utils.create_test_audit(uuid=utils.generate_uuid())
fake_solution = SolutionFaker.build()
fake_solution._meta_actions[0] = "valeur_qcq"
fake_solution.actions[0] = "valeur_qcq"
self.assertRaises(MetaActionNotFound, self.default_planner.schedule,
self.context, audit.id, fake_solution)

View File

@@ -21,4 +21,4 @@ class TestDefaultSolution(base.BaseTestCase):
def test_default_solution(self):
solution = DefaultSolution()
solution.add_change_request("BLA")
self.assertEqual(solution.meta_actions[0], "BLA")
self.assertEqual(solution.actions[0], "BLA")