summaryrefslogtreecommitdiffstats
path: root/dovetail/testcase.py
diff options
context:
space:
mode:
Diffstat (limited to 'dovetail/testcase.py')
-rw-r--r--dovetail/testcase.py78
1 files changed, 43 insertions, 35 deletions
diff --git a/dovetail/testcase.py b/dovetail/testcase.py
index 408599fc..b6819964 100644
--- a/dovetail/testcase.py
+++ b/dovetail/testcase.py
@@ -39,7 +39,7 @@ class Testcase(object):
return False
# self.logger.debug('cmd_lines:%s', cmd_lines)
self.cmds.append(cmd_lines)
- self.logger.debug('cmds:%s', self.cmds)
+ self.logger.debug('cmds: {}'.format(self.cmds))
return True
def prepare_cmd(self, test_type):
@@ -55,7 +55,7 @@ class Testcase(object):
return self.parse_cmd(testcase_cmds)
if config_cmds:
return self.parse_cmd(config_cmds)
- self.logger.error('testcase %s has no cmds', self.name())
+ self.logger.error('Test case {} has no cmds.'.format(self.name()))
return False
def __str__(self):
@@ -75,7 +75,8 @@ class Testcase(object):
def sub_testcase_passed(self, name, passed=None):
if passed is not None:
- self.logger.debug('sub_testcase_passed:%s %s', name, passed)
+ self.logger.debug(
+ 'sub_testcase_passed: {} {}'.format(name, passed))
self.sub_testcase_status[name] = passed
return self.sub_testcase_status[name]
@@ -111,28 +112,16 @@ class Testcase(object):
return pre_condition
pre_condition = self.pre_condition_cls(self.validate_type())
if not pre_condition:
- self.logger.debug('testcase:%s pre_condition is empty',
- self.name())
+ self.logger.debug(
+ 'Test case: {} pre_condition is empty.'.format(self.name()))
return pre_condition
- def pre_copy_src_path(self, test_type):
+ def pre_copy_path(self, key_name):
try:
- pre_copy_src_file = \
- self.testcase['validate']['pre_copy']['src_file']
- result_dir = dt_cfg.dovetail_config[test_type]['result']['dir']
- except KeyError as e:
- self.logger.error('src file Key error %s', e)
- return None
- src_path = os.path.join(result_dir, pre_copy_src_file)
- return src_path
-
- def pre_copy_dest_path(self):
- try:
- pre_copy_dest_path = \
- self.testcase['validate']['pre_copy']['dest_path']
+ path = self.testcase['validate']['pre_copy'][key_name]
except KeyError:
- pre_copy_dest_path = ''
- return pre_copy_dest_path
+ return None
+ return path
def post_condition(self):
try:
@@ -143,34 +132,35 @@ class Testcase(object):
return post_condition
post_condition = self.post_condition_cls(self.validate_type())
if not post_condition:
- self.logger.debug('testcae:%s post_condition is empty',
- self.name())
+ self.logger.debug(
+ 'Test case: {} post_condition is empty.'.format(self.name()))
return post_condition
def mk_src_file(self):
- testcase_src_file = self.testcase['validate']['pre_copy']['src_file']
+ testcase_src_file = self.pre_copy_path('src_file')
try:
file_path = os.path.join(dt_cfg.dovetail_config['result_dir'],
testcase_src_file)
with open(file_path, 'w+') as src_file:
if self.sub_testcase() is not None:
for sub_test in self.sub_testcase():
- self.logger.debug('save testcases %s', sub_test)
+ self.logger.debug(
+ 'Save test cases {}'.format(sub_test))
src_file.write(sub_test + '\n')
- self.logger.debug('save testcases to %s', file_path)
+ self.logger.debug('Save test cases to {}'.format(file_path))
+ return file_path
except Exception:
- self.logger.error('Failed to save: %s', file_path)
-
- src_file_path = os.path.join(dt_cfg.dovetail_config['result_dir'],
- testcase_src_file)
- return src_file_path
+ self.logger.exception('Failed to save: {}'.format(file_path))
+ return None
def run(self):
runner = TestRunnerFactory.create(self)
try:
runner.run()
+ runner.save_logs()
except AttributeError as e:
- self.logger.exception('testcase:%s except:%s', self.name, e)
+ self.logger.exception(
+ 'Test case: {} Exception: {}'.format(self.name, e))
# testcase in upstream testing project
# validate_testcase_list = {'functest': {}, 'yardstick': {}, 'shell': {}}
@@ -244,8 +234,8 @@ class Testcase(object):
cls.testcase_list[next(testcase_yaml.iterkeys())] = \
testcase
else:
- cls.logger.error('failed to create testcase: %s',
- testcase_file)
+ cls.logger.error('Failed to create test case: {}'
+ .format(testcase_file))
@classmethod
def get(cls, testcase_name):
@@ -265,13 +255,30 @@ class FunctestTestcase(Testcase):
class YardstickTestcase(Testcase):
- validate_testcae_list = {}
+ validate_testcase_list = {}
def __init__(self, testcase_yaml):
super(YardstickTestcase, self).__init__(testcase_yaml)
self.type = 'yardstick'
+class BottlenecksTestcase(Testcase):
+
+ validate_testcase_list = {}
+
+ def __init__(self, testcase_yaml):
+ super(BottlenecksTestcase, self).__init__(testcase_yaml)
+ self.type = 'bottlenecks'
+ self._update_cmds()
+
+ def _update_cmds(self):
+ if dt_cfg.dovetail_config['report_dest'].startswith("http"):
+ try:
+ self.testcase['validate']['cmds'][0] += ' --report'
+ except KeyError:
+ return
+
+
class ShellTestcase(Testcase):
validate_testcase_list = {}
@@ -285,6 +292,7 @@ class TestcaseFactory(object):
TESTCASE_TYPE_MAP = {
'functest': FunctestTestcase,
'yardstick': YardstickTestcase,
+ 'bottlenecks': BottlenecksTestcase,
'shell': ShellTestcase,
}