From ee26a1ca85fc5fac6df6c39f362fad83de73c0cc Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Fri, 5 May 2017 14:38:27 +0200 Subject: Print the real testcase duration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TestCase offers a new public method to calculate and print the duration. It also adds the related unit tests and adapts run_tests.py. Change-Id: Ib6a7e637dafacb9027146199aeb033c2dcb986c6 Signed-off-by: Cédric Ollivier --- functest/ci/run_tests.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'functest/ci/run_tests.py') diff --git a/functest/ci/run_tests.py b/functest/ci/run_tests.py index d13612603..d9f3fe42d 100755 --- a/functest/ci/run_tests.py +++ b/functest/ci/run_tests.py @@ -9,7 +9,6 @@ # import argparse -import datetime import enum import importlib import logging @@ -121,8 +120,8 @@ def get_run_dict(testname): def run_test(test, tier_name, testcases=None): + duration = "XX:XX" result_str = "PASS" - start = datetime.datetime.now() test_name = test.get_name() logger.info("\n") # blank line print_separator("=") @@ -146,7 +145,6 @@ def run_test(test, tier_name, testcases=None): cls = getattr(module, run_dict['class']) test_dict = ft_utils.get_dict_by_test(test_name) test_case = cls(**test_dict) - try: kwargs = run_dict['args'] result = test_case.run(**kwargs) @@ -155,7 +153,8 @@ def run_test(test, tier_name, testcases=None): if result == testcase.TestCase.EX_OK: if GlobalVariables.REPORT_FLAG: test_case.push_to_db() - result = test_case.check_result() + result = test_case.is_successful() + duration = test_case.get_duration() except ImportError: logger.exception("Cannot import module {}".format( run_dict['module'])) @@ -168,12 +167,9 @@ def run_test(test, tier_name, testcases=None): if test.needs_clean() and GlobalVariables.CLEAN_FLAG: cleanup() - end = datetime.datetime.now() - duration = (end - start).seconds - duration_str = ("%02d:%02d" % divmod(duration, 60)) - logger.info("Test execution time: %s" % duration_str) + logger.info("Test execution time: %s", duration) - if result != 0: + if result != testcase.TestCase.EX_OK: logger.error("The test case '%s' failed. " % test_name) GlobalVariables.OVERALL_RESULT = Result.EX_ERROR result_str = "FAIL" @@ -181,12 +177,12 @@ def run_test(test, tier_name, testcases=None): if test.is_blocking(): if not testcases or testcases == "all": # if it is a single test we don't print the whole results table - update_test_info(test_name, result_str, duration_str) + update_test_info(test_name, result_str, duration) generate_report.main(GlobalVariables.EXECUTED_TEST_CASES) raise BlockingTestFailed("The test case {} failed and is blocking" .format(test.get_name())) - update_test_info(test_name, result_str, duration_str) + update_test_info(test_name, result_str, duration) def run_tier(tier): -- cgit 1.2.3-korg