Merge "Open storperf testcase to huawei-pod2"
[yardstick.git] / tests / unit / benchmark / runner / test_base.py
1 #!/usr/bin/env python
2
3 ##############################################################################
4 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
11
12 from __future__ import print_function
13 from __future__ import absolute_import
14
15 import unittest
16 import time
17
18 from mock import mock
19
20 from yardstick.benchmark.runners.iteration import IterationRunner
21
22
23 class RunnerTestCase(unittest.TestCase):
24
25     @mock.patch("yardstick.benchmark.runners.iteration.multiprocessing")
26     def test_get_output(self, mock_process):
27         runner = IterationRunner({})
28         runner.output_queue.put({'case': 'opnfv_yardstick_tc002'})
29         runner.output_queue.put({'criteria': 'PASS'})
30
31         idle_result = {
32             'case': 'opnfv_yardstick_tc002',
33             'criteria': 'PASS'
34         }
35
36         for retries in range(1000):
37             time.sleep(0.01)
38             if not runner.output_queue.empty():
39                 break
40         actual_result = runner.get_output()
41         self.assertEqual(idle_result, actual_result)
42
43
44 def main():
45     unittest.main()
46
47
48 if __name__ == '__main__':
49     main()