diff options
author | xudan <xudan16@huawei.com> | 2017-05-25 04:35:18 -0400 |
---|---|---|
committer | xudan <xudan16@huawei.com> | 2017-05-25 22:51:50 -0400 |
commit | ed7f8ee3697be3751dc6cfb243cc55092ddd1dd5 (patch) | |
tree | 82e64038198e38303286f256441ee6245e44b659 /dovetail/run.py | |
parent | ed7de0f59902094646ec53e0c3af192538833611 (diff) |
Change the directories of results and some files to DOVETAIL_HOME
JIRA: DOVETAIL-438
1. Need an env variable DOVETAIL_HOME in env_config.sh
2. env_config.sh, pod.yaml and id_rsa should be put in path DOVETAIL_HOME/pre_config
3. the results will also be put in this path
4. no need to give the path of openstack credential file while running a testsuite
5. if running with the code, source the env_config.sh file before running
source $DOVETAIL_HOME/env_config.sh
dovetail run --testsuite <testsuite_name>
6. if running with Dovetail docker image
docker run -it --privileged=true -e DOVETAIL_HOME=<dovetail_home_path>
-v <dovetail_home_path>:<dovetail_home_path>
-v /var/run/docker.sock:/var/run/docker.sock
opnfv/dovetail:latest /bin/bash
Change-Id: Ia23078f27a34e293d0075e49c673930f41069cb6
Signed-off-by: xudan <xudan16@huawei.com>
Diffstat (limited to 'dovetail/run.py')
-rwxr-xr-x | dovetail/run.py | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/dovetail/run.py b/dovetail/run.py index 5b4dca8e..521379d7 100755 --- a/dovetail/run.py +++ b/dovetail/run.py @@ -181,23 +181,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' @@ -207,6 +220,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) |