diff options
Diffstat (limited to 'dovetail/run.py')
-rwxr-xr-x | dovetail/run.py | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/dovetail/run.py b/dovetail/run.py index a191e399..84bd88f3 100755 --- a/dovetail/run.py +++ b/dovetail/run.py @@ -87,14 +87,18 @@ def check_tc_result(testcase, logger): logger.error("Fail to push results to database.") if dt_cfg.dovetail_config['report_dest'] == "file": if validate_type.lower() == 'yardstick': - logger.info("Results have been stored with file %s.", - os.path.join(result_dir, - testcase.validate_testcase() + '.out')) - if validate_type.lower() == 'functest': - logger.info("Results have been stored with file %s.", - os.path.join(result_dir, functest_result)) - result = Report.get_result(testcase) - Report.check_result(testcase, result) + result_file = os.path.join(result_dir, testcase.name() + '.out') + elif validate_type.lower() == 'functest': + result_file = os.path.join(result_dir, functest_result) + else: + logger.error("Don't support %s now.", validate_type) + return + if os.path.isfile(result_file): + logger.info("Results have been stored with file %s.", result_file) + result = Report.get_result(testcase) + Report.check_result(testcase, result) + else: + logger.error("Fail to store results with file %s.", result_file) def validate_input(input_dict, check_dict, logger): @@ -176,23 +180,36 @@ def clean_results_dir(): def get_result_path(): - dovetail_home = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + try: + dovetail_home = os.environ["DOVETAIL_HOME"] + except Exception: + print("ERROR: mandatory env variable 'DOVETAIL_HOME' is not found, " + "please set in env_config.sh and source this file before " + "running.") + return None result_path = os.path.join(dovetail_home, 'results') dt_cfg.dovetail_config['result_dir'] = result_path + pre_config_path = os.path.join(dovetail_home, 'pre_config') + dt_cfg.dovetail_config['config_dir'] = pre_config_path + return dovetail_home -def get_userconfig_path(): +def copy_userconfig_files(logger): dovetail_home = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) userconfig_path = os.path.join(dovetail_home, 'userconfig') - dt_cfg.dovetail_config['userconfig_dir'] = userconfig_path + pre_config_path = dt_cfg.dovetail_config['config_dir'] + if not os.path.isdir(pre_config_path): + os.makedirs(pre_config_path) + cmd = 'sudo cp -r %s/* %s' % (userconfig_path, pre_config_path) + dt_utils.exec_cmd(cmd, logger, exit_on_error=False) def main(*args, **kwargs): """Dovetail compliance test entry!""" build_tag = "daily-master-%s" % str(uuid.uuid4()) dt_cfg.dovetail_config['build_tag'] = build_tag - get_result_path() - get_userconfig_path() + if not get_result_path(): + return clean_results_dir() if kwargs['debug']: os.environ['DEBUG'] = 'true' @@ -202,6 +219,7 @@ def main(*args, **kwargs): logger.info('Dovetail compliance: %s!', (kwargs['testsuite'])) logger.info('================================================') logger.info('Build tag: %s', dt_cfg.dovetail_config['build_tag']) + copy_userconfig_files(logger) dt_utils.check_docker_version(logger) validate_input(kwargs, dt_cfg.dovetail_config['validate_input'], logger) configs = filter_config(kwargs, logger) |