summaryrefslogtreecommitdiffstats
path: root/tests/unit/benchmark/runner/test_base.py
blob: 7880fe5a507e8ab9477f97b30edbef1b99ec7e07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/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 multiprocessing
import time

from yardstick.benchmark.runners.iteration import IterationRunner


class RunnerTestCase(unittest.TestCase):

    def test_get_output(self):
        queue = multiprocessing.Queue()
        runner = IterationRunner({}, queue)
        runner.output_queue.put({'case': 'opnfv_yardstick_tc002'})
        runner.output_queue.put({'criteria': 'PASS'})

        idle_result = {
            'case': 'opnfv_yardstick_tc002',
            'criteria': 'PASS'
        }

        time.sleep(1)
        actual_result = runner.get_output()
        self.assertEqual(idle_result, actual_result)


def main():
    unittest.main()


if __name__ == '__main__':
    main()