Rename BenchmarkEngine to TaskEngine
The reame is performed as a part of transition to the new task format. Change-Id: Ieaef03138298ef04f52a8f0da2a87b3664130ec8
This commit is contained in:
parent
8347790441
commit
d60bdaff80
@ -232,7 +232,7 @@ class Task(object):
|
||||
deployment = objects.Deployment.get(deployment)
|
||||
task = task_instance or objects.Task(
|
||||
deployment_uuid=deployment["uuid"], temporary=True)
|
||||
benchmark_engine = engine.BenchmarkEngine(
|
||||
benchmark_engine = engine.TaskEngine(
|
||||
config, task, admin=deployment["admin"], users=deployment["users"])
|
||||
|
||||
benchmark_engine.validate()
|
||||
@ -260,7 +260,7 @@ class Task(object):
|
||||
|
||||
LOG.info("Benchmark Task %s on Deployment %s" % (task["uuid"],
|
||||
deployment["uuid"]))
|
||||
benchmark_engine = engine.BenchmarkEngine(
|
||||
benchmark_engine = engine.TaskEngine(
|
||||
config, task, admin=deployment["admin"], users=deployment["users"],
|
||||
abort_on_sla_failure=abort_on_sla_failure)
|
||||
|
||||
|
@ -68,10 +68,10 @@ class NotFoundScenarios(InvalidTaskException):
|
||||
msg_fmt = _("There are no benchmark scenarios with names: `%(names)s`.")
|
||||
|
||||
|
||||
class InvalidBenchmarkConfig(InvalidTaskException):
|
||||
class InvalidTaskConfig(InvalidTaskException):
|
||||
msg_fmt = _("Input task is invalid!\n\n"
|
||||
"Benchmark %(name)s[%(pos)s] has wrong configuration"
|
||||
"\nBenchmark configuration:\n%(config)s\n"
|
||||
"Subtask %(name)s[%(pos)s] has wrong configuration"
|
||||
"\Subtask configuration:\n%(config)s\n"
|
||||
"\nReason:\n %(reason)s")
|
||||
|
||||
|
||||
|
@ -138,12 +138,12 @@ class ResultConsumer(object):
|
||||
time.sleep(2.0)
|
||||
|
||||
|
||||
class BenchmarkEngine(object):
|
||||
"""The Benchmark engine class is used to execute benchmark scenarios.
|
||||
class TaskEngine(object):
|
||||
"""The Task engine class is used to execute benchmark scenarios.
|
||||
|
||||
An instance of this class is initialized by the API with the benchmarks
|
||||
An instance of this class is initialized by the API with the task
|
||||
configuration and then is used to validate and execute all specified
|
||||
in config benchmarks.
|
||||
in config subtasks.
|
||||
|
||||
.. note::
|
||||
|
||||
@ -155,14 +155,14 @@ class BenchmarkEngine(object):
|
||||
users = .... # contains a list of dicts of representations of
|
||||
# objects.Endpoint with OpenStack users credentials.
|
||||
|
||||
engine = BenchmarkEngine(config, task, admin=admin, users=users)
|
||||
engine = TaskEngine(config, task, admin=admin, users=users)
|
||||
engine.validate() # to test config
|
||||
engine.run() # to run config
|
||||
"""
|
||||
|
||||
def __init__(self, config, task, admin=None, users=None,
|
||||
abort_on_sla_failure=False):
|
||||
"""BenchmarkEngine constructor.
|
||||
"""TaskEngine constructor.
|
||||
|
||||
:param config: Dict with configuration of specified benchmark scenarios
|
||||
:param task: Instance of Task,
|
||||
@ -215,7 +215,7 @@ class BenchmarkEngine(object):
|
||||
sla.SLA.validate(scenario_obj.get("sla", {}))
|
||||
except (exceptions.RallyException,
|
||||
jsonschema.ValidationError) as e:
|
||||
raise exceptions.InvalidBenchmarkConfig(
|
||||
raise exceptions.InvalidTaskConfig(
|
||||
name=scenario_obj["name"],
|
||||
pos=pos, config=scenario_obj,
|
||||
reason=six.text_type(e)
|
||||
@ -229,7 +229,7 @@ class BenchmarkEngine(object):
|
||||
except exceptions.InvalidScenarioArgument as e:
|
||||
kw = {"name": name, "pos": pos,
|
||||
"config": kwargs, "reason": six.text_type(e)}
|
||||
raise exceptions.InvalidBenchmarkConfig(**kw)
|
||||
raise exceptions.InvalidTaskConfig(**kw)
|
||||
|
||||
def _get_user_ctx_for_validation(self, ctx):
|
||||
if self.existing_users:
|
||||
|
@ -33,10 +33,10 @@ class TaskSampleTestCase(test.TestCase):
|
||||
os.pardir, os.pardir, os.pardir,
|
||||
"samples", "tasks")
|
||||
|
||||
@mock.patch("rally.task.engine.BenchmarkEngine"
|
||||
@mock.patch("rally.task.engine.TaskEngine"
|
||||
"._validate_config_semantic")
|
||||
def test_schema_is_valid(self,
|
||||
mock_benchmark_engine__validate_config_semantic):
|
||||
mock_task_engine__validate_config_semantic):
|
||||
scenarios = set()
|
||||
|
||||
for dirname, dirnames, filenames in os.walk(self.samples_path):
|
||||
@ -52,7 +52,7 @@ class TaskSampleTestCase(test.TestCase):
|
||||
try:
|
||||
task_config = yaml.safe_load(api.Task.render_template
|
||||
(task_file.read()))
|
||||
eng = engine.BenchmarkEngine(task_config,
|
||||
eng = engine.TaskEngine(task_config,
|
||||
mock.MagicMock())
|
||||
eng.validate()
|
||||
except Exception:
|
||||
|
@ -28,10 +28,10 @@ class RallyJobsTestCase(test.TestCase):
|
||||
rally_jobs_path = os.path.join(
|
||||
os.path.dirname(__file__), "..", "..", "..", "rally-jobs")
|
||||
|
||||
@mock.patch("rally.task.engine.BenchmarkEngine"
|
||||
@mock.patch("rally.task.engine.TaskEngine"
|
||||
"._validate_config_semantic")
|
||||
def test_schema_is_valid(
|
||||
self, mock_benchmark_engine__validate_config_semantic):
|
||||
self, mock_task_engine__validate_config_semantic):
|
||||
discover.load_plugins(os.path.join(self.rally_jobs_path, "plugins"))
|
||||
|
||||
for filename in ["rally.yaml", "rally-neutron.yaml",
|
||||
@ -55,7 +55,7 @@ class RallyJobsTestCase(test.TestCase):
|
||||
task = api.Task.render_template(task_file.read(), **args)
|
||||
task = yaml.safe_load(task)
|
||||
|
||||
eng = engine.BenchmarkEngine(task, mock.MagicMock())
|
||||
eng = engine.TaskEngine(task, mock.MagicMock())
|
||||
eng.validate()
|
||||
except Exception:
|
||||
print(traceback.format_exc())
|
||||
|
@ -32,14 +32,14 @@ class TestException(exceptions.RallyException):
|
||||
msg_fmt = "TestException"
|
||||
|
||||
|
||||
class BenchmarkEngineTestCase(test.TestCase):
|
||||
class TaskEngineTestCase(test.TestCase):
|
||||
|
||||
@mock.patch("rally.task.engine.TaskConfig")
|
||||
def test_init(self, mock_task_config):
|
||||
config = mock.MagicMock()
|
||||
task = mock.MagicMock()
|
||||
mock_task_config.return_value = fake_task_instance = mock.MagicMock()
|
||||
eng = engine.BenchmarkEngine(config, task)
|
||||
eng = engine.TaskEngine(config, task)
|
||||
mock_task_config.assert_has_calls([mock.call(config)])
|
||||
self.assertEqual(eng.config, fake_task_instance)
|
||||
self.assertEqual(eng.task, task)
|
||||
@ -48,7 +48,7 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
@mock.patch("jsonschema.validate")
|
||||
def test_validate(self, mock_validate, mock_task_config):
|
||||
mock_task_config.return_value = config = mock.MagicMock()
|
||||
eng = engine.BenchmarkEngine(mock.MagicMock(), mock.MagicMock())
|
||||
eng = engine.TaskEngine(mock.MagicMock(), mock.MagicMock())
|
||||
mock_validate = mock.MagicMock()
|
||||
|
||||
eng._validate_config_scenarios_name = mock_validate.names
|
||||
@ -70,13 +70,13 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
}
|
||||
task = mock.MagicMock()
|
||||
self.assertRaises(exceptions.InvalidTaskException,
|
||||
engine.BenchmarkEngine, config, task)
|
||||
engine.TaskEngine, config, task)
|
||||
self.assertTrue(task.set_failed.called)
|
||||
|
||||
@mock.patch("rally.task.engine.TaskConfig")
|
||||
def test_validate__wrong_scenarios_name(self, mock_task_config):
|
||||
task = mock.MagicMock()
|
||||
eng = engine.BenchmarkEngine(mock.MagicMock(), task)
|
||||
eng = engine.TaskEngine(mock.MagicMock(), task)
|
||||
eng._validate_config_scenarios_name = mock.MagicMock(
|
||||
side_effect=exceptions.NotFoundScenarios)
|
||||
|
||||
@ -86,10 +86,10 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
@mock.patch("rally.task.engine.TaskConfig")
|
||||
def test_validate__wrong_syntax(self, mock_task_config):
|
||||
task = mock.MagicMock()
|
||||
eng = engine.BenchmarkEngine(mock.MagicMock(), task)
|
||||
eng = engine.TaskEngine(mock.MagicMock(), task)
|
||||
eng._validate_config_scenarios_name = mock.MagicMock()
|
||||
eng._validate_config_syntax = mock.MagicMock(
|
||||
side_effect=exceptions.InvalidBenchmarkConfig)
|
||||
side_effect=exceptions.InvalidTaskConfig)
|
||||
|
||||
self.assertRaises(exceptions.InvalidTaskException, eng.validate)
|
||||
self.assertTrue(task.set_failed.called)
|
||||
@ -97,11 +97,11 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
@mock.patch("rally.task.engine.TaskConfig")
|
||||
def test_validate__wrong_semantic(self, mock_task_config):
|
||||
task = mock.MagicMock()
|
||||
eng = engine.BenchmarkEngine(mock.MagicMock(), task)
|
||||
eng = engine.TaskEngine(mock.MagicMock(), task)
|
||||
eng._validate_config_scenarios_name = mock.MagicMock()
|
||||
eng._validate_config_syntax = mock.MagicMock()
|
||||
eng._validate_config_semantic = mock.MagicMock(
|
||||
side_effect=exceptions.InvalidBenchmarkConfig)
|
||||
side_effect=exceptions.InvalidTaskConfig)
|
||||
|
||||
self.assertRaises(exceptions.InvalidTaskException, eng.validate)
|
||||
self.assertTrue(task.set_failed.called)
|
||||
@ -124,7 +124,7 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
mock.MagicMock(get_name=lambda: "b"),
|
||||
mock.MagicMock(get_name=lambda: "a")
|
||||
]
|
||||
eng = engine.BenchmarkEngine(mock.MagicMock(), mock.MagicMock())
|
||||
eng = engine.TaskEngine(mock.MagicMock(), mock.MagicMock())
|
||||
eng._validate_config_scenarios_name(mock_task_instance)
|
||||
|
||||
@mock.patch("rally.task.engine.TaskConfig")
|
||||
@ -141,7 +141,7 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
]
|
||||
mock_task_instance.subtasks = [mock_subtask]
|
||||
mock_scenario.list_benchmark_scenarios.return_value = ["exist", "aaa"]
|
||||
eng = engine.BenchmarkEngine(mock.MagicMock(), mock.MagicMock())
|
||||
eng = engine.TaskEngine(mock.MagicMock(), mock.MagicMock())
|
||||
|
||||
self.assertRaises(exceptions.NotFoundScenarios,
|
||||
eng._validate_config_scenarios_name,
|
||||
@ -162,7 +162,7 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
{"name": "scb", "runner": "b"}
|
||||
]
|
||||
mock_task_instance.subtasks = [mock_subtask]
|
||||
eng = engine.BenchmarkEngine(mock.MagicMock(), mock.MagicMock())
|
||||
eng = engine.TaskEngine(mock.MagicMock(), mock.MagicMock())
|
||||
eng._validate_config_syntax(mock_task_instance)
|
||||
mock_scenario_runner_validate.assert_has_calls(
|
||||
[mock.call({}), mock.call("b")], any_order=True)
|
||||
@ -183,11 +183,11 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
{"name": "scb", "runner": "b"}
|
||||
]
|
||||
mock_task_instance.subtasks = [mock_subtask]
|
||||
eng = engine.BenchmarkEngine(mock.MagicMock(), mock.MagicMock())
|
||||
eng = engine.TaskEngine(mock.MagicMock(), mock.MagicMock())
|
||||
|
||||
mock_scenario_runner.validate = mock.MagicMock(
|
||||
side_effect=jsonschema.ValidationError("a"))
|
||||
self.assertRaises(exceptions.InvalidBenchmarkConfig,
|
||||
self.assertRaises(exceptions.InvalidTaskConfig,
|
||||
eng._validate_config_syntax, mock_task_instance)
|
||||
|
||||
@mock.patch("rally.task.engine.TaskConfig")
|
||||
@ -203,11 +203,11 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
{"name": "scb", "runner": "b"}
|
||||
]
|
||||
mock_task_instance.subtasks = [mock_subtask]
|
||||
eng = engine.BenchmarkEngine(mock.MagicMock(), mock.MagicMock())
|
||||
eng = engine.TaskEngine(mock.MagicMock(), mock.MagicMock())
|
||||
|
||||
mock_context_manager.validate = mock.MagicMock(
|
||||
side_effect=jsonschema.ValidationError("a"))
|
||||
self.assertRaises(exceptions.InvalidBenchmarkConfig,
|
||||
self.assertRaises(exceptions.InvalidTaskConfig,
|
||||
eng._validate_config_syntax, mock_task_instance)
|
||||
|
||||
@mock.patch("rally.task.engine.TaskConfig")
|
||||
@ -215,7 +215,7 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
def test__validate_config_semantic_helper(self, mock_scenario_validate,
|
||||
mock_task_config):
|
||||
deployment = mock.MagicMock()
|
||||
eng = engine.BenchmarkEngine(mock.MagicMock(), mock.MagicMock())
|
||||
eng = engine.TaskEngine(mock.MagicMock(), mock.MagicMock())
|
||||
eng._validate_config_semantic_helper("admin", "user", "name", "pos",
|
||||
deployment, {"args": "args"})
|
||||
mock_scenario_validate.assert_called_once_with(
|
||||
@ -227,9 +227,9 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
side_effect=exceptions.InvalidScenarioArgument)
|
||||
def test__validate_config_semanitc_helper_invalid_arg(
|
||||
self, mock_scenario_validate, mock_task_config):
|
||||
eng = engine.BenchmarkEngine(mock.MagicMock(), mock.MagicMock())
|
||||
eng = engine.TaskEngine(mock.MagicMock(), mock.MagicMock())
|
||||
|
||||
self.assertRaises(exceptions.InvalidBenchmarkConfig,
|
||||
self.assertRaises(exceptions.InvalidTaskConfig,
|
||||
eng._validate_config_semantic_helper, "a", "u", "n",
|
||||
"p", mock.MagicMock(), {})
|
||||
|
||||
@ -241,8 +241,8 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
context = {"a": 10}
|
||||
users = [mock.MagicMock(), mock.MagicMock()]
|
||||
|
||||
eng = engine.BenchmarkEngine(mock.MagicMock(), mock.MagicMock(),
|
||||
users=users)
|
||||
eng = engine.TaskEngine(mock.MagicMock(), mock.MagicMock(),
|
||||
users=users)
|
||||
|
||||
result = eng._get_user_ctx_for_validation(context)
|
||||
|
||||
@ -254,7 +254,7 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
@mock.patch("rally.task.engine.TaskConfig")
|
||||
@mock.patch("rally.task.engine.osclients.Clients")
|
||||
@mock.patch("rally.task.engine.users_ctx")
|
||||
@mock.patch("rally.task.engine.BenchmarkEngine"
|
||||
@mock.patch("rally.task.engine.TaskEngine"
|
||||
"._validate_config_semantic_helper")
|
||||
@mock.patch("rally.task.engine.objects.Deployment.get",
|
||||
return_value="FakeDeployment")
|
||||
@ -279,7 +279,7 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
|
||||
mock_task_instance.subtasks = [mock_subtask1, mock_subtask2]
|
||||
fake_task = mock.MagicMock()
|
||||
eng = engine.BenchmarkEngine(mock_task_instance, fake_task)
|
||||
eng = engine.TaskEngine(mock_task_instance, fake_task)
|
||||
|
||||
eng.admin = "admin"
|
||||
|
||||
@ -320,7 +320,7 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
|
||||
task = mock.MagicMock()
|
||||
mock_task_get_status.return_value = consts.TaskStatus.ABORTING
|
||||
eng = engine.BenchmarkEngine(mock.MagicMock(), task)
|
||||
eng = engine.TaskEngine(mock.MagicMock(), task)
|
||||
eng.run()
|
||||
task.update_status.assert_has_calls([
|
||||
mock.call(consts.TaskStatus.RUNNING),
|
||||
@ -346,13 +346,13 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
mock_task_instance = mock.MagicMock()
|
||||
mock_subtask = mock.MagicMock()
|
||||
mock_subtask.scenarios = [
|
||||
{"name": "a.benchmark", "context": {"context_a": {"a": 1}}},
|
||||
{"name": "b.benchmark", "context": {"context_b": {"b": 2}}}
|
||||
{"name": "a.task", "context": {"context_a": {"a": 1}}},
|
||||
{"name": "b.task", "context": {"context_b": {"b": 2}}}
|
||||
]
|
||||
mock_task_instance.subtasks = [mock_subtask]
|
||||
|
||||
mock_task_config.return_value = mock_task_instance
|
||||
eng = engine.BenchmarkEngine(mock.MagicMock(), mock.MagicMock())
|
||||
eng = engine.TaskEngine(mock.MagicMock(), mock.MagicMock())
|
||||
eng.run()
|
||||
|
||||
self.assertEqual(2, mock_log.exception.call_count)
|
||||
@ -371,15 +371,15 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
False,
|
||||
True]
|
||||
config = {
|
||||
"a.benchmark": [{"runner": {"type": "a", "b": 1}}],
|
||||
"b.benchmark": [{"runner": {"type": "a", "b": 1}}],
|
||||
"c.benchmark": [{"runner": {"type": "a", "b": 1}}]
|
||||
"a.task": [{"runner": {"type": "a", "b": 1}}],
|
||||
"b.task": [{"runner": {"type": "a", "b": 1}}],
|
||||
"c.task": [{"runner": {"type": "a", "b": 1}}]
|
||||
}
|
||||
fake_runner_cls = mock.MagicMock()
|
||||
fake_runner = mock.MagicMock()
|
||||
fake_runner_cls.return_value = fake_runner
|
||||
mock_scenario_runner.get.return_value = fake_runner_cls
|
||||
eng = engine.BenchmarkEngine(config, task)
|
||||
eng = engine.TaskEngine(config, task)
|
||||
|
||||
eng.run()
|
||||
|
||||
@ -399,16 +399,16 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
mock_result_consumer, mock_task_get_status):
|
||||
task = mock.MagicMock()
|
||||
config = {
|
||||
"a.benchmark": [{"runner": {"type": "a", "b": 1}}],
|
||||
"b.benchmark": [{"runner": {"type": "a", "b": 1}}],
|
||||
"c.benchmark": [{"runner": {"type": "a", "b": 1}}]
|
||||
"a.task": [{"runner": {"type": "a", "b": 1}}],
|
||||
"b.task": [{"runner": {"type": "a", "b": 1}}],
|
||||
"c.task": [{"runner": {"type": "a", "b": 1}}]
|
||||
}
|
||||
fake_runner_cls = mock.MagicMock()
|
||||
fake_runner = mock.MagicMock()
|
||||
fake_runner_cls.return_value = fake_runner
|
||||
mock_task_get_status.return_value = consts.TaskStatus.SOFT_ABORTING
|
||||
mock_scenario_runner.get.return_value = fake_runner_cls
|
||||
eng = engine.BenchmarkEngine(config, task)
|
||||
eng = engine.TaskEngine(config, task)
|
||||
eng.run()
|
||||
self.assertEqual(mock.call(consts.TaskStatus.ABORTED),
|
||||
task.update_status.mock_calls[-1])
|
||||
@ -419,13 +419,13 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
default_context = {"a": 1, "b": 2}
|
||||
mock_scenario_get.return_value._meta_get.return_value = default_context
|
||||
task = mock.MagicMock()
|
||||
name = "a.benchmark"
|
||||
name = "a.task"
|
||||
context = {"b": 3, "c": 4}
|
||||
endpoint = mock.MagicMock()
|
||||
config = {
|
||||
"a.benchmark": [{"context": {"context_a": {"a": 1}}}],
|
||||
"a.task": [{"context": {"context_a": {"a": 1}}}],
|
||||
}
|
||||
eng = engine.BenchmarkEngine(config, task)
|
||||
eng = engine.TaskEngine(config, task)
|
||||
result = eng._prepare_context(context, name, endpoint)
|
||||
expected_context = copy.deepcopy(default_context)
|
||||
expected_context.setdefault("users", {})
|
||||
@ -448,14 +448,14 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
mock_task_config):
|
||||
mock_scenario_get.return_value._meta_get.return_value = {}
|
||||
task = mock.MagicMock()
|
||||
name = "a.benchmark"
|
||||
name = "a.task"
|
||||
context = {"b": 3, "c": 4}
|
||||
endpoint = mock.MagicMock()
|
||||
config = {
|
||||
"a.benchmark": [{"context": {"context_a": {"a": 1}}}],
|
||||
"a.task": [{"context": {"context_a": {"a": 1}}}],
|
||||
}
|
||||
existing_users = [mock.MagicMock()]
|
||||
eng = engine.BenchmarkEngine(config, task, users=existing_users)
|
||||
eng = engine.TaskEngine(config, task, users=existing_users)
|
||||
result = eng._prepare_context(context, name, endpoint)
|
||||
expected_context = {"existing_users": existing_users}
|
||||
expected_context.update(context)
|
||||
@ -540,7 +540,7 @@ class ResultConsumerTestCase(test.TestCase):
|
||||
|
||||
key = {"kw": {"fake": 2}, "name": "fake", "pos": 0}
|
||||
|
||||
eng = engine.BenchmarkEngine({}, task)
|
||||
eng = engine.TaskEngine({}, task)
|
||||
eng.duration = 123
|
||||
eng.full_duration = 456
|
||||
|
||||
@ -597,12 +597,12 @@ class ResultConsumerTestCase(test.TestCase):
|
||||
@mock.patch("rally.task.engine.threading.Thread")
|
||||
@mock.patch("rally.task.engine.threading.Event")
|
||||
@mock.patch("rally.common.objects.Task.get_status")
|
||||
@mock.patch("rally.task.engine.BenchmarkEngine._prepare_context")
|
||||
@mock.patch("rally.task.engine.TaskEngine._prepare_context")
|
||||
@mock.patch("rally.task.engine.time.sleep")
|
||||
@mock.patch("rally.task.engine.BenchmarkEngine._get_runner")
|
||||
@mock.patch("rally.task.engine.TaskEngine._get_runner")
|
||||
def test_wait_and_abort_on_abort(
|
||||
self, mock_benchmark_engine__get_runner,
|
||||
mock_sleep, mock_benchmark_engine__prepare_context,
|
||||
self, mock_task_engine__get_runner,
|
||||
mock_sleep, mock_task_engine__prepare_context,
|
||||
mock_task_get_status, mock_event, mock_thread):
|
||||
runner = mock.MagicMock()
|
||||
key = mock.MagicMock()
|
||||
@ -624,12 +624,12 @@ class ResultConsumerTestCase(test.TestCase):
|
||||
@mock.patch("rally.task.engine.threading.Thread")
|
||||
@mock.patch("rally.task.engine.threading.Event")
|
||||
@mock.patch("rally.common.objects.Task.get_status")
|
||||
@mock.patch("rally.task.engine.BenchmarkEngine._prepare_context")
|
||||
@mock.patch("rally.task.engine.TaskEngine._prepare_context")
|
||||
@mock.patch("rally.task.engine.time.sleep")
|
||||
@mock.patch("rally.task.engine.BenchmarkEngine._get_runner")
|
||||
@mock.patch("rally.task.engine.TaskEngine._get_runner")
|
||||
def test_wait_and_abort_on_no_abort(
|
||||
self, mock_benchmark_engine__get_runner, mock_sleep,
|
||||
mock_benchmark_engine__prepare_context, mock_task_get_status,
|
||||
self, mock_task_engine__get_runner, mock_sleep,
|
||||
mock_task_engine__prepare_context, mock_task_get_status,
|
||||
mock_event, mock_thread):
|
||||
runner = mock.MagicMock()
|
||||
key = mock.MagicMock()
|
||||
@ -693,23 +693,23 @@ class TaskTestCase(test.TestCase):
|
||||
def test_make_subtasks_v1(self, mock_task_config__validate_json,
|
||||
mock_task_config__get_version, mock_sub_task):
|
||||
mock_task_config__get_version.return_value = 1
|
||||
config = {"a.benchmark": [{"s": 1}, {"s": 2}],
|
||||
"b.benchmark": [{"s": 3}]}
|
||||
config = {"a.task": [{"s": 1}, {"s": 2}],
|
||||
"b.task": [{"s": 3}]}
|
||||
self.assertEqual(3, len(engine.TaskConfig(config).subtasks))
|
||||
mock_sub_task.assert_has_calls([
|
||||
mock.call({
|
||||
"title": "a.benchmark",
|
||||
"scenarios": [{"s": 1, "name": "a.benchmark"}]
|
||||
"title": "a.task",
|
||||
"scenarios": [{"s": 1, "name": "a.task"}]
|
||||
}),
|
||||
mock.call({
|
||||
"title": "a.benchmark",
|
||||
"scenarios": [{"s": 2, "name": "a.benchmark"}]
|
||||
"title": "a.task",
|
||||
"scenarios": [{"s": 2, "name": "a.task"}]
|
||||
}),
|
||||
mock.call({
|
||||
"title": "b.benchmark",
|
||||
"scenarios": [{"s": 3, "name": "b.benchmark"}]
|
||||
"title": "b.task",
|
||||
"scenarios": [{"s": 3, "name": "b.task"}]
|
||||
})
|
||||
])
|
||||
], any_order=True)
|
||||
|
||||
@mock.patch("rally.task.engine.SubTask")
|
||||
@mock.patch("rally.task.engine.TaskConfig._get_version")
|
||||
|
@ -60,12 +60,12 @@ class TaskAPITestCase(test.TestCase):
|
||||
return_value=fakes.FakeDeployment(uuid="deployment_uuid",
|
||||
admin=mock.MagicMock(),
|
||||
users=[]))
|
||||
@mock.patch("rally.api.engine.BenchmarkEngine")
|
||||
@mock.patch("rally.api.engine.TaskEngine")
|
||||
def test_validate(
|
||||
self, mock_benchmark_engine, mock_deployment_get, mock_task):
|
||||
self, mock_task_engine, mock_deployment_get, mock_task):
|
||||
api.Task.validate(mock_deployment_get.return_value["uuid"], "config")
|
||||
|
||||
mock_benchmark_engine.assert_has_calls([
|
||||
mock_task_engine.assert_has_calls([
|
||||
mock.call("config", mock_task.return_value,
|
||||
admin=mock_deployment_get.return_value["admin"],
|
||||
users=[]),
|
||||
@ -83,12 +83,12 @@ class TaskAPITestCase(test.TestCase):
|
||||
return_value=fakes.FakeDeployment(uuid="deployment_uuid",
|
||||
admin=mock.MagicMock(),
|
||||
users=[]))
|
||||
@mock.patch("rally.api.engine.BenchmarkEngine")
|
||||
def test_validate_engine_exception(self, mock_benchmark_engine,
|
||||
@mock.patch("rally.api.engine.TaskEngine")
|
||||
def test_validate_engine_exception(self, mock_task_engine,
|
||||
mock_deployment, mock_task):
|
||||
|
||||
excpt = exceptions.InvalidTaskException()
|
||||
mock_benchmark_engine.return_value.validate.side_effect = excpt
|
||||
mock_task_engine.return_value.validate.side_effect = excpt
|
||||
self.assertRaises(exceptions.InvalidTaskException, api.Task.validate,
|
||||
mock_deployment.return_value["uuid"], "config")
|
||||
|
||||
@ -163,12 +163,12 @@ class TaskAPITestCase(test.TestCase):
|
||||
return_value=fakes.FakeDeployment(uuid="deployment_uuid",
|
||||
admin=mock.MagicMock(),
|
||||
users=[]))
|
||||
@mock.patch("rally.api.engine.BenchmarkEngine")
|
||||
def test_start(self, mock_benchmark_engine, mock_deployment_get,
|
||||
@mock.patch("rally.api.engine.TaskEngine")
|
||||
def test_start(self, mock_task_engine, mock_deployment_get,
|
||||
mock_task):
|
||||
api.Task.start(mock_deployment_get.return_value["uuid"], "config")
|
||||
|
||||
mock_benchmark_engine.assert_has_calls([
|
||||
mock_task_engine.assert_has_calls([
|
||||
mock.call("config", mock_task.return_value,
|
||||
admin=mock_deployment_get.return_value["admin"],
|
||||
users=[], abort_on_sla_failure=False),
|
||||
@ -196,11 +196,11 @@ class TaskAPITestCase(test.TestCase):
|
||||
|
||||
@mock.patch("rally.api.objects.Task")
|
||||
@mock.patch("rally.api.objects.Deployment.get")
|
||||
@mock.patch("rally.api.engine.BenchmarkEngine")
|
||||
def test_start_exception(self, mock_benchmark_engine, mock_deployment_get,
|
||||
@mock.patch("rally.api.engine.TaskEngine")
|
||||
def test_start_exception(self, mock_task_engine, mock_deployment_get,
|
||||
mock_task):
|
||||
mock_task.return_value.is_temporary = False
|
||||
mock_benchmark_engine.return_value.run.side_effect = TypeError
|
||||
mock_task_engine.return_value.run.side_effect = TypeError
|
||||
self.assertRaises(TypeError, api.Task.start, "deployment_uuid",
|
||||
"config")
|
||||
mock_deployment_get().update_status.assert_called_once_with(
|
||||
|
Loading…
Reference in New Issue
Block a user