From eaacf8913a141b1e518ea990e7f12f0a195f8c21 Mon Sep 17 00:00:00 2001 From: SerenaFeng Date: Tue, 28 Mar 2017 18:42:42 +0800 Subject: rename feature_base to feature remove useless suffix _base Change-Id: I63a73fd6fef2fccd9b92c405f64dda50735b0026 Signed-off-by: SerenaFeng --- functest/core/feature.py | 63 +++++++++++++++++++++++++ functest/core/feature_base.py | 63 ------------------------- functest/opnfv_tests/features/barometer.py | 2 +- functest/opnfv_tests/features/copper.py | 2 +- functest/opnfv_tests/features/doctor.py | 2 +- functest/opnfv_tests/features/domino.py | 2 +- functest/opnfv_tests/features/netready.py | 2 +- functest/opnfv_tests/features/odl_sfc.py | 2 +- functest/opnfv_tests/features/promise.py | 2 +- functest/opnfv_tests/features/sdnvpn.py | 2 +- functest/opnfv_tests/features/security_scan.py | 2 +- functest/opnfv_tests/mano/orchestra.py | 2 +- functest/opnfv_tests/vnf/rnc/parser.py | 2 +- functest/opnfv_tests/vnf/router/vyos_vrouter.py | 2 +- 14 files changed, 75 insertions(+), 75 deletions(-) create mode 100644 functest/core/feature.py delete mode 100644 functest/core/feature_base.py (limited to 'functest') diff --git a/functest/core/feature.py b/functest/core/feature.py new file mode 100644 index 00000000..f7f3e460 --- /dev/null +++ b/functest/core/feature.py @@ -0,0 +1,63 @@ +import time + +import testcase as base +import functest.utils.functest_utils as ft_utils +import functest.utils.functest_logger as ft_logger +from functest.utils.constants import CONST + + +class FeatureBase(base.TestCase): + + 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 = CONST.__getattribute__(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 = self.execute() + self.stop_time = time.time() + self.post() + self.parse_results(ret) + self.log_results() + self.logger.info("Test result is stored in '%s'" % self.result_file) + return base.TestCase.EX_OK + + def execute(self): + ''' + Executer method that can be overwritten + By default it executes a shell command. + ''' + return ft_utils.execute_command(self.cmd, output_file=self.result_file) + + def prepare(self, **kwargs): + pass + + def post(self, **kwargs): + pass + + def parse_results(self, ret): + exit_code = base.TestCase.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.TestCase.EX_RUN_ERROR + self.criteria = "FAIL" + + return exit_code + + def get_result_file(self): + return "{}/{}.log".format(CONST.dir_results, self.project_name) + + def log_results(self): + ft_utils.logger_test_results(self.project_name, + self.case_name, + self.criteria, + self.details) diff --git a/functest/core/feature_base.py b/functest/core/feature_base.py deleted file mode 100644 index f7f3e460..00000000 --- a/functest/core/feature_base.py +++ /dev/null @@ -1,63 +0,0 @@ -import time - -import testcase as base -import functest.utils.functest_utils as ft_utils -import functest.utils.functest_logger as ft_logger -from functest.utils.constants import CONST - - -class FeatureBase(base.TestCase): - - 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 = CONST.__getattribute__(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 = self.execute() - self.stop_time = time.time() - self.post() - self.parse_results(ret) - self.log_results() - self.logger.info("Test result is stored in '%s'" % self.result_file) - return base.TestCase.EX_OK - - def execute(self): - ''' - Executer method that can be overwritten - By default it executes a shell command. - ''' - return ft_utils.execute_command(self.cmd, output_file=self.result_file) - - def prepare(self, **kwargs): - pass - - def post(self, **kwargs): - pass - - def parse_results(self, ret): - exit_code = base.TestCase.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.TestCase.EX_RUN_ERROR - self.criteria = "FAIL" - - return exit_code - - def get_result_file(self): - return "{}/{}.log".format(CONST.dir_results, self.project_name) - - def log_results(self): - ft_utils.logger_test_results(self.project_name, - self.case_name, - self.criteria, - self.details) diff --git a/functest/opnfv_tests/features/barometer.py b/functest/opnfv_tests/features/barometer.py index 32067284..fdcd3803 100644 --- a/functest/opnfv_tests/features/barometer.py +++ b/functest/opnfv_tests/features/barometer.py @@ -8,7 +8,7 @@ from baro_tests import collectd -import functest.core.feature_base as base +import functest.core.feature as base class BarometerCollectd(base.FeatureBase): diff --git a/functest/opnfv_tests/features/copper.py b/functest/opnfv_tests/features/copper.py index 735b315d..9f6d8e16 100644 --- a/functest/opnfv_tests/features/copper.py +++ b/functest/opnfv_tests/features/copper.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import functest.core.feature_base as base +import functest.core.feature as base class Copper(base.FeatureBase): diff --git a/functest/opnfv_tests/features/doctor.py b/functest/opnfv_tests/features/doctor.py index 4d295a67..8fb84068 100644 --- a/functest/opnfv_tests/features/doctor.py +++ b/functest/opnfv_tests/features/doctor.py @@ -13,7 +13,7 @@ # 0.2: measure test duration and publish results under json format # # -import functest.core.feature_base as base +import functest.core.feature as base class Doctor(base.FeatureBase): diff --git a/functest/opnfv_tests/features/domino.py b/functest/opnfv_tests/features/domino.py index b36220fa..9a4db737 100644 --- a/functest/opnfv_tests/features/domino.py +++ b/functest/opnfv_tests/features/domino.py @@ -14,7 +14,7 @@ # 0.3: add report flag to push results when needed # 0.4: refactoring to match Test abstraction class -import functest.core.feature_base as base +import functest.core.feature as base class Domino(base.FeatureBase): diff --git a/functest/opnfv_tests/features/netready.py b/functest/opnfv_tests/features/netready.py index dec2a23c..ab2c9da0 100644 --- a/functest/opnfv_tests/features/netready.py +++ b/functest/opnfv_tests/features/netready.py @@ -8,7 +8,7 @@ # # -import functest.core.feature_base as base +import functest.core.feature as base class GluonVping(base.FeatureBase): diff --git a/functest/opnfv_tests/features/odl_sfc.py b/functest/opnfv_tests/features/odl_sfc.py index 1956c9c8..b26c2b58 100644 --- a/functest/opnfv_tests/features/odl_sfc.py +++ b/functest/opnfv_tests/features/odl_sfc.py @@ -7,7 +7,7 @@ # # http://www.apache.org/licenses/LICENSE-2.0 # -import functest.core.feature_base as base +import functest.core.feature as base class OpenDaylightSFC(base.FeatureBase): diff --git a/functest/opnfv_tests/features/promise.py b/functest/opnfv_tests/features/promise.py index 15636fbf..bb270ac9 100644 --- a/functest/opnfv_tests/features/promise.py +++ b/functest/opnfv_tests/features/promise.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import functest.core.feature_base as base +import functest.core.feature as base class Promise(base.FeatureBase): diff --git a/functest/opnfv_tests/features/sdnvpn.py b/functest/opnfv_tests/features/sdnvpn.py index 1919a03c..c375084a 100644 --- a/functest/opnfv_tests/features/sdnvpn.py +++ b/functest/opnfv_tests/features/sdnvpn.py @@ -7,7 +7,7 @@ # # http://www.apache.org/licenses/LICENSE-2.0 # -import functest.core.feature_base as base +import functest.core.feature as base class SdnVpnTests(base.FeatureBase): diff --git a/functest/opnfv_tests/features/security_scan.py b/functest/opnfv_tests/features/security_scan.py index 58f0ec74..ac36e7a3 100644 --- a/functest/opnfv_tests/features/security_scan.py +++ b/functest/opnfv_tests/features/security_scan.py @@ -8,7 +8,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 # -import functest.core.feature_base as base +import functest.core.feature as base from functest.utils.constants import CONST diff --git a/functest/opnfv_tests/mano/orchestra.py b/functest/opnfv_tests/mano/orchestra.py index fd5e40d0..a805b62b 100644 --- a/functest/opnfv_tests/mano/orchestra.py +++ b/functest/opnfv_tests/mano/orchestra.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import functest.core.feature_base as base +import functest.core.feature as base class Orchestra(base.FeatureBase): diff --git a/functest/opnfv_tests/vnf/rnc/parser.py b/functest/opnfv_tests/vnf/rnc/parser.py index 1cff7220..905d51e8 100644 --- a/functest/opnfv_tests/vnf/rnc/parser.py +++ b/functest/opnfv_tests/vnf/rnc/parser.py @@ -15,7 +15,7 @@ # limitations under the License. # -import functest.core.feature_base as base +import functest.core.feature as base class Parser(base.FeatureBase): diff --git a/functest/opnfv_tests/vnf/router/vyos_vrouter.py b/functest/opnfv_tests/vnf/router/vyos_vrouter.py index 6c50e837..110c09b8 100644 --- a/functest/opnfv_tests/vnf/router/vyos_vrouter.py +++ b/functest/opnfv_tests/vnf/router/vyos_vrouter.py @@ -6,7 +6,7 @@ # are made available under the terms of the Apache License, Version 2.0 # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 -import functest.core.feature_base as base +import functest.core.feature as base import json import os -- cgit 1.2.3-korg