本文整理汇总了Python中rally.task.runner._run_scenario_once函数的典型用法代码示例。如果您正苦于以下问题:Python _run_scenario_once函数的具体用法?Python _run_scenario_once怎么用?Python _run_scenario_once使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_run_scenario_once函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_run_scenario_once_internal_logic
def test_run_scenario_once_internal_logic(self):
context = runner._get_scenario_context(
12, fakes.FakeContext({}).context)
scenario_cls = mock.MagicMock()
runner._run_scenario_once(scenario_cls, "test", context, {})
expected_calls = [
mock.call(context),
mock.call().test(),
mock.call().idle_duration(),
mock.call().idle_duration(),
mock.call().atomic_actions()
]
scenario_cls.assert_has_calls(expected_calls, any_order=True)
示例2: _run_scenario
def _run_scenario(self, cls, method_name, context, args):
"""Runs the specified scenario with given arguments.
The scenario iterations are executed one-by-one in the same python
interpreter process as Rally. This allows you to execute
scenario without introducing any concurrent operations as well as
interactively debug the scenario from the same command that you use
to start Rally.
:param cls: The Scenario class where the scenario is implemented
:param method_name: Name of the method that implements the scenario
:param context: context that contains users, admin & other
information, that was created before scenario
execution starts.
:param args: Arguments to call the scenario method with
:returns: List of results fore each single scenario iteration,
where each result is a dictionary
"""
times = self.config.get("times", 1)
event_queue = rutils.DequeAsQueue(self.event_queue)
for i in range(times):
if self.aborted.is_set():
break
result = runner._run_scenario_once(
cls, method_name, runner._get_scenario_context(i, context),
args, event_queue)
self._send_result(result)
self._flush_results()
示例3: _run_scenario_once_with_sleep
def _run_scenario_once_with_sleep(args):
iteration, cls, method_name, context_obj, kwargs, pause = args
# Time to take a break
time.sleep(pause)
args = (iteration, cls, method_name, context_obj, kwargs)
return runner._run_scenario_once(args)
示例4: _run_scenario_once_with_unpack_args
def _run_scenario_once_with_unpack_args(args):
# NOTE(andreykurilin): `pool.imap` is used in
# ConstantForDurationScenarioRunner. It does not want to work with
# instance-methods, class-methods and static-methods. Also, it can't
# transmit positional or keyword arguments to destination function.
# While original `rally.task.runner._run_scenario_once` accepts
# multiple arguments instead of one big tuple with all arguments, we
# need to hardcode unpacking here(all other runners are able to
# transmit arguments in proper way).
return runner._run_scenario_once(*args)
示例5: _run_scenario
def _run_scenario(self, cls, method_name, context, args):
# runners settings are stored in self.config
min_times = self.config.get("min_times", 1)
max_times = self.config.get("max_times", 1)
for i in range(random.randrange(min_times, max_times)):
run_args = (i, cls, method_name,
runner._get_scenario_context(context), args)
result = runner._run_scenario_once(run_args)
# use self.send_result for result of each iteration
self._send_result(result)
示例6: test_run_scenario_once_internal_logic
def test_run_scenario_once_internal_logic(self):
context = runner._get_scenario_context(
12, fakes.FakeContext({}).context)
scenario_cls = mock.MagicMock()
event_queue = mock.MagicMock()
runner._run_scenario_once(
scenario_cls, "test", context, {}, event_queue)
expected_calls = [
mock.call(context),
mock.call().test(),
mock.call().idle_duration(),
mock.call().idle_duration(),
mock.call().atomic_actions()
]
scenario_cls.assert_has_calls(expected_calls, any_order=True)
event_queue.put.assert_called_once_with(
{"type": "iteration", "value": 13})
示例7: test_run_scenario_once_without_scenario_output
def test_run_scenario_once_without_scenario_output(self, mock_timer):
result = runner._run_scenario_once(
fakes.FakeScenario, "do_it", mock.MagicMock(), {})
expected_result = {
"duration": fakes.FakeTimer().duration(),
"timestamp": fakes.FakeTimer().timestamp(),
"idle_duration": 0,
"error": [],
"output": {"additive": [], "complete": []},
"atomic_actions": {}
}
self.assertEqual(expected_result, result)
示例8: test_run_scenario_once_without_scenario_output
def test_run_scenario_once_without_scenario_output(self, mock_timer):
args = (1, fakes.FakeScenario, "do_it", mock.MagicMock(), {})
result = runner._run_scenario_once(args)
expected_result = {
"duration": fakes.FakeTimer().duration(),
"timestamp": fakes.FakeTimer().timestamp(),
"idle_duration": 0,
"error": [],
"scenario_output": {"errors": "", "data": {}},
"atomic_actions": {}
}
self.assertEqual(expected_result, result)
示例9: test_run_scenario_once_exception
def test_run_scenario_once_exception(self, mock_timer):
result = runner._run_scenario_once(
fakes.FakeScenario, "something_went_wrong", mock.MagicMock(), {})
expected_error = result.pop("error")
expected_result = {
"duration": fakes.FakeTimer().duration(),
"timestamp": fakes.FakeTimer().timestamp(),
"idle_duration": 0,
"output": {"additive": [], "complete": []},
"atomic_actions": {}
}
self.assertEqual(expected_result, result)
self.assertEqual(expected_error[:2],
["Exception", "Something went wrong"])
示例10: test_run_scenario_once_with_scenario_output
def test_run_scenario_once_with_scenario_output(self, mock_timer):
context = runner._get_scenario_context(
fakes.FakeUserContext({}).context)
args = (1, fakes.FakeScenario, "with_output", context, {})
result = runner._run_scenario_once(args)
expected_result = {
"duration": fakes.FakeTimer().duration(),
"timestamp": fakes.FakeTimer().timestamp(),
"idle_duration": 0,
"error": [],
"scenario_output": fakes.FakeScenario().with_output(),
"atomic_actions": {}
}
self.assertEqual(expected_result, result)
示例11: test_run_scenario_once_exception
def test_run_scenario_once_exception(self, mock_timer):
context = runner._get_scenario_context(
fakes.FakeUserContext({}).context)
args = (1, fakes.FakeScenario, "something_went_wrong", context, {})
result = runner._run_scenario_once(args)
expected_error = result.pop("error")
expected_result = {
"duration": fakes.FakeTimer().duration(),
"timestamp": fakes.FakeTimer().timestamp(),
"idle_duration": 0,
"scenario_output": {"errors": "", "data": {}},
"atomic_actions": {}
}
self.assertEqual(expected_result, result)
self.assertEqual(expected_error[:2],
["Exception", "Something went wrong"])
示例12: test_run_scenario_once_with_returned_scenario_output
def test_run_scenario_once_with_returned_scenario_output(self, mock_timer):
args = (1, fakes.FakeScenario, "with_output", mock.MagicMock(), {})
result = runner._run_scenario_once(args)
expected_result = {
"duration": fakes.FakeTimer().duration(),
"timestamp": fakes.FakeTimer().timestamp(),
"idle_duration": 0,
"error": [],
"output": {"additive": [{"chart_plugin": "StackedArea",
"description": "",
"data": [["a", 1]],
"title": "Scenario output"}],
"complete": []},
"atomic_actions": {}
}
self.assertEqual(expected_result, result)
示例13: test_run_scenario_once_with_added_scenario_output
def test_run_scenario_once_with_added_scenario_output(self, mock_timer):
result = runner._run_scenario_once(
fakes.FakeScenario, "with_add_output", mock.MagicMock(), {})
expected_result = {
"duration": fakes.FakeTimer().duration(),
"timestamp": fakes.FakeTimer().timestamp(),
"idle_duration": 0,
"error": [],
"output": {"additive": [{"chart_plugin": "FooPlugin",
"description": "Additive description",
"data": [["a", 1]],
"title": "Additive"}],
"complete": [{"data": [["a", [[1, 2], [2, 3]]]],
"description": "Complete description",
"title": "Complete",
"chart_plugin": "BarPlugin"}]},
"atomic_actions": {}
}
self.assertEqual(expected_result, result)