summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthewLi <matthew.lijun@huawei.com>2016-12-09 03:31:28 -0500
committerMatthewLi <matthew.lijun@huawei.com>2016-12-09 03:47:45 -0500
commita875b9d4ff6b5c8492f38ea87f8e11c02ebe66b9 (patch)
treec17a9e68fd7b1e062a5cc2d21f5153dd3e3ac582
parenta372d5dff98c600f0318ac8e60e7db37cd47aaa8 (diff)
[dovetail tool]: move config info from .py to config .yml file
JIRA: DOVETAIL-145 Change-Id: Ia9b3c678f1a491e5daf2d280f05904ead3b0a296 Signed-off-by: MatthewLi <matthew.lijun@huawei.com>
-rw-r--r--dovetail/conf/dovetail_config.py7
-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.py29
-rw-r--r--dovetail/testcase.py14
-rw-r--r--dovetail/tests/unit/test_parser.py4
-rw-r--r--dovetail/utils/dovetail_logger.py4
9 files changed, 48 insertions, 39 deletions
diff --git a/dovetail/conf/dovetail_config.py b/dovetail/conf/dovetail_config.py
index 14dc59a3..a5669bda 100644
--- a/dovetail/conf/dovetail_config.py
+++ b/dovetail/conf/dovetail_config.py
@@ -14,13 +14,6 @@ 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 = {}
@classmethod
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..724dc305 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)
@@ -148,11 +148,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 +160,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 +175,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'))