summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Koistinen <miikka.koistinen@nokia.com>2018-05-24 15:30:12 +0300
committerMiikka Koistinen <miikka.koistinen@nokia.com>2018-06-25 15:23:10 +0300
commit5e04a8a99bdb13de5c95d9dfebd98ed7ec697ff3 (patch)
tree7b3415fdb1d45fa5a61c22a8a42a8faa76d8770d
parentd64760d051ec14002847352a20da02774a8bda05 (diff)
Add unit test file for DurationRunner
JIRA: YARDSTICK-1199 Change-Id: I5526935207ae3661a4cb8b8d25e93bc26adc3ef2 Signed-off-by: Miikka Koistinen <miikka.koistinen@nokia.com>
-rw-r--r--yardstick/tests/unit/benchmark/runner/test_duration.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/yardstick/tests/unit/benchmark/runner/test_duration.py b/yardstick/tests/unit/benchmark/runner/test_duration.py
new file mode 100644
index 000000000..21e3874b8
--- /dev/null
+++ b/yardstick/tests/unit/benchmark/runner/test_duration.py
@@ -0,0 +1,39 @@
+##############################################################################
+# Copyright (c) 2018 Nokia and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+import mock
+import unittest
+import multiprocessing
+import os
+
+from yardstick.benchmark.runners import duration
+
+
+class DurationRunnerTest(unittest.TestCase):
+ def setUp(self):
+ self.scenario_cfg = {
+ 'runner': {'interval': 0, "duration": 0},
+ 'type': 'some_type'
+ }
+
+ @mock.patch.object(os, 'getpid')
+ @mock.patch.object(multiprocessing, 'Process')
+ def test__run_benchmark_called_with(self, mock_multiprocessing_process,
+ mock_os_getpid):
+ mock_os_getpid.return_value = 101
+
+ runner = duration.DurationRunner({})
+ benchmark_cls = mock.Mock()
+ runner._run_benchmark(benchmark_cls, 'my_method', self.scenario_cfg,
+ {})
+ mock_multiprocessing_process.assert_called_once_with(
+ name='Duration-some_type-101',
+ target=duration._worker_process,
+ args=(runner.result_queue, benchmark_cls, 'my_method',
+ self.scenario_cfg, {}, runner.aborted, runner.output_queue))