summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/dovetailtool/dovetail.tool.installation.rst16
-rw-r--r--dovetail/conf/cmd_config.yml13
-rw-r--r--dovetail/conf/dovetail_config.py31
-rw-r--r--dovetail/conf/dovetail_config.yml12
-rw-r--r--dovetail/container.py8
-rw-r--r--dovetail/parser.py4
-rw-r--r--dovetail/report.py5
-rwxr-xr-xdovetail/run.py31
-rw-r--r--dovetail/testcase.py14
-rw-r--r--dovetail/tests/unit/test_parser.py4
-rw-r--r--dovetail/utils/dovetail_logger.py4
11 files changed, 87 insertions, 55 deletions
diff --git a/docs/dovetailtool/dovetail.tool.installation.rst b/docs/dovetailtool/dovetail.tool.installation.rst
index 7826f33f..93871e76 100644
--- a/docs/dovetailtool/dovetail.tool.installation.rst
+++ b/docs/dovetailtool/dovetail.tool.installation.rst
@@ -101,6 +101,22 @@ testarea ``ipv6`` in ``compliance_set``
python run.py --testsuite compliance_set --testarea ipv6
+Dovetail provides some sets, ``debug``, ``proposed_tests`` and ``compliance_set``,
+``debug`` is used for locally and Continuous Integration(CI) developing purpose,
+which provides typical testcase examples, feel free to edit it when develops locally, such as
+only to run a testcase which only takes minutes. ``proposed_tests`` is the testcase
+candidate which mainly comes from the wiki link
+https://wiki.opnfv.org/display/dovetail/Dovetail+Test+Areas+and+Test+Cases.
+``compliance_set`` is used for compliance. Moreover, dovetail tool can be easily
+extended to support more complicated compliance requirements,
+such as feature set based or scenario based compliance.
+
+If you want to run ``debug``, just run with
+
+::
+
+ python run.py --testsuite debug
+
Running Dovetail in a Docker container
########################################
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 a0cdf657..6174e313 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 d8f9fa0a..44cb7fcb 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 7fd4076d..a58c560f 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 60ce2b28..77669ce1 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'))