diff options
-rw-r--r-- | docker/Dockerfile.centos7 | 3 | ||||
-rw-r--r-- | docs/dovetailtool/dovetail.tool.installation.rst | 12 | ||||
-rw-r--r-- | dovetail/conf/cmd_config.yml | 13 | ||||
-rw-r--r-- | dovetail/conf/dovetail_config.py | 31 | ||||
-rw-r--r-- | dovetail/conf/dovetail_config.yml | 12 | ||||
-rw-r--r-- | dovetail/container.py | 8 | ||||
-rw-r--r-- | dovetail/parser.py | 4 | ||||
-rw-r--r-- | dovetail/report.py | 5 | ||||
-rwxr-xr-x | dovetail/run.py | 31 | ||||
-rw-r--r-- | dovetail/testcase.py | 14 | ||||
-rw-r--r-- | dovetail/tests/unit/test_parser.py | 4 | ||||
-rw-r--r-- | dovetail/utils/dovetail_logger.py | 4 |
12 files changed, 83 insertions, 58 deletions
diff --git a/docker/Dockerfile.centos7 b/docker/Dockerfile.centos7 index 965c535b..0107cb7b 100644 --- a/docker/Dockerfile.centos7 +++ b/docker/Dockerfile.centos7 @@ -5,7 +5,8 @@ LABEL version="0.1" description="OPNFV Dovetail Docker Container" ARG BRANCH=master RUN yum update -y && yum install -y sudo iproute epel-release && \ - yum install -y python-pip git && \ + yum install -y python-pip git docker && \ + sed -ie 's/requiretty/!requiretty/g' /etc/sudoers && \ pip install pyyaml click jinja2 ENV HOME /home/opnfv diff --git a/docs/dovetailtool/dovetail.tool.installation.rst b/docs/dovetailtool/dovetail.tool.installation.rst index 3c145059..93871e76 100644 --- a/docs/dovetailtool/dovetail.tool.installation.rst +++ b/docs/dovetailtool/dovetail.tool.installation.rst @@ -131,8 +131,16 @@ Pull Dovetail Docker image from public Dockerhub <Tag> here is the version, 'latest' is used for the master branch. -As an alternative way, you can build own docker image from Dockfile(s) under ``docker/`` directory, -``Dockerfile`` is based on ubuntu system and ``Dockerfile.centos7`` is for centos7. +(Optional) Create Docker image from Dockerfile +----------------------------------------------- +Instead of an official Docker image, you can build your own Docker image from +Dockerfile(s) located under the ``docker/`` directory. The ``Dockerfile`` +is based on Ubuntu and the ``Dockerfile.centos7`` file is for a CentOS based +Docker image. + +:: + + sudo docker build -t <your_new_image_name> -f <your_Dockerfile> . Dovetail Docker container creation ---------------------------------- diff --git a/dovetail/conf/cmd_config.yml b/dovetail/conf/cmd_config.yml index 4e3d0110..35c000ef 100644 --- a/dovetail/conf/cmd_config.yml +++ b/dovetail/conf/cmd_config.yml @@ -31,11 +31,11 @@ cli: - '--DEPLOY_TYPE' - '-T' help: 'DEPLOY_TYPE of the system under test (SUT).' - DEBUG: + CON_DEBUG: flags: - - '--DEBUG' - - '-d' - help: 'DEBUG for showing debug log.' + - '--CON_DEBUG' + - '-c' + help: 'True for showing debug log in functest/yardstick container.' non-envs: testsuite: flags: @@ -52,3 +52,8 @@ cli: - '--tag' - '-o' help: 'Overwrite tags for each docker container (e.g. "functest:stable,yardstick:latest")' + debug: + flags: + - '--debug' + - '-d' + help: 'True for showing debug log in screen.' diff --git a/dovetail/conf/dovetail_config.py b/dovetail/conf/dovetail_config.py index 14dc59a3..d812c5c9 100644 --- a/dovetail/conf/dovetail_config.py +++ b/dovetail/conf/dovetail_config.py @@ -14,15 +14,14 @@ import re class DovetailConfig: - COMPLIANCE_PATH = './compliance/' - TESTCASE_PATH = './testcase/' - # testsuite supported tuple, should adjust accordingly - testsuite_supported = ('compliance_set', 'proposed_tests', 'debug') - # testarea supported tuple, should adjust accordingly - testarea_supported = ('vimops', 'nfvi', 'ipv6') - dovetail_config = {} + CMD_NAME_TRANS = { + 'SUT_TYPE': 'INSTALLER_TYPE', + 'SUT_IP': 'INSTALLER_IP', + 'CON_DEBUG': 'CI_DEBUG', + } + @classmethod def load_config_files(cls): curr_path = os.path.dirname(os.path.abspath(__file__)) @@ -42,11 +41,7 @@ class DovetailConfig: @classmethod def cmd_name_trans(cls, cmd_name): key = cmd_name.upper() - if key == 'SUT_TYPE': - key = 'INSTALLER_TYPE' - if key == 'SUT_IP': - key = 'INSTALLER_IP' - return key + return cls.CMD_NAME_TRANS.get(key, key) @classmethod def update_envs(cls, options): @@ -55,18 +50,16 @@ class DovetailConfig: if not options[item] and key in os.environ: options[item] = os.environ[key] if options[item]: - cls.update_config_envs('functest', key) - cls.update_config_envs('yardstick', key) + cls.update_config_envs('functest', key, options[item]) + cls.update_config_envs('yardstick', key, options[item]) @classmethod - def update_config_envs(cls, script_type, key): - if key == 'DEBUG': - os.environ['CI_DEBUG'] = os.environ[key] + def update_config_envs(cls, script_type, key, value): envs = cls.dovetail_config[script_type]['envs'] old_value = re.findall(r'\s+%s=(.*?)(\s+|$)' % key, envs) if old_value == []: - envs += ' -e ' + key + '=' + os.environ[key] + envs += ' -e ' + key + '=' + value else: - envs = envs.replace(old_value[0][0], os.environ[key]) + envs = envs.replace(old_value[0][0], value) cls.dovetail_config[script_type]['envs'] = envs return envs diff --git a/dovetail/conf/dovetail_config.yml b/dovetail/conf/dovetail_config.yml index c4131a91..be2d075d 100644 --- a/dovetail/conf/dovetail_config.yml +++ b/dovetail/conf/dovetail_config.yml @@ -5,6 +5,18 @@ report_file: 'dovetail_report.txt' cli_file_name: 'cmd_config.yml' # TO DO: once version scheme settled, adjust accordingly repo: 'https://github.com/opnfv/dovetail/tree/master/' +COMPLIANCE_PATH: ./compliance/ +TESTCASE_PATH: ./testcase/ +# testsuite supported, should adjust accordingly +testsuite_supported: + - compliance_set + - proposed_tests + - debug +# testarea supported, should adjust accordingly +testarea_supported: + - vimops + - nfvi + - ipv6 # used for testcase cmd template in jinja2 format # we have two variables available now diff --git a/dovetail/container.py b/dovetail/container.py index 67a70767..af05dcd5 100644 --- a/dovetail/container.py +++ b/dovetail/container.py @@ -10,7 +10,7 @@ import utils.dovetail_logger as dt_logger import utils.dovetail_utils as dt_utils -from conf.dovetail_config import DovetailConfig as dt_config +from conf.dovetail_config import DovetailConfig as dt_cfg class Container: @@ -36,13 +36,13 @@ class Container: @staticmethod def get_docker_image(type): - return '%s:%s' % (dt_config.dovetail_config[type]['image_name'], - dt_config.dovetail_config[type]['docker_tag']) + return '%s:%s' % (dt_cfg.dovetail_config[type]['image_name'], + dt_cfg.dovetail_config[type]['docker_tag']) @classmethod def create(cls, type): sshkey = "-v /root/.ssh/id_rsa:/root/.ssh/id_rsa " - dovetail_config = dt_config.dovetail_config + dovetail_config = dt_cfg.dovetail_config docker_image = cls.get_docker_image(type) envs = dovetail_config[type]['envs'] opts = dovetail_config[type]['opts'] diff --git a/dovetail/parser.py b/dovetail/parser.py index 4385325d..ad969bc2 100644 --- a/dovetail/parser.py +++ b/dovetail/parser.py @@ -12,7 +12,7 @@ import jinja2 import utils.dovetail_logger as dt_logger import utils.dovetail_utils as dt_utils -from conf.dovetail_config import DovetailConfig as dt_config +from conf.dovetail_config import DovetailConfig as dt_cfg class Parser: @@ -30,7 +30,7 @@ class Parser: try: template = jinja2.Template(cmd, undefined=jinja2.StrictUndefined) kwargs = {} - for arg in dt_config.dovetail_config['parameters']: + for arg in dt_cfg.dovetail_config['parameters']: path = eval(arg['path']) cls.logger.debug('name: %s, eval path: %s ' % (arg['name'], path)) diff --git a/dovetail/report.py b/dovetail/report.py index a6fff20c..2e2a24f3 100644 --- a/dovetail/report.py +++ b/dovetail/report.py @@ -106,7 +106,7 @@ class Report: sub_report = {} testcase_num = {} testcase_passnum = {} - for area in dt_cfg.testarea_supported: + for area in dt_cfg.dovetail_config['testarea_supported']: sub_report[area] = '' testcase_num[area] = 0 testcase_passnum[area] = 0 @@ -114,7 +114,8 @@ class Report: # TO DO: once version scheme settled, adjust accordingly spec_link = dt_cfg.dovetail_config['repo'] + 'dovetail/testcase' for testcase in report_data['testcases_list']: - pattern = re.compile('|'.join(dt_cfg.testarea_supported)) + pattern = re.compile( + '|'.join(dt_cfg.dovetail_config['testarea_supported'])) area = pattern.findall(testcase['name'])[0] result_dir = dt_cfg.dovetail_config['result_dir'] sub_report[area] += '- <%s> %s result: <%s>\n' %\ diff --git a/dovetail/run.py b/dovetail/run.py index 0c57b4ed..d9bc0aaa 100755 --- a/dovetail/run.py +++ b/dovetail/run.py @@ -23,7 +23,7 @@ from testcase import Testsuite from report import Report from report import FunctestCrawler, YardstickCrawler from report import FunctestChecker, YardstickChecker -from conf.dovetail_config import DovetailConfig as dt_config +from conf.dovetail_config import DovetailConfig as dt_cfg def load_testsuite(testsuite): @@ -36,7 +36,7 @@ def set_container_tags(option_str): option_str = script_tag_opt.split(':') script_type = option_str[0].strip() script_tag = option_str[1].strip() - dt_config.dovetail_config[script_type]['docker_tag'] = script_tag + dt_cfg.dovetail_config[script_type]['docker_tag'] = script_tag def load_testcase(): @@ -110,7 +110,7 @@ def filter_env_options(input_dict): envs_options = {} for key, value in input_dict.items(): key = key.upper() - if key in dt_config.dovetail_config['cli']['options']['envs']: + if key in dt_cfg.dovetail_config['cli']['options']['envs']: envs_options[key] = value return envs_options @@ -128,7 +128,7 @@ def create_logs(): def clean_results_dir(): - result_path = dt_config.dovetail_config['result_dir'] + result_path = dt_cfg.dovetail_config['result_dir'] if os.path.exists(result_path): if os.path.isdir(result_path): cmd = 'sudo rm -rf %s/*' % (result_path) @@ -141,6 +141,8 @@ def clean_results_dir(): def main(*args, **kwargs): """Dovetail compliance test entry!""" clean_results_dir() + if kwargs['debug']: + os.environ['DEBUG'] = kwargs['debug'] create_logs() logger = dt_logger.Logger('run').getLogger() logger.info('================================================') @@ -148,11 +150,11 @@ def main(*args, **kwargs): logger.info('================================================') validate_options(kwargs, logger) envs_options = filter_env_options(kwargs) - dt_config.update_envs(envs_options) + dt_cfg.update_envs(envs_options) logger.info('Your new envs for functest: %s' % - dt_config.dovetail_config['functest']['envs']) + dt_cfg.dovetail_config['functest']['envs']) logger.info('Your new envs for yardstick: %s' % - dt_config.dovetail_config['yardstick']['envs']) + dt_cfg.dovetail_config['yardstick']['envs']) if 'tag' in kwargs and kwargs['tag'] is not None: set_container_tags(kwargs['tag']) @@ -160,9 +162,10 @@ def main(*args, **kwargs): testarea = kwargs['testarea'] testsuite_validation = False testarea_validation = False - if (testarea == 'full') or (testarea in dt_config.testarea_supported): + if (testarea == 'full') or \ + (testarea in dt_cfg.dovetail_config['testarea_supported']): testarea_validation = True - if kwargs['testsuite'] in dt_config.testsuite_supported: + if kwargs['testsuite'] in dt_cfg.dovetail_config['testsuite_supported']: testsuite_validation = True if testsuite_validation and testarea_validation: testsuite_yaml = load_testsuite(kwargs['testsuite']) @@ -174,18 +177,18 @@ def main(*args, **kwargs): (kwargs['testsuite'], testarea)) -dt_config.load_config_files() +dt_cfg.load_config_files() CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) -if dt_config.dovetail_config['cli']['options'] is not None: - for key, value in dt_config.dovetail_config['cli']['options'].items(): +if dt_cfg.dovetail_config['cli']['options'] is not None: + for key, value in dt_cfg.dovetail_config['cli']['options'].items(): if value is not None: for k, v in value.items(): flags = v['flags'] del v['flags'] main = click.option(*flags, **v)(main) -if dt_config.dovetail_config['cli']['arguments'] is not None: - for key, value in dt_config.dovetail_config['cli']['arguments'].items(): +if dt_cfg.dovetail_config['cli']['arguments'] is not None: + for key, value in dt_cfg.dovetail_config['cli']['arguments'].items(): if value is not None: for k, v in value.items(): flags = v['flags'] diff --git a/dovetail/testcase.py b/dovetail/testcase.py index 9cd8e777..3385fe04 100644 --- a/dovetail/testcase.py +++ b/dovetail/testcase.py @@ -13,7 +13,7 @@ import yaml import utils.dovetail_logger as dt_logger from parser import Parser -from conf.dovetail_config import DovetailConfig as dt_config +from conf.dovetail_config import DovetailConfig as dt_cfg class Testcase: @@ -34,7 +34,7 @@ class Testcase: def prepare_cmd(self): script_type = self.script_type() - for cmd in dt_config.dovetail_config[script_type]['testcase']['cmds']: + for cmd in dt_cfg.dovetail_config[script_type]['testcase']['cmds']: cmd_lines = Parser.parse_cmd(cmd, self) if not cmd_lines: return False @@ -111,11 +111,11 @@ class Testcase: @staticmethod def pre_condition_cls(script_type): - return dt_config.dovetail_config[script_type]['pre_condition'] + return dt_cfg.dovetail_config[script_type]['pre_condition'] @staticmethod def post_condition_cls(script_type): - return dt_config.dovetail_config[script_type]['post_condition'] + return dt_cfg.dovetail_config[script_type]['post_condition'] @classmethod def update_script_testcase(cls, script_type, script_testcase): @@ -144,7 +144,8 @@ class Testcase: @classmethod def load(cls): - for root, dirs, files in os.walk(dt_config.TESTCASE_PATH): + for root, dirs, files in \ + os.walk(dt_cfg.dovetail_config['TESTCASE_PATH']): for testcase_file in files: with open(os.path.join(root, testcase_file)) as f: testcase_yaml = yaml.safe_load(f) @@ -180,7 +181,8 @@ class Testsuite: @classmethod def load(cls): - for root, dirs, files in os.walk(dt_config.COMPLIANCE_PATH): + for root, dirs, files in \ + os.walk(dt_cfg.dovetail_config['COMPLIANCE_PATH']): for testsuite_yaml in files: with open(os.path.join(root, testsuite_yaml)) as f: testsuite_yaml = yaml.safe_load(f) diff --git a/dovetail/tests/unit/test_parser.py b/dovetail/tests/unit/test_parser.py index 2183bd60..8d32995c 100644 --- a/dovetail/tests/unit/test_parser.py +++ b/dovetail/tests/unit/test_parser.py @@ -25,8 +25,8 @@ class TestParser(unittest.TestCase): def setUp(self): """Test case setup""" - from conf.dovetail_config import DovetailConfig as dt_config - dt_config.load_config_files() + from conf.dovetail_config import DovetailConfig as dt_cfg + dt_cfg.load_config_files() dovetail_parser.Parser.create_log() logging.disable(logging.CRITICAL) diff --git a/dovetail/utils/dovetail_logger.py b/dovetail/utils/dovetail_logger.py index 8afa08a1..bb09a7b1 100644 --- a/dovetail/utils/dovetail_logger.py +++ b/dovetail/utils/dovetail_logger.py @@ -24,7 +24,7 @@ import logging import os -from conf.dovetail_config import DovetailConfig as dt_config +from conf.dovetail_config import DovetailConfig as dt_cfg class Logger: @@ -46,7 +46,7 @@ class Logger: ch.setLevel(logging.INFO) self.logger.addHandler(ch) - result_path = dt_config.dovetail_config['result_dir'] + result_path = dt_cfg.dovetail_config['result_dir'] if not os.path.exists(result_path): os.makedirs(result_path) hdlr = logging.FileHandler(os.path.join(result_path, 'dovetail.log')) |