aboutsummaryrefslogtreecommitdiffstats
path: root/functest/core
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2016-11-24 10:32:53 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2016-12-07 14:36:26 +0800
commitc5c6dce10bfa43dacd3043ebe9942689eed8b9a4 (patch)
tree6af9c1a441b2bd6f6c33a84b16ed096d2f680afc /functest/core
parentc10898356f97b3f2e5c39928e4133570b75a52e1 (diff)
abstract umbrella part to make integration code simpler
implement an abstract class Umbrella, and take parser for instance JIRA: FUNCTEST-618 Change-Id: Iadf71ad49abd901b9659cb71135fc902a3b616d1 Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'functest/core')
-rw-r--r--functest/core/feature_base.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/functest/core/feature_base.py b/functest/core/feature_base.py
new file mode 100644
index 00000000..01a27f30
--- /dev/null
+++ b/functest/core/feature_base.py
@@ -0,0 +1,58 @@
+import time
+
+import testcase_base as base
+import functest.utils.functest_utils as ft_utils
+import functest.utils.functest_logger as ft_logger
+
+
+class FeatureBase(base.TestcaseBase):
+ def __init__(self, project='functest', case='', repo='', cmd=''):
+ super(FeatureBase, self).__init__()
+ self.project_name = project
+ self.case_name = case
+ self.cmd = cmd
+ self.repo = self.get_conf('general.directories.{}'.format(repo))
+ self.result_file = self.get_result_file()
+ self.logger = ft_logger.Logger(project).getLogger()
+
+ def run(self, **kwargs):
+ self.prepare()
+ self.start_time = time.time()
+ ret = ft_utils.execute_command(self.cmd, output_file=self.result_file)
+ self.stop_time = time.time()
+ self.post()
+ self.parse_results(ret)
+ self.log_results()
+ return base.TestcaseBase.EX_OK
+
+ def prepare(self, **kwargs):
+ pass
+
+ def post(self, **kwargs):
+ pass
+
+ def parse_results(self, ret):
+ exit_code = base.TestcaseBase.EX_OK
+ if ret == 0:
+ self.logger.info("{} OK".format(self.project_name))
+ self.criteria = 'PASS'
+ else:
+ self.logger.info("{} FAILED".format(self.project_name))
+ exit_code = base.TestcaseBase.EX_RUN_ERROR
+ self.criteria = "FAIL"
+
+ return exit_code
+
+ def get_result_file(self):
+ dir = self.get_conf('general.directories.dir_results')
+ return "{}/{}.log".format(dir, self.project_name)
+
+ def log_results(self):
+ ft_utils.logger_test_results(self.project_name,
+ self.case_name,
+ self.criteria,
+ self.details)
+
+ @staticmethod
+ def get_conf(parameter):
+ return ft_utils.get_functest_config(parameter)