aboutsummaryrefslogtreecommitdiffstats
path: root/functest/ci
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2017-05-05 14:38:27 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2017-05-05 16:18:47 +0200
commitee26a1ca85fc5fac6df6c39f362fad83de73c0cc (patch)
tree4e649ef404854dfa62e05e74d4437bec75edb936 /functest/ci
parent7489b8ed94857ba2eacb02d75fdcef3f1721b00e (diff)
Print the real testcase duration
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 <cedric.ollivier@orange.com>
Diffstat (limited to 'functest/ci')
-rwxr-xr-xfunctest/ci/run_tests.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/functest/ci/run_tests.py b/functest/ci/run_tests.py
index d1361260..d9f3fe42 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):