Merge "Remove extra field from watcher plugin"
This commit is contained in:
commit
11a9c09c2b
@ -17,7 +17,6 @@
|
|||||||
name: "dummy"
|
name: "dummy"
|
||||||
strategy:
|
strategy:
|
||||||
name: "dummy"
|
name: "dummy"
|
||||||
extra: {}
|
|
||||||
sla:
|
sla:
|
||||||
failure_rate:
|
failure_rate:
|
||||||
max: 0
|
max: 0
|
||||||
@ -29,7 +28,6 @@
|
|||||||
name: "dummy"
|
name: "dummy"
|
||||||
strategy:
|
strategy:
|
||||||
name: "dummy"
|
name: "dummy"
|
||||||
extra: {}
|
|
||||||
runner:
|
runner:
|
||||||
type: "constant"
|
type: "constant"
|
||||||
times: 10
|
times: 10
|
||||||
@ -56,12 +54,10 @@
|
|||||||
name: "workload_balancing"
|
name: "workload_balancing"
|
||||||
strategy:
|
strategy:
|
||||||
name: "workload_stabilization"
|
name: "workload_stabilization"
|
||||||
extra: {}
|
|
||||||
- goal:
|
- goal:
|
||||||
name: "dummy"
|
name: "dummy"
|
||||||
strategy:
|
strategy:
|
||||||
name: "dummy"
|
name: "dummy"
|
||||||
extra: {}
|
|
||||||
sla:
|
sla:
|
||||||
failure_rate:
|
failure_rate:
|
||||||
max: 0
|
max: 0
|
@ -60,9 +60,6 @@ class AuditTemplateGenerator(context.Context):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"extra": {
|
|
||||||
"type": "object"
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -100,10 +97,9 @@ class AuditTemplateGenerator(context.Context):
|
|||||||
strategy_id = types.WatcherStrategy.transform(
|
strategy_id = types.WatcherStrategy.transform(
|
||||||
clients=clients,
|
clients=clients,
|
||||||
resource_config=audit_params["strategy"])
|
resource_config=audit_params["strategy"])
|
||||||
extra = audit_params.get("extra") or {}
|
|
||||||
|
|
||||||
audit_template = watcher_scenario._create_audit_template(
|
audit_template = watcher_scenario._create_audit_template(
|
||||||
goal_id, strategy_id, extra)
|
goal_id, strategy_id)
|
||||||
self.context["audit_templates"].append(audit_template.uuid)
|
self.context["audit_templates"].append(audit_template.uuid)
|
||||||
|
|
||||||
@logging.log_task_wrapper(LOG.info, _("Exit context: `Audit Templates`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `Audit Templates`"))
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from rally.common import logging
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally.plugins.openstack import scenario
|
from rally.plugins.openstack import scenario
|
||||||
from rally.plugins.openstack.scenarios.watcher import utils
|
from rally.plugins.openstack.scenarios.watcher import utils
|
||||||
@ -28,18 +29,18 @@ from rally.task import validation
|
|||||||
name="Watcher.create_audit_template_and_delete")
|
name="Watcher.create_audit_template_and_delete")
|
||||||
class CreateAuditTemplateAndDelete(utils.WatcherScenario):
|
class CreateAuditTemplateAndDelete(utils.WatcherScenario):
|
||||||
|
|
||||||
def run(self, goal, strategy, extra=None):
|
@logging.log_deprecated_args("Extra field has been removed "
|
||||||
|
"since it isn't used.", "0.8.0", ["extra"],
|
||||||
|
once=True)
|
||||||
|
def run(self, goal, strategy):
|
||||||
"""Create audit template and delete it.
|
"""Create audit template and delete it.
|
||||||
|
|
||||||
:param goal: The goal audit template is based on
|
:param goal: The goal audit template is based on
|
||||||
:param strategy: The strategy used to provide resource optimization
|
:param strategy: The strategy used to provide resource optimization
|
||||||
algorithm
|
algorithm
|
||||||
:param extra: This field is used to specify some audit template
|
|
||||||
options
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
extra = extra or {}
|
audit_template = self._create_audit_template(goal, strategy)
|
||||||
audit_template = self._create_audit_template(goal, strategy, extra)
|
|
||||||
self._delete_audit_template(audit_template.uuid)
|
self._delete_audit_template(audit_template.uuid)
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,19 +34,17 @@ class WatcherScenario(scenario.OpenStackScenario):
|
|||||||
"""Base class for Watcher scenarios with basic atomic actions."""
|
"""Base class for Watcher scenarios with basic atomic actions."""
|
||||||
|
|
||||||
@atomic.action_timer("watcher.create_audit_template")
|
@atomic.action_timer("watcher.create_audit_template")
|
||||||
def _create_audit_template(self, goal_id, strategy_id, extra):
|
def _create_audit_template(self, goal_id, strategy_id):
|
||||||
"""Create Audit Template in DB
|
"""Create Audit Template in DB
|
||||||
|
|
||||||
:param goal_id: UUID Goal
|
:param goal_id: UUID Goal
|
||||||
:param strategy_id: UUID Strategy
|
:param strategy_id: UUID Strategy
|
||||||
:param extra: Audit Template Extra (JSON Dict)
|
|
||||||
:return: Audit Template object
|
:return: Audit Template object
|
||||||
"""
|
"""
|
||||||
return self.admin_clients("watcher").audit_template.create(
|
return self.admin_clients("watcher").audit_template.create(
|
||||||
goal=goal_id,
|
goal=goal_id,
|
||||||
strategy=strategy_id,
|
strategy=strategy_id,
|
||||||
name=self.generate_random_name(),
|
name=self.generate_random_name())
|
||||||
extra=extra or {})
|
|
||||||
|
|
||||||
@atomic.action_timer("watcher.delete_audit_template")
|
@atomic.action_timer("watcher.delete_audit_template")
|
||||||
def _delete_audit_template(self, audit_template):
|
def _delete_audit_template(self, audit_template):
|
||||||
|
@ -21,8 +21,7 @@
|
|||||||
},
|
},
|
||||||
"strategy": {
|
"strategy": {
|
||||||
"name": "dummy"
|
"name": "dummy"
|
||||||
},
|
}
|
||||||
"extra": {}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -17,4 +17,3 @@
|
|||||||
name: "dummy"
|
name: "dummy"
|
||||||
strategy:
|
strategy:
|
||||||
name: "dummy"
|
name: "dummy"
|
||||||
extra: {}
|
|
||||||
|
@ -7,8 +7,7 @@
|
|||||||
},
|
},
|
||||||
"strategy": {
|
"strategy": {
|
||||||
"name": "dummy"
|
"name": "dummy"
|
||||||
},
|
}
|
||||||
"extra": {}
|
|
||||||
},
|
},
|
||||||
"runner": {
|
"runner": {
|
||||||
"type": "constant",
|
"type": "constant",
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
name: "dummy"
|
name: "dummy"
|
||||||
strategy:
|
strategy:
|
||||||
name: "dummy"
|
name: "dummy"
|
||||||
extra: {}
|
|
||||||
runner:
|
runner:
|
||||||
type: "constant"
|
type: "constant"
|
||||||
times: 10
|
times: 10
|
||||||
|
@ -17,8 +17,7 @@
|
|||||||
},
|
},
|
||||||
"strategy": {
|
"strategy": {
|
||||||
"name": "workload_stabilization"
|
"name": "workload_stabilization"
|
||||||
},
|
}
|
||||||
"extra": {}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"goal": {
|
"goal": {
|
||||||
@ -26,8 +25,7 @@
|
|||||||
},
|
},
|
||||||
"strategy": {
|
"strategy": {
|
||||||
"name": "dummy"
|
"name": "dummy"
|
||||||
},
|
}
|
||||||
"extra": {}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,7 @@
|
|||||||
name: "workload_balancing"
|
name: "workload_balancing"
|
||||||
strategy:
|
strategy:
|
||||||
name: "workload_stabilization"
|
name: "workload_stabilization"
|
||||||
extra: {}
|
|
||||||
- goal:
|
- goal:
|
||||||
name: "dummy"
|
name: "dummy"
|
||||||
strategy:
|
strategy:
|
||||||
name: "dummy"
|
name: "dummy"
|
||||||
extra: {}
|
|
||||||
|
@ -51,8 +51,7 @@ class AuditTemplateTestCase(test.ScenarioTestCase):
|
|||||||
},
|
},
|
||||||
"strategy": {
|
"strategy": {
|
||||||
"name": "workload_stabilization"
|
"name": "workload_stabilization"
|
||||||
},
|
}
|
||||||
"extra": {}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"goal": {
|
"goal": {
|
||||||
@ -60,8 +59,7 @@ class AuditTemplateTestCase(test.ScenarioTestCase):
|
|||||||
},
|
},
|
||||||
"strategy": {
|
"strategy": {
|
||||||
"name": "workload_stabilization"
|
"name": "workload_stabilization"
|
||||||
},
|
}
|
||||||
"extra": {}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -75,7 +73,7 @@ class AuditTemplateTestCase(test.ScenarioTestCase):
|
|||||||
audit_template.setup()
|
audit_template.setup()
|
||||||
goal_id = mock_watcher_goal_transform.return_value
|
goal_id = mock_watcher_goal_transform.return_value
|
||||||
strategy_id = mock_watcher_strategy_transform.return_value
|
strategy_id = mock_watcher_strategy_transform.return_value
|
||||||
mock_calls = [mock.call(goal_id, strategy_id, {})]
|
mock_calls = [mock.call(goal_id, strategy_id)]
|
||||||
mock_watcher_scenario__create_audit_template.assert_has_calls(
|
mock_watcher_scenario__create_audit_template.assert_has_calls(
|
||||||
mock_calls)
|
mock_calls)
|
||||||
|
|
||||||
|
@ -27,10 +27,9 @@ class WatcherTestCase(test.ScenarioTestCase):
|
|||||||
scenario._create_audit_template = mock.MagicMock(
|
scenario._create_audit_template = mock.MagicMock(
|
||||||
return_value=audit_template)
|
return_value=audit_template)
|
||||||
scenario._delete_audit_template = mock.MagicMock()
|
scenario._delete_audit_template = mock.MagicMock()
|
||||||
scenario.run("goal", "strategy", {})
|
scenario.run("goal", "strategy")
|
||||||
scenario._create_audit_template.assert_called_once_with("goal",
|
scenario._create_audit_template.assert_called_once_with("goal",
|
||||||
"strategy",
|
"strategy")
|
||||||
{})
|
|
||||||
scenario._delete_audit_template.assert_called_once_with(
|
scenario._delete_audit_template.assert_called_once_with(
|
||||||
audit_template.uuid)
|
audit_template.uuid)
|
||||||
|
|
||||||
|
@ -28,12 +28,11 @@ class WatcherScenarioTestCase(test.ScenarioTestCase):
|
|||||||
watcher_scenario = utils.WatcherScenario(self.context)
|
watcher_scenario = utils.WatcherScenario(self.context)
|
||||||
watcher_scenario.generate_random_name = mock.MagicMock(
|
watcher_scenario.generate_random_name = mock.MagicMock(
|
||||||
return_value="mock_name")
|
return_value="mock_name")
|
||||||
watcher_scenario._create_audit_template("fake_goal", "fake_strategy",
|
watcher_scenario._create_audit_template("fake_goal", "fake_strategy")
|
||||||
{})
|
|
||||||
self.admin_clients(
|
self.admin_clients(
|
||||||
"watcher").audit_template.create.assert_called_once_with(
|
"watcher").audit_template.create.assert_called_once_with(
|
||||||
goal="fake_goal", strategy="fake_strategy",
|
goal="fake_goal", strategy="fake_strategy",
|
||||||
name="mock_name", extra={})
|
name="mock_name")
|
||||||
self._test_atomic_action_timer(watcher_scenario.atomic_actions(),
|
self._test_atomic_action_timer(watcher_scenario.atomic_actions(),
|
||||||
"watcher.create_audit_template")
|
"watcher.create_audit_template")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user