Enable strategy parameters
Strategy provides parameters to customize algorithm behavior. End user could query then specify parameters for their requirements. Change-Id: Id097db5f6e79c94b57674c8e5d55b06098abf18c Implements-bp: optimization-threshold
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
import mock
|
||||
|
||||
from watcher.applier.loading import default
|
||||
from watcher.common import utils
|
||||
from watcher.decision_engine.model import model_root
|
||||
from watcher.decision_engine.strategy import strategies
|
||||
from watcher.tests import base
|
||||
@@ -45,12 +46,16 @@ class TestDummyStrategy(base.TestCase):
|
||||
|
||||
def test_dummy_strategy(self):
|
||||
dummy = strategies.DummyStrategy(config=mock.Mock())
|
||||
dummy.input_parameters = utils.Struct()
|
||||
dummy.input_parameters.update({'para1': 4.0, 'para2': 'Hi'})
|
||||
solution = dummy.execute()
|
||||
self.assertEqual(3, len(solution.actions))
|
||||
|
||||
def test_check_parameters(self):
|
||||
model = self.fake_cluster.generate_scenario_3_with_2_hypervisors()
|
||||
self.m_model.return_value = model
|
||||
self.strategy.input_parameters = utils.Struct()
|
||||
self.strategy.input_parameters.update({'para1': 4.0, 'para2': 'Hi'})
|
||||
solution = self.strategy.execute()
|
||||
loader = default.DefaultActionLoader()
|
||||
for action in solution.actions:
|
||||
|
||||
@@ -21,6 +21,7 @@ import mock
|
||||
|
||||
from watcher.applier.loading import default
|
||||
from watcher.common import exception
|
||||
from watcher.common import utils
|
||||
from watcher.decision_engine.model import model_root
|
||||
from watcher.decision_engine.model import resource
|
||||
from watcher.decision_engine.strategy import strategies
|
||||
@@ -57,6 +58,10 @@ class TestOutletTempControl(base.BaseTestCase):
|
||||
statistic_aggregation=self.fake_metrics.mock_get_statistics)
|
||||
self.strategy = strategies.OutletTempControl(config=mock.Mock())
|
||||
|
||||
self.strategy.input_parameters = utils.Struct()
|
||||
self.strategy.input_parameters.update({'threshold': 34.3})
|
||||
self.strategy.threshold = 34.3
|
||||
|
||||
def test_calc_used_res(self):
|
||||
model = self.fake_cluster.generate_scenario_3_with_2_hypervisors()
|
||||
self.m_model.return_value = model
|
||||
|
||||
@@ -154,7 +154,8 @@ class TestSyncer(base.DbTestCase):
|
||||
]
|
||||
m_s_list.return_value = [
|
||||
objects.Strategy(self.ctx, id=1, name="strategy_1",
|
||||
goal_id=1, display_name="Strategy 1")
|
||||
goal_id=1, display_name="Strategy 1",
|
||||
parameters_spec='{}')
|
||||
]
|
||||
self.syncer.sync()
|
||||
|
||||
@@ -218,7 +219,8 @@ class TestSyncer(base.DbTestCase):
|
||||
]
|
||||
m_s_list.return_value = [
|
||||
objects.Strategy(self.ctx, id=1, name="strategy_1",
|
||||
goal_id=1, display_name="original")
|
||||
goal_id=1, display_name="original",
|
||||
parameters_spec='{}')
|
||||
]
|
||||
self.syncer.sync()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user