summaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorJo¶rgen Karlsson <jorgen.w.karlsson@ericsson.com>2015-12-11 15:50:22 +0100
committerJörgen Karlsson <jorgen.w.karlsson@ericsson.com>2015-12-15 17:12:55 +0000
commit05c1840c9c4dda154c9c5d00ff3cd23ba202330b (patch)
treee440c79354739c5a9921757226e9d9128ee5766d /tests/unit
parent3dfc4babd729b64757608945536e180e8c8ef271 (diff)
Add run_in_background attribute to scenarios
This change adds the possibility to run scenarios as "background tasks". Background scenarios/tasks: - are started before all "normal scenarios" - runs in parallel with "normal scenarios" - terminates when all "normal scenarios" have completed their tasks They are intended as a way to perform background tasks, e.g. collect data such as cpuload etc, in parallel with the execution of normal benchmarking scenarios. Note that we already have the 'run_in_parallel' attribute but this attribute has a couple of issues and do not solve all the uses cases. Change-Id: I9c5230bfdbbb66030f57b658ce1db87ff2c2d62b Signed-off-by: Jo¶rgen Karlsson <jorgen.w.karlsson@ericsson.com>
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/cmd/commands/test_task.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/unit/cmd/commands/test_task.py b/tests/unit/cmd/commands/test_task.py
index 89813cb98..e785e99a9 100644
--- a/tests/unit/cmd/commands/test_task.py
+++ b/tests/unit/cmd/commands/test_task.py
@@ -36,3 +36,23 @@ class TaskCommandsTestCase(unittest.TestCase):
self.assertEqual(context_cfg["host"], server_info)
self.assertEqual(context_cfg["target"], server_info)
+
+ @mock.patch('yardstick.cmd.commands.task.Context')
+ @mock.patch('yardstick.cmd.commands.task.base_runner')
+ def test_run(self, mock_base_runner, mock_ctx):
+ scenario = \
+ {'host': 'athena.demo',
+ 'target': 'ares.demo',
+ 'runner':
+ {'duration': 60,
+ 'interval': 1,
+ 'type': 'Duration'
+ },
+ 'type': 'Ping'}
+
+ t = task.TaskCommands()
+ runner = mock.Mock()
+ runner.join.return_value = 0
+ mock_base_runner.Runner.get.return_value = runner
+ t._run([scenario], False, "yardstick.out")
+ self.assertTrue(runner.run.called)