diff options
Diffstat (limited to 'dovetail/run.py')
-rwxr-xr-x | dovetail/run.py | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/dovetail/run.py b/dovetail/run.py index 865b3996..0c57b4ed 100755 --- a/dovetail/run.py +++ b/dovetail/run.py @@ -10,18 +10,19 @@ import click import sys +import os +import time import utils.dovetail_logger as dt_logger +import utils.dovetail_utils as dt_utils from parser import Parser from container import Container from testcase import Testcase from testcase import Testsuite from report import Report -from report import FunctestCrawler -from report import YardstickCrawler -from report import FunctestChecker -from report import YardstickChecker +from report import FunctestCrawler, YardstickCrawler +from report import FunctestChecker, YardstickChecker from conf.dovetail_config import DovetailConfig as dt_config @@ -48,6 +49,7 @@ def run_test(testsuite, testarea, logger): if value is not None and (testarea == 'full' or testarea in value): testarea_list.append(value) + duration = 0 for testcase_name in testarea_list: logger.info('>>[testcase]: %s' % (testcase_name)) testcase = Testcase.get(testcase_name) @@ -78,8 +80,11 @@ def run_test(testsuite, testarea, logger): if not testcase.prepare_cmd(): logger.error('failed to prepare testcase:%s' % testcase.name()) else: + start_time = time.time() for cmd in testcase.cmds: Container.exec_cmd(container_id, cmd) + end_time = time.time() + duration = end_time - start_time # testcase.post_condition() @@ -88,6 +93,8 @@ def run_test(testsuite, testarea, logger): db_result = Report.get_result(testcase) Report.check_result(testcase, db_result) + return duration + def validate_options(input_dict, logger): # for 'tag' option @@ -120,8 +127,20 @@ def create_logs(): Testsuite.create_log() +def clean_results_dir(): + result_path = dt_config.dovetail_config['result_dir'] + if os.path.exists(result_path): + if os.path.isdir(result_path): + cmd = 'sudo rm -rf %s/*' % (result_path) + dt_utils.exec_cmd(cmd, exit_on_error=False) + else: + print "result_dir in dovetail_config.yml is not a directory." + sys.exit(-1) + + def main(*args, **kwargs): """Dovetail compliance test entry!""" + clean_results_dir() create_logs() logger = dt_logger.Logger('run').getLogger() logger.info('================================================') @@ -138,8 +157,6 @@ def main(*args, **kwargs): if 'tag' in kwargs and kwargs['tag'] is not None: set_container_tags(kwargs['tag']) - load_testcase() - testsuite_yaml = load_testsuite(kwargs['testsuite']) testarea = kwargs['testarea'] testsuite_validation = False testarea_validation = False @@ -148,8 +165,10 @@ def main(*args, **kwargs): if kwargs['testsuite'] in dt_config.testsuite_supported: testsuite_validation = True if testsuite_validation and testarea_validation: - run_test(testsuite_yaml, testarea, logger) - Report.generate(testsuite_yaml, testarea) + testsuite_yaml = load_testsuite(kwargs['testsuite']) + load_testcase() + duration = run_test(testsuite_yaml, testarea, logger) + Report.generate(testsuite_yaml, testarea, duration) else: logger.error('invalid input commands, testsuite %s testarea %s' % (kwargs['testsuite'], testarea)) |