summaryrefslogtreecommitdiffstats
path: root/tests/unit/benchmark/runner/test_base.py
diff options
context:
space:
mode:
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-02-13 11:02:45 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-02-13 11:02:45 +0000
commit3333efb08ae1d4ee92ea5274f847aabfa95e3eec (patch)
tree69fd366752e18e3c66bcdc6327c35bd77a38ecb2 /tests/unit/benchmark/runner/test_base.py
parent44f31bf01c787501d0c077730d4b76bb02a3faaf (diff)
parentba4e9e6e47bd10ecc803bab920178ea973c2fa86 (diff)
Merge "Move tests: unit/benchmark"
Diffstat (limited to 'tests/unit/benchmark/runner/test_base.py')
-rw-r--r--tests/unit/benchmark/runner/test_base.py95
1 files changed, 0 insertions, 95 deletions
diff --git a/tests/unit/benchmark/runner/test_base.py b/tests/unit/benchmark/runner/test_base.py
deleted file mode 100644
index f47b88e95..000000000
--- a/tests/unit/benchmark/runner/test_base.py
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd 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
-##############################################################################
-
-from __future__ import print_function
-from __future__ import absolute_import
-
-import unittest
-import time
-
-from mock import mock
-
-from yardstick.benchmark.runners import base
-from yardstick.benchmark.runners.iteration import IterationRunner
-
-
-class ActionTestCase(unittest.TestCase):
-
- @mock.patch("yardstick.benchmark.runners.base.subprocess")
- def test__execute_shell_command(self, mock_subprocess):
- mock_subprocess.check_output.side_effect = Exception()
-
- self.assertEqual(base._execute_shell_command("")[0], -1)
-
- @mock.patch("yardstick.benchmark.runners.base.subprocess")
- def test__single_action(self, mock_subprocess):
- mock_subprocess.check_output.side_effect = Exception()
-
- base._single_action(0, "echo", mock.MagicMock())
-
- @mock.patch("yardstick.benchmark.runners.base.subprocess")
- def test__periodic_action(self, mock_subprocess):
- mock_subprocess.check_output.side_effect = Exception()
-
- base._periodic_action(0, "echo", mock.MagicMock())
-
-
-class RunnerTestCase(unittest.TestCase):
-
- @mock.patch("yardstick.benchmark.runners.iteration.multiprocessing")
- def test_get_output(self, mock_process):
- runner = IterationRunner({})
- runner.output_queue.put({'case': 'opnfv_yardstick_tc002'})
- runner.output_queue.put({'criteria': 'PASS'})
-
- idle_result = {
- 'case': 'opnfv_yardstick_tc002',
- 'criteria': 'PASS'
- }
-
- for retries in range(1000):
- time.sleep(0.01)
- if not runner.output_queue.empty():
- break
- actual_result = runner.get_output()
- self.assertEqual(idle_result, actual_result)
-
- @mock.patch("yardstick.benchmark.runners.iteration.multiprocessing")
- def test_get_result(self, mock_process):
- runner = IterationRunner({})
- runner.result_queue.put({'case': 'opnfv_yardstick_tc002'})
- runner.result_queue.put({'criteria': 'PASS'})
-
- idle_result = [
- {'case': 'opnfv_yardstick_tc002'},
- {'criteria': 'PASS'}
- ]
-
- for retries in range(1000):
- time.sleep(0.01)
- if not runner.result_queue.empty():
- break
- actual_result = runner.get_result()
- self.assertEqual(idle_result, actual_result)
-
- def test__run_benchmark(self):
- runner = base.Runner(mock.Mock())
-
- with self.assertRaises(NotImplementedError):
- runner._run_benchmark(mock.Mock(), mock.Mock(), mock.Mock(), mock.Mock())
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()