aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--functest/tests/unit/cli/commands/test_cli_env.py1
-rw-r--r--functest/tests/unit/core/test_testcase_base.py1
-rw-r--r--functest/tests/unit/odl/test_odl.py1
-rw-r--r--functest/tests/unit/utils/test_functest_utils.py1
-rwxr-xr-xrun_unit_tests.sh3
5 files changed, 4 insertions, 3 deletions
diff --git a/functest/tests/unit/cli/commands/test_cli_env.py b/functest/tests/unit/cli/commands/test_cli_env.py
index 4b6ea57a..f70761dc 100644
--- a/functest/tests/unit/cli/commands/test_cli_env.py
+++ b/functest/tests/unit/cli/commands/test_cli_env.py
@@ -11,6 +11,7 @@ import unittest
from git.exc import NoSuchPathError
import mock
+mock.patch('logging.FileHandler').start() # noqa
from functest.cli.commands import cli_env
from functest.utils.constants import CONST
from functest.tests.unit import test_utils
diff --git a/functest/tests/unit/core/test_testcase_base.py b/functest/tests/unit/core/test_testcase_base.py
index b7c81d87..b6efa40d 100644
--- a/functest/tests/unit/core/test_testcase_base.py
+++ b/functest/tests/unit/core/test_testcase_base.py
@@ -11,6 +11,7 @@ import logging
import mock
import unittest
+mock.patch('logging.FileHandler').start() # noqa
from functest.core import testcase_base
diff --git a/functest/tests/unit/odl/test_odl.py b/functest/tests/unit/odl/test_odl.py
index d8c7f84e..4430c3b8 100644
--- a/functest/tests/unit/odl/test_odl.py
+++ b/functest/tests/unit/odl/test_odl.py
@@ -17,6 +17,7 @@ from keystoneauth1.exceptions import auth_plugins
from robot.errors import RobotError
from robot.result import testcase
+mock.patch('logging.FileHandler').start() # noqa
from functest.core import testcase_base
from functest.opnfv_tests.sdn.odl import odl
diff --git a/functest/tests/unit/utils/test_functest_utils.py b/functest/tests/unit/utils/test_functest_utils.py
index ce9086a7..c4b56660 100644
--- a/functest/tests/unit/utils/test_functest_utils.py
+++ b/functest/tests/unit/utils/test_functest_utils.py
@@ -18,6 +18,7 @@ import mock
import requests
from functest.tests.unit import test_utils
+mock.patch('logging.FileHandler').start() # noqa
from functest.utils import functest_utils
diff --git a/run_unit_tests.sh b/run_unit_tests.sh
index e0e6195c..edce03c1 100755
--- a/run_unit_tests.sh
+++ b/run_unit_tests.sh
@@ -21,10 +21,7 @@ clean_results_dir
# TODO clean that...
# Create log dir if needed
# log shall be disabled during unit tests
-# fix to be done in Logger
-echo "Create dummy log file...."
sudo mkdir -p /home/opnfv/functest/results/odl
-sudo touch /home/opnfv/functest/results/functest.log
sudo touch /home/opnfv/functest/results/odl/stdout.txt
sudo chmod -Rf a+rw /home/opnfv
i { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
##############################################################################
# Copyright (c) 2016 ZTE Corp 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 json
import importlib
import sys
from qtip.utils import logger_utils
from os.path import expanduser

logger = logger_utils.QtipLogger('suite_result').get


def get_benchmark_result(benchmark_name, suite_name):
    benchmark_indices = importlib.import_module('scripts.ref_results'
                                                '.{0}_benchmarks_indices'.format(suite_name))
    methodToCall = getattr(benchmark_indices, '{0}_index'.format(benchmark_name))
    return methodToCall()


def get_suite_result(suite_name):
    suite_dict = {}
    suite_bench_list = {'compute': ['DPI', 'Dhrystone', 'Whetstone', 'SSL', 'RamSpeed'],
                        'storage': ['FIO'],
                        'network': ['IPERF']}
    temp = 0
    l = len(suite_bench_list[suite_name])
    for benchmark in suite_bench_list[suite_name]:
        try:
            suite_dict[benchmark] = get_benchmark_result(benchmark.lower(), suite_name)
            temp = temp + float(suite_dict[benchmark]['index'])
        except OSError:
            l = l - 1
            pass

    if l == 0:
        logger.info("No {0} suite results found".format(suite_name))
        return False
    else:
        suite_index = temp / l
        suite_dict_f = {'index': suite_index,
                        'suite_results': suite_dict}
        result_path = expanduser('~') + '/qtip/results'
        with open('{0}/{1}_result.json'.format(result_path, suite_name), 'w+') as result_json:
            json.dump(suite_dict_f, result_json, indent=4, sort_keys=True)
        return True


def main():
    get_suite_result(sys.argv[1])


if __name__ == "__main__":
    main()