From 05c1840c9c4dda154c9c5d00ff3cd23ba202330b Mon Sep 17 00:00:00 2001 From: Jo¶rgen Karlsson Date: Fri, 11 Dec 2015 15:50:22 +0100 Subject: Add run_in_background attribute to scenarios MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tests/unit/cmd/commands/test_task.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') 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) -- cgit 1.2.3-korg