diff options
Diffstat (limited to 'functest/opnfv_tests')
33 files changed, 187 insertions, 359 deletions
diff --git a/functest/opnfv_tests/features/barometer.py b/functest/opnfv_tests/features/barometer.py index 6207f581..8a409406 100644 --- a/functest/opnfv_tests/features/barometer.py +++ b/functest/opnfv_tests/features/barometer.py @@ -16,10 +16,5 @@ class BarometerCollectd(base.Feature): Class for executing barometercollectd testcase. ''' - def __init__(self, case_name='barometercollectd'): - super(BarometerCollectd, self).__init__(project='barometer', - case_name=case_name, - repo='dir_repo_barometer') - def execute(self): return collectd.main(self.logger) diff --git a/functest/opnfv_tests/features/copper.py b/functest/opnfv_tests/features/copper.py deleted file mode 100644 index 5b88a499..00000000 --- a/functest/opnfv_tests/features/copper.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/python -# -# Copyright 2016 AT&T Intellectual Property, Inc -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import functest.core.feature as base - - -class Copper(base.Feature): - def __init__(self, case_name='copper-notification'): - super(Copper, self).__init__(project='copper', - case_name=case_name, - repo='dir_repo_copper') - self.cmd = 'cd %s/tests && bash run.sh && cd -' % self.repo diff --git a/functest/opnfv_tests/features/doctor.py b/functest/opnfv_tests/features/doctor.py deleted file mode 100644 index fd181a04..00000000 --- a/functest/opnfv_tests/features/doctor.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/python -# -# Copyright (c) 2017 All rights reserved -# This program and the accompanying materials -# 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 -# -# 0.1: This script boots the VM1 and allocates IP address from Nova -# Later, the VM2 boots then execute cloud-init to ping VM1. -# After successful ping, both the VMs are deleted. -# 0.2: measure test duration and publish results under json format -# -# -import functest.core.feature as base - - -class Doctor(base.Feature): - def __init__(self, case_name='doctor-notification'): - super(Doctor, self).__init__(project='doctor', - case_name=case_name, - repo='dir_repo_doctor') - self.cmd = 'cd %s/tests && ./run.sh' % self.repo diff --git a/functest/opnfv_tests/features/domino.py b/functest/opnfv_tests/features/domino.py deleted file mode 100644 index 1c620235..00000000 --- a/functest/opnfv_tests/features/domino.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/python -# -# Copyright (c) 2015 All rights reserved -# This program and the accompanying materials -# 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 -# -# 0.1: This script boots the VM1 and allocates IP address from Nova -# Later, the VM2 boots then execute cloud-init to ping VM1. -# After successful ping, both the VMs are deleted. -# 0.2: measure test duration and publish results under json format -# 0.3: add report flag to push results when needed -# 0.4: refactoring to match Test abstraction class - -import functest.core.feature as base - - -class Domino(base.Feature): - def __init__(self, case_name='domino-multinode'): - super(Domino, self).__init__(project='domino', - case_name=case_name, - repo='dir_repo_domino') - self.cmd = 'cd %s && ./tests/run_multinode.sh' % self.repo diff --git a/functest/opnfv_tests/features/netready.py b/functest/opnfv_tests/features/netready.py deleted file mode 100644 index ada322c1..00000000 --- a/functest/opnfv_tests/features/netready.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/python -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# - -# -import functest.core.feature as base - - -class GluonVping(base.Feature): - - def __init__(self, case_name='gluon_vping'): - super(GluonVping, self).__init__(project='netready', - case_name=case_name, - repo='dir_repo_netready') - dir_netready_functest = '{}/test/functest'.format(self.repo) - self.cmd = ('cd %s && python ./gluon-test-suite.py' % - dir_netready_functest) diff --git a/functest/opnfv_tests/features/odl_sfc.py b/functest/opnfv_tests/features/odl_sfc.py deleted file mode 100644 index f96683e3..00000000 --- a/functest/opnfv_tests/features/odl_sfc.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/python -# -# Copyright (c) 2016 All rights reserved -# This program and the accompanying materials -# 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 as base - - -class OpenDaylightSFC(base.Feature): - - def __init__(self, case_name='functest-odl-sfc'): - super(OpenDaylightSFC, self).__init__(project='sfc', - case_name=case_name, - repo='dir_repo_sfc') - dir_sfc_functest = '{}/sfc/tests/functest'.format(self.repo) - self.cmd = 'cd %s && python ./run_tests.py' % dir_sfc_functest diff --git a/functest/opnfv_tests/features/promise.py b/functest/opnfv_tests/features/promise.py deleted file mode 100644 index e3dc7fdf..00000000 --- a/functest/opnfv_tests/features/promise.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/python -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import functest.core.feature as base - - -class Promise(base.Feature): - def __init__(self, case_name='promise'): - super(Promise, self).__init__(project='promise', - case_name=case_name, - repo='dir_repo_promise') - dir_promise_functest = '{}/promise/test/functest'.format(self.repo) - self.cmd = 'cd %s && python ./run_tests.py' % dir_promise_functest diff --git a/functest/opnfv_tests/features/sdnvpn.py b/functest/opnfv_tests/features/sdnvpn.py deleted file mode 100644 index 5e9254a0..00000000 --- a/functest/opnfv_tests/features/sdnvpn.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/python -# -# Copyright (c) 2016 All rights reserved -# This program and the accompanying materials -# 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 as base - - -class SdnVpnTests(base.Feature): - - def __init__(self, case_name='bgpvpn'): - super(SdnVpnTests, self).__init__(project='sdnvpn', - case_name=case_name, - repo='dir_repo_sdnvpn') - dir_sfc_functest = '{}/sdnvpn/test/functest'.format(self.repo) - self.cmd = 'cd %s && python ./run_tests.py' % dir_sfc_functest diff --git a/functest/opnfv_tests/features/security_scan.py b/functest/opnfv_tests/features/security_scan.py deleted file mode 100644 index e7256380..00000000 --- a/functest/opnfv_tests/features/security_scan.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/python -# -# Copyright (c) 2015 All rights reserved -# This program and the accompanying materials -# 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 as base -from functest.utils.constants import CONST - - -class SecurityScan(base.Feature): - def __init__(self, case_name='security_scan'): - super(SecurityScan, self).__init__(project='securityscanning', - case_name=case_name, - repo='dir_repo_securityscan') - self.cmd = ('. {0}/stackrc && ' - 'cd {1} && ' - 'python security_scan.py --config config.ini && ' - 'cd -'.format(CONST.dir_functest_conf, - self.repo)) diff --git a/functest/opnfv_tests/mano/orchestra.py b/functest/opnfv_tests/mano/orchestra.py index a9cf0ae6..dea26efc 100644 --- a/functest/opnfv_tests/mano/orchestra.py +++ b/functest/opnfv_tests/mano/orchestra.py @@ -16,9 +16,12 @@ import functest.core.feature as base class Orchestra(base.Feature): - def __init__(self): - super(Orchestra, self).__init__(project='orchestra', - case='orchestra', - repo='dir_repo_orchestra') + def __init__(self, **kwargs): + if "project_name" not in kwargs: + kwargs["project_name"] = "orchestra" + if "case_name" not in kwargs: + kwargs["case_name"] = "orchestra" + kwargs['repo'] = 'dir_repo_orchestra' + super(Orchestra, self).__init__(**kwargs) # TODO # self.cmd = "%s/tests/run.sh %s/tests" % (self.repo, self.repo) diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py index e7411c51..e07e2a8d 100644 --- a/functest/opnfv_tests/openstack/rally/rally.py +++ b/functest/opnfv_tests/openstack/rally/rally.py @@ -56,8 +56,8 @@ class RallyBase(testcase.TestCase): RALLY_PRIVATE_SUBNET_CIDR = CONST.rally_subnet_cidr RALLY_ROUTER_NAME = CONST.rally_router_name - def __init__(self, case_name=''): - super(RallyBase, self).__init__(case_name) + def __init__(self, **kwargs): + super(RallyBase, self).__init__(**kwargs) self.mode = '' self.summary = [] self.scenario_dir = '' @@ -500,12 +500,12 @@ class RallyBase(testcase.TestCase): 'nb tests': total_nb_tests, 'nb success': success_rate}}) - self.criteria = ft_utils.check_success_rate( + self.result = ft_utils.check_success_rate( self.case_name, success_rate) self.details = payload logger.info("Rally '%s' success_rate is %s%%, is marked as %s" - % (self.case_name, success_rate, self.criteria)) + % (self.case_name, success_rate, self.result)) def _clean_up(self): if self.volume_type: @@ -536,8 +536,10 @@ class RallyBase(testcase.TestCase): class RallySanity(RallyBase): - def __init__(self, case_name="rally_sanity"): - super(RallySanity, self).__init__(case_name) + def __init__(self, **kwargs): + if "case_name" not in kwargs: + kwargs["case_name"] = "rally_sanity" + super(RallySanity, self).__init__(**kwargs) self.mode = 'sanity' self.test_name = 'all' self.smoke = True @@ -545,8 +547,10 @@ class RallySanity(RallyBase): class RallyFull(RallyBase): - def __init__(self, case_name="rally_full"): - super(RallyFull, self).__init__(case_name) + def __init__(self, **kwargs): + if "case_name" not in kwargs: + kwargs["case_name"] = "rally_full" + super(RallyFull, self).__init__(**kwargs) self.mode = 'full' self.test_name = 'all' self.smoke = False diff --git a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py index 441abfee..2f2fc00f 100755 --- a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py +++ b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py @@ -25,8 +25,10 @@ logger = ft_logger.Logger("refstack_defcore").getLogger() class RefstackClient(testcase.TestCase): - def __init__(self, case_name="refstack_defcore"): - super(RefstackClient, self).__init__(case_name) + def __init__(self, **kwargs): + if "case_name" not in kwargs: + kwargs["case_name"] = "refstack_defcore" + super(RefstackClient, self).__init__(**kwargs) self.FUNCTEST_TEST = CONST.dir_functest_test self.CONF_PATH = CONST.refstack_tempest_conf_path self.DEFCORE_LIST = CONST.refstack_defcore_list @@ -131,10 +133,10 @@ class RefstackClient(testcase.TestCase): except Exception: success_rate = 0 - self.criteria = ft_utils.check_success_rate( + self.result = ft_utils.check_success_rate( self.case_name, success_rate) logger.info("Testcase %s success_rate is %s%%, is marked as %s" - % (self.case_name, success_rate, self.criteria)) + % (self.case_name, success_rate, self.result)) def run(self): '''used for functest command line, @@ -169,7 +171,7 @@ class RefstackClient(testcase.TestCase): '''used for manually running, python refstack_client.py -c <tempest_conf_path> --testlist <testlist_path> - can generate a reference tempest.conf by + can generate a reference refstack_tempest.conf by python tempest_conf.py ''' try: @@ -204,7 +206,7 @@ class RefstackClientParser(object): self.parser = argparse.ArgumentParser() self.parser.add_argument( '-c', '--config', - help='the file path of tempest.conf', + help='the file path of refstack_tempest.conf', default=self.confpath) self.parser.add_argument( '-t', '--testlist', diff --git a/functest/opnfv_tests/openstack/snaps/api_check.py b/functest/opnfv_tests/openstack/snaps/api_check.py index dea1ca75..50f67094 100644 --- a/functest/opnfv_tests/openstack/snaps/api_check.py +++ b/functest/opnfv_tests/openstack/snaps/api_check.py @@ -11,7 +11,6 @@ from snaps import test_suite_builder from functest.opnfv_tests.openstack.snaps.snaps_test_runner import \ SnapsTestRunner -from functest.utils.constants import CONST class ApiCheck(SnapsTestRunner): @@ -20,13 +19,15 @@ class ApiCheck(SnapsTestRunner): that exercise many of the OpenStack APIs within Keystone, Glance, Neutron, and Nova """ - def __init__(self, case_name="api_check"): - super(ApiCheck, self).__init__(case_name) + def __init__(self, **kwargs): + if "case_name" not in kwargs: + kwargs["case_name"] = "api_check" + super(ApiCheck, self).__init__(**kwargs) self.suite = unittest.TestSuite() test_suite_builder.add_openstack_api_tests( - self.suite, - CONST.openstack_creds, - self.ext_net_name, - use_keystone=CONST.snaps_use_keystone) + suite=self.suite, + os_creds=self.os_creds, + ext_net_name=self.ext_net_name, + use_keystone=self.use_keystone) diff --git a/functest/opnfv_tests/openstack/snaps/connection_check.py b/functest/opnfv_tests/openstack/snaps/connection_check.py index 57b74d4c..f2753aea 100644 --- a/functest/opnfv_tests/openstack/snaps/connection_check.py +++ b/functest/opnfv_tests/openstack/snaps/connection_check.py @@ -11,7 +11,6 @@ from snaps import test_suite_builder from functest.opnfv_tests.openstack.snaps.snaps_test_runner import \ SnapsTestRunner -from functest.utils.constants import CONST class ConnectionCheck(SnapsTestRunner): @@ -20,13 +19,15 @@ class ConnectionCheck(SnapsTestRunner): that simply obtain the different OpenStack clients and may perform simple queries """ - def __init__(self, case_name="connection_check"): - super(ConnectionCheck, self).__init__(case_name) + def __init__(self, **kwargs): + if "case_name" not in kwargs: + kwargs["case_name"] = "connection_check" + super(ConnectionCheck, self).__init__(**kwargs) self.suite = unittest.TestSuite() test_suite_builder.add_openstack_client_tests( - self.suite, - CONST.openstack_creds, - self.ext_net_name, - use_keystone=CONST.snaps_use_keystone) + suite=self.suite, + os_creds=self.os_creds, + ext_net_name=self.ext_net_name, + use_keystone=self.use_keystone) diff --git a/functest/opnfv_tests/openstack/snaps/health_check.py b/functest/opnfv_tests/openstack/snaps/health_check.py index 6b3cfdd0..c057eb2b 100644 --- a/functest/opnfv_tests/openstack/snaps/health_check.py +++ b/functest/opnfv_tests/openstack/snaps/health_check.py @@ -21,18 +21,20 @@ class HealthCheck(SnapsTestRunner): creates a VM with a single port with an IPv4 address that is assigned by DHCP. This test then validates the expected IP with the actual """ - def __init__(self, case_name="snaps_health_check"): - super(HealthCheck, self).__init__(case_name) + def __init__(self, **kwargs): + if "case_name" not in kwargs: + kwargs["case_name"] = "snaps_health_check" + super(HealthCheck, self).__init__(**kwargs) self.suite = unittest.TestSuite() image_custom_config = None if hasattr(CONST, 'snaps_health_check'): - image_custom_config = CONST.snaps_health_check - + image_custom_config = CONST.__getattribute__('snaps_health_check') self.suite.addTest( OSIntegrationTestCase.parameterize( - SimpleHealthCheck, CONST.openstack_creds, self.ext_net_name, - use_keystone=CONST.snaps_use_keystone, + SimpleHealthCheck, os_creds=self.os_creds, + ext_net_name=self.ext_net_name, + use_keystone=self.use_keystone, flavor_metadata=self.flavor_metadata, image_metadata=image_custom_config)) diff --git a/functest/opnfv_tests/openstack/snaps/smoke.py b/functest/opnfv_tests/openstack/snaps/smoke.py index 45fa6de8..2c6fc255 100644 --- a/functest/opnfv_tests/openstack/snaps/smoke.py +++ b/functest/opnfv_tests/openstack/snaps/smoke.py @@ -21,30 +21,31 @@ class SnapsSmoke(SnapsTestRunner): that exercise many of the OpenStack APIs within Keystone, Glance, Neutron, and Nova """ - def __init__(self): - super(SnapsSmoke, self).__init__() + def __init__(self, **kwargs): + if "case_name" not in kwargs: + kwargs["case_name"] = "snaps_smoke" + super(SnapsSmoke, self).__init__(**kwargs) self.suite = unittest.TestSuite() - self.case_name = "snaps_smoke" - use_fip = CONST.snaps_use_floating_ips # The snaps smoke test uses the same config as the # snaps_health_check suite, so reuse it here image_custom_config = None if hasattr(CONST, 'snaps_health_check'): - image_custom_config = CONST.snaps_health_check + image_custom_config = CONST.__getattribute__('snaps_health_check') # Tests requiring floating IPs leverage files contained within the # SNAPS repository and are found relative to that path - if use_fip: - snaps_dir = CONST.dir_repo_snaps + '/snaps' + if self.use_fip: + snaps_dir = os.path.join(CONST.__getattribute__('dir_repo_snaps'), + 'snaps') os.chdir(snaps_dir) test_suite_builder.add_openstack_integration_tests( - self.suite, - CONST.openstack_creds, - self.ext_net_name, - use_keystone=CONST.snaps_use_keystone, + suite=self.suite, + os_creds=self.os_creds, + ext_net_name=self.ext_net_name, + use_keystone=self.use_keystone, flavor_metadata=self.flavor_metadata, image_metadata=image_custom_config, - use_floating_ips=use_fip) + use_floating_ips=self.use_fip) diff --git a/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py b/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py index 044a0bb0..8a68cad9 100644 --- a/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py +++ b/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py @@ -5,12 +5,13 @@ # # http://www.apache.org/licenses/LICENSE-2.0 -from functest.utils import functest_logger as ft_logger from functest.core.pytest_suite_runner import PyTestSuiteRunner from functest.opnfv_tests.openstack.snaps import snaps_utils from functest.utils import functest_utils +from functest.utils.constants import CONST from snaps.openstack import create_flavor +from snaps.openstack.tests import openstack_tests class SnapsTestRunner(PyTestSuiteRunner): @@ -19,15 +20,20 @@ class SnapsTestRunner(PyTestSuiteRunner): creates a VM with a single port with an IPv4 address that is assigned by DHCP. This test then validates the expected IP with the actual """ - def __init__(self, case_name=''): - super(SnapsTestRunner, self).__init__(case_name) + def __init__(self, **kwargs): + super(SnapsTestRunner, self).__init__(**kwargs) - self.ext_net_name = snaps_utils.get_ext_net_name() - self.logger = ft_logger.Logger(self.project_name).getLogger() + self.os_creds = openstack_tests.get_credentials( + os_env_file=CONST.__getattribute__('openstack_creds'), + proxy_settings_str=None, ssh_proxy_cmd=None) + + self.ext_net_name = snaps_utils.get_ext_net_name(self.os_creds) + self.use_fip = CONST.__getattribute__('snaps_use_floating_ips') + self.use_keystone = CONST.__getattribute__('snaps_use_keystone') scenario = functest_utils.get_scenario() self.flavor_metadata = create_flavor.MEM_PAGE_SIZE_ANY if 'ovs' in scenario or 'fdio' in scenario: self.flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE - self.logger.info("Using flavor metatdata '%s'" % self.flavor_metadata) + self.logger.info("Using flavor metadata '%s'", self.flavor_metadata) diff --git a/functest/opnfv_tests/openstack/snaps/snaps_utils.py b/functest/opnfv_tests/openstack/snaps/snaps_utils.py index 4ea1a04a..327ba073 100644 --- a/functest/opnfv_tests/openstack/snaps/snaps_utils.py +++ b/functest/opnfv_tests/openstack/snaps/snaps_utils.py @@ -5,19 +5,15 @@ # # http://www.apache.org/licenses/LICENSE-2.0 -from snaps.openstack.tests import openstack_tests from snaps.openstack.utils import neutron_utils -from functest.utils.constants import CONST - -def get_ext_net_name(): +def get_ext_net_name(os_creds): """ Returns the first external network name + :param: os_creds: an instance of snaps OSCreds object :return: """ - os_env_file = CONST.openstack_creds - os_creds = openstack_tests.get_credentials(os_env_file=os_env_file) neutron = neutron_utils.neutron_client(os_creds) ext_nets = neutron_utils.get_external_networks(neutron) return ext_nets[0]['network']['name'] diff --git a/functest/opnfv_tests/openstack/tempest/custom_tests/blacklist.txt b/functest/opnfv_tests/openstack/tempest/custom_tests/blacklist.txt index 0da92cd8..026b24f4 100644 --- a/functest/opnfv_tests/openstack/tempest/custom_tests/blacklist.txt +++ b/functest/opnfv_tests/openstack/tempest/custom_tests/blacklist.txt @@ -52,7 +52,7 @@ tests: - tempest.scenario.test_server_basic_ops.TestServerBasicOps.test_server_basic_ops - +- # https://bugs.opendaylight.org/show_bug.cgi?id=5586 scenarios: - os-odl-bgpvpn-ha @@ -60,6 +60,5 @@ - os-odl_l2-bgpvpn-ha installers: - apex - - fuel tests: - tempest.api.compute.servers.test_server_actions.ServerActionsTestJSON.test_reboot_server_hard diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py index c3184e35..e6c6b44f 100644 --- a/functest/opnfv_tests/openstack/tempest/tempest.py +++ b/functest/opnfv_tests/openstack/tempest/tempest.py @@ -28,8 +28,8 @@ logger = ft_logger.Logger("Tempest").getLogger() class TempestCommon(testcase.TestCase): - def __init__(self, case_name=''): - super(TempestCommon, self).__init__(case_name) + def __init__(self, **kwargs): + super(TempestCommon, self).__init__(**kwargs) self.MODE = "" self.OPTION = "" self.VERIFIER_ID = conf_utils.get_verifier_id() @@ -200,19 +200,17 @@ class TempestCommon(testcase.TestCase): except Exception: success_rate = 0 - self.criteria = ft_utils.check_success_rate( + self.result = ft_utils.check_success_rate( self.case_name, success_rate) logger.info("Tempest %s success_rate is %s%%, is marked as %s" - % (self.case_name, success_rate, self.criteria)) + % (self.case_name, success_rate, self.result)) def run(self): self.start_time = time.time() - - if not os.path.exists(conf_utils.TEMPEST_RESULTS_DIR): - os.makedirs(conf_utils.TEMPEST_RESULTS_DIR) - try: + if not os.path.exists(conf_utils.TEMPEST_RESULTS_DIR): + os.makedirs(conf_utils.TEMPEST_RESULTS_DIR) image_and_flavor = conf_utils.create_tempest_resources() conf_utils.configure_tempest( self.DEPLOYMENT_DIR, @@ -234,31 +232,39 @@ class TempestCommon(testcase.TestCase): class TempestSmokeSerial(TempestCommon): - def __init__(self, case_name='tempest_smoke_serial'): - TempestCommon.__init__(self, case_name) + def __init__(self, **kwargs): + if "case_name" not in kwargs: + kwargs["case_name"] = 'tempest_smoke_serial' + TempestCommon.__init__(self, **kwargs) self.MODE = "smoke" self.OPTION = "--concurrency 1" class TempestSmokeParallel(TempestCommon): - def __init__(self, case_name='tempest_smoke_parallel'): - TempestCommon.__init__(self, case_name) + def __init__(self, **kwargs): + if "case_name" not in kwargs: + kwargs["case_name"] = 'tempest_smoke_parallel' + TempestCommon.__init__(self, **kwargs) self.MODE = "smoke" self.OPTION = "" class TempestFullParallel(TempestCommon): - def __init__(self, case_name="tempest_full_parallel"): - TempestCommon.__init__(self, case_name) + def __init__(self, **kwargs): + if "case_name" not in kwargs: + kwargs["case_name"] = 'tempest_full_parallel' + TempestCommon.__init__(self, **kwargs) self.MODE = "full" class TempestMultisite(TempestCommon): - def __init__(self, case_name="multisite"): - TempestCommon.__init__(self, case_name) + def __init__(self, **kwargs): + if "case_name" not in kwargs: + kwargs["case_name"] = 'multisite' + TempestCommon.__init__(self, **kwargs) self.MODE = "feature_multisite" self.OPTION = "--concurrency 1" conf_utils.install_verifier_ext(CONST.dir_repo_kingbird) @@ -266,15 +272,19 @@ class TempestMultisite(TempestCommon): class TempestCustom(TempestCommon): - def __init__(self, case_name="tempest_custom"): - TempestCommon.__init__(self, case_name) + def __init__(self, **kwargs): + if "case_name" not in kwargs: + kwargs["case_name"] = 'tempest_custom' + TempestCommon.__init__(self, **kwargs) self.MODE = "custom" self.OPTION = "--concurrency 1" class TempestDefcore(TempestCommon): - def __init__(self, case_name="tempest_defcore"): - TempestCommon.__init__(self, case_name) + def __init__(self, **kwargs): + if "case_name" not in kwargs: + kwargs["case_name"] = 'tempest_defcore' + TempestCommon.__init__(self, **kwargs) self.MODE = "defcore" self.OPTION = "--concurrency 1" diff --git a/functest/opnfv_tests/openstack/vping/vping_base.py b/functest/opnfv_tests/openstack/vping/vping_base.py index 64cb0004..8bf263eb 100644 --- a/functest/opnfv_tests/openstack/vping/vping_base.py +++ b/functest/opnfv_tests/openstack/vping/vping_base.py @@ -18,8 +18,8 @@ from functest.utils.constants import CONST class VPingBase(testcase.TestCase): - def __init__(self, case_name=''): - super(VPingBase, self).__init__(case_name) + def __init__(self, **kwargs): + super(VPingBase, self).__init__(**kwargs) self.logger = None self.functest_repo = CONST.dir_repo_functest self.repo = CONST.dir_vping @@ -273,7 +273,7 @@ class VPingBase(testcase.TestCase): self.details = {'timestart': start_time, 'duration': duration, 'status': test_status} - self.criteria = test_status + self.result = test_status @staticmethod def pMsg(msg): diff --git a/functest/opnfv_tests/openstack/vping/vping_ssh.py b/functest/opnfv_tests/openstack/vping/vping_ssh.py index a68b0ff7..c26c4e0c 100755 --- a/functest/opnfv_tests/openstack/vping/vping_ssh.py +++ b/functest/opnfv_tests/openstack/vping/vping_ssh.py @@ -24,8 +24,10 @@ import functest.core.testcase as testcase class VPingSSH(vping_base.VPingBase): - def __init__(self, case_name='vping_ssh'): - super(VPingSSH, self).__init__(case_name) + def __init__(self, **kwargs): + if "case_name" not in kwargs: + kwargs["case_name"] = "vping_ssh" + super(VPingSSH, self).__init__(**kwargs) self.logger = ft_logger.Logger(self.case_name).getLogger() def do_vping(self, vm, test_ip): diff --git a/functest/opnfv_tests/openstack/vping/vping_userdata.py b/functest/opnfv_tests/openstack/vping/vping_userdata.py index e9b86998..1b00ca23 100755 --- a/functest/opnfv_tests/openstack/vping/vping_userdata.py +++ b/functest/opnfv_tests/openstack/vping/vping_userdata.py @@ -18,8 +18,10 @@ import vping_base class VPingUserdata(vping_base.VPingBase): - def __init__(self, case_name='vping_userdata'): - super(VPingUserdata, self).__init__(case_name) + def __init__(self, **kwargs): + if "case_name" not in kwargs: + kwargs["case_name"] = "vping_userdata" + super(VPingUserdata, self).__init__(**kwargs) self.logger = ft_logger.Logger(self.case_name).getLogger() def boot_vm_preparation(self, config, vmname, test_ip): diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py index c0e2a9ae..6f4acf6d 100755 --- a/functest/opnfv_tests/sdn/odl/odl.py +++ b/functest/opnfv_tests/sdn/odl/odl.py @@ -100,7 +100,7 @@ class ODLTests(testcase.TestCase): result = robot.api.ExecutionResult(xml_file) visitor = ODLResultVisitor() result.visit(visitor) - self.criteria = result.suite.status + self.result = result.suite.status self.start_time = timestamp_to_secs(result.suite.starttime) self.stop_time = timestamp_to_secs(result.suite.endtime) self.details = {} @@ -112,6 +112,7 @@ class ODLTests(testcase.TestCase): It has been designed to be called in any context. It requires the following keyword arguments: + * odlusername, * odlpassword, * osauthurl, @@ -130,7 +131,7 @@ class ODLTests(testcase.TestCase): * delete temporary files. Args: - **kwargs: Arbitrary keyword arguments. + kwargs: Arbitrary keyword arguments. Returns: EX_OK if all suites ran well. @@ -197,7 +198,7 @@ class ODLTests(testcase.TestCase): required. Args: - **kwargs: Arbitrary keyword arguments. + kwargs: Arbitrary keyword arguments. Returns: EX_OK if all suites ran well. diff --git a/functest/opnfv_tests/sdn/onos/onos.py b/functest/opnfv_tests/sdn/onos/onos.py index fe37669a..4d489d67 100644 --- a/functest/opnfv_tests/sdn/onos/onos.py +++ b/functest/opnfv_tests/sdn/onos/onos.py @@ -21,16 +21,21 @@ import functest.utils.functest_utils as ft_utils import functest.utils.openstack_utils as openstack_utils -logger = ft_logger.Logger(__name__).getLogger() - - class OnosBase(testcase.TestCase): - onos_repo_path = CONST.dir_repo_onos - onos_sfc_image_name = CONST.onos_sfc_image_name - onos_sfc_image_path = os.path.join(CONST.dir_functest_data, - CONST.onos_sfc_image_file_name) - onos_sfc_path = os.path.join(CONST.dir_repo_functest, - CONST.dir_onos_sfc) + onos_repo_path = CONST.__getattribute__('dir_repo_onos') + onos_sfc_image_name = CONST.__getattribute__('onos_sfc_image_name') + onos_sfc_image_path = os.path.join( + CONST.__getattribute__('dir_functest_data'), + CONST.__getattribute__('onos_sfc_image_file_name')) + onos_sfc_path = os.path.join(CONST.__getattribute__('dir_repo_functest'), + CONST.__getattribute__('dir_onos_sfc')) + installer_type = CONST.__getattribute__('INSTALLER_TYPE') + logger = ft_logger.Logger(__name__).getLogger() + + def __init__(self, **kwargs): + if "case_name" not in kwargs: + kwargs["case_name"] = "onos_base" + super(OnosBase, self).__init__(**kwargs) def run(self): self.start_time = time.time() @@ -38,7 +43,7 @@ class OnosBase(testcase.TestCase): self._run() res = testcase.TestCase.EX_OK except Exception as e: - logger.error('Error with run: %s', e) + self.logger.error('Error with run: %s', e) res = testcase.TestCase.EX_RUN_ERROR self.stop_time = time.time() @@ -49,25 +54,27 @@ class OnosBase(testcase.TestCase): class Onos(OnosBase): - def __init__(self, case_name='onos'): - super(Onos, self).__init__(case_name) + def __init__(self, **kwargs): + if "case_name" not in kwargs: + kwargs["case_name"] = "onos" + super(Onos, self).__init__(**kwargs) self.log_path = os.path.join(self.onos_repo_path, 'TestON/logs') def set_onos_ip(self): - if (CONST.INSTALLER_TYPE and - CONST.INSTALLER_TYPE.lower() == 'joid'): + if (self.installer_type and + self.installer_type.lower() == 'joid'): sdn_controller_env = os.getenv('SDN_CONTROLLER') OC1 = re.search(r"\d+\.\d+\.\d+\.\d+", sdn_controller_env).group() else: neutron_url = openstack_utils.get_endpoint(service_type='network') OC1 = urlparse.urlparse(neutron_url).hostname os.environ['OC1'] = OC1 - logger.debug("ONOS IP is %s" % OC1) + self.logger.debug("ONOS IP is %s", OC1) def run_onos_script(self, testname): cli_dir = os.path.join(self.onos_repo_path, 'TestON/bin/cli.py') cmd = '{0} run {1}'.format(cli_dir, testname) - logger.debug("Run script: %s" % testname) + self.logger.debug("Run script: %s", testname) ft_utils.execute_command_raise( cmd, error_msg=('Error when running ONOS script: %s' @@ -82,8 +89,8 @@ class Onos(OnosBase): elif os.path.isfile(log): os.remove(log) except OSError as e: - logger.error('Error with deleting file %s: %s', - log, e.strerror) + self.logger.error('Error with deleting file %s: %s', + log, e.strerror) def get_result(self): cmd = 'grep -rnh Fail {0}'.format(self.log_path) @@ -93,9 +100,9 @@ class Onos(OnosBase): stderr=subprocess.STDOUT) for line in p.stdout: - logger.debug(line) + self.logger.debug(line) if re.search("\s+[1-9]+\s+", line): - logger.debug("Testcase Fails\n" + line) + self.logger.debug("Testcase Fails\n" + line) cmd = "grep -rnh 'Execution Time' {0}".format(self.log_path) result_buffer = os.popen(cmd).read() @@ -153,10 +160,10 @@ class Onos(OnosBase): if (result['FUNCvirNet']['result'] == "Success" and result['FUNCvirNetL3']['result'] == "Success"): status = "PASS" - except: - logger.error("Unable to set ONOS criteria") + except Exception: + self.logger.error("Unable to set ONOS result") - self.criteria = status + self.result = status self.details = result def _run(self): @@ -168,13 +175,14 @@ class Onos(OnosBase): class OnosSfc(OnosBase): - def __init__(self): - super(OnosSfc, self).__init__() - self.case_name = 'onos_sfc' + def __init__(self, **kwargs): + if "case_name" not in kwargs: + kwargs["case_name"] = "onos_sfc" + super(OnosSfc, self).__init__(**kwargs) - def get_ip(type): + def get_ip(self, type): url = openstack_utils.get_endpoint(service_type=type) - logger.debug('get_ip for %s: %s' % (type, url)) + self.logger.debug('get_ip for %s: %s', type, url) return urlparse.urlparse(url).hostname def update_sfc_onos_file(self, before, after): @@ -188,6 +196,7 @@ class OnosSfc(OnosBase): % (before, after))) def create_image(self): + self.logger.warn('inside create_image') glance_client = openstack_utils.get_glance_client() image_id = openstack_utils.create_glance_image( glance_client, @@ -196,19 +205,20 @@ class OnosSfc(OnosBase): if image_id is None: raise Exception('Failed to create image') - logger.debug("Image '%s' with ID=%s is created successfully." - % (self.onos_sfc_image_name, image_id)) + self.logger.debug("Image '%s' with ID=%s is created successfully.", + self.onos_sfc_image_name, image_id) def set_sfc_conf(self): self.update_sfc_onos_file("keystone_ip", self.get_ip("keystone")) self.update_sfc_onos_file("neutron_ip", self.get_ip("neutron")) self.update_sfc_onos_file("nova_ip", self.get_ip("nova")) self.update_sfc_onos_file("glance_ip", self.get_ip("glance")) - self.update_sfc_onos_file("console", CONST.OS_PASSWORD) + self.update_sfc_onos_file("console", + CONST.__getattribute__('OS_PASSWORD')) neutron_client = openstack_utils.get_neutron_client() ext_net = openstack_utils.get_external_net(neutron_client) self.update_sfc_onos_file("admin_floating_net", ext_net) - logger.debug("SFC configuration is modified") + self.logger.debug("SFC configuration is modified") def sfc_test(self): cmd = 'python {0}'.format(os.path.join(self.onos_sfc_path, 'sfc.py')) diff --git a/functest/opnfv_tests/vnf/aaa/aaa.py b/functest/opnfv_tests/vnf/aaa/aaa.py index f80e7bcc..9c94cfb1 100755 --- a/functest/opnfv_tests/vnf/aaa/aaa.py +++ b/functest/opnfv_tests/vnf/aaa/aaa.py @@ -20,8 +20,10 @@ class AaaVnf(vnf_base.VnfOnBoardingBase): logger = ft_logger.Logger("VNF AAA").getLogger() - def __init__(self): - super(AaaVnf, self).__init__(case_name="aaa") + def __init__(self, **kwargs): + if "case_name" not in kwargs: + kwargs["case_name"] = "aaa" + super(AaaVnf, self).__init__(**kwargs) def deploy_orchestrator(self): self.logger.info("No VNFM needed to deploy a free radius here") @@ -47,7 +49,7 @@ class AaaVnf(vnf_base.VnfOnBoardingBase): def main(self, **kwargs): self.logger.info("AAA VNF onboarding") self.execute() - if self.criteria is "PASS": + if self.result is "PASS": return self.EX_OK else: return self.EX_RUN_ERROR diff --git a/functest/opnfv_tests/vnf/ims/clearwater_ims_base.py b/functest/opnfv_tests/vnf/ims/clearwater_ims_base.py index 2fc5449c..494633f4 100644 --- a/functest/opnfv_tests/vnf/ims/clearwater_ims_base.py +++ b/functest/opnfv_tests/vnf/ims/clearwater_ims_base.py @@ -20,13 +20,12 @@ import functest.utils.functest_utils as ft_utils class ClearwaterOnBoardingBase(vnf_base.VnfOnBoardingBase): - def __init__(self, project='functest', case='', repo='', cmd=''): + def __init__(self, **kwargs): self.logger = ft_logger.Logger(__name__).getLogger() - super(ClearwaterOnBoardingBase, self).__init__( - project, case, repo, cmd) + super(ClearwaterOnBoardingBase, self).__init__(**kwargs) self.case_dir = os.path.join(CONST.dir_functest_test, 'vnf', 'ims') self.data_dir = CONST.dir_ims_data - self.result_dir = os.path.join(CONST.dir_results, case) + self.result_dir = os.path.join(CONST.dir_results, self.case_name) self.test_dir = CONST.dir_repo_vims_test if not os.path.exists(self.data_dir): diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.py b/functest/opnfv_tests/vnf/ims/cloudify_ims.py index d739335d..0e6d4797 100644 --- a/functest/opnfv_tests/vnf/ims/cloudify_ims.py +++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.py @@ -25,9 +25,10 @@ import functest.utils.openstack_utils as os_utils class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase): - def __init__(self, project='functest', case_name='cloudify_ims', - repo='', cmd=''): - super(CloudifyIms, self).__init__(project, case_name, repo, cmd) + def __init__(self, **kwargs): + if "case_name" not in kwargs: + kwargs["case_name"] = "cloudify_ims" + super(CloudifyIms, self).__init__(**kwargs) self.logger = ft_logger.Logger(__name__).getLogger() # Retrieve the configuration @@ -276,7 +277,7 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase): self.logger.info("Cloudify IMS VNF onboarding test starting") self.execute() self.logger.info("Cloudify IMS VNF onboarding test executed") - if self.criteria is "PASS": + if self.result is "PASS": return self.EX_OK else: return self.EX_RUN_ERROR diff --git a/functest/opnfv_tests/vnf/ims/opera_ims.py b/functest/opnfv_tests/vnf/ims/opera_ims.py index 7ca96ae1..a46f9d71 100644 --- a/functest/opnfv_tests/vnf/ims/opera_ims.py +++ b/functest/opnfv_tests/vnf/ims/opera_ims.py @@ -119,7 +119,7 @@ class OperaIms(clearwater_ims_base.ClearwaterOnBoardingBase): self.logger.info("Start to run Opera vIMS VNF onboarding test") self.execute() self.logger.info("Opera vIMS VNF onboarding test finished") - if self.criteria is "PASS": + if self.result is "PASS": return self.EX_OK else: return self.EX_RUN_ERROR diff --git a/functest/opnfv_tests/vnf/ims/orchestra_ims.py b/functest/opnfv_tests/vnf/ims/orchestra_ims.py index c95a17e2..351c5fbe 100755 --- a/functest/opnfv_tests/vnf/ims/orchestra_ims.py +++ b/functest/opnfv_tests/vnf/ims/orchestra_ims.py @@ -484,7 +484,7 @@ class ImsVnf(vnf_base.VnfOnBoardingBase): self.logger.info("Orchestra IMS VNF onboarding test starting") self.execute() self.logger.info("Orchestra IMS VNF onboarding test executed") - if self.criteria is "PASS": + if self.result is "PASS": return self.EX_OK else: return self.EX_RUN_ERROR diff --git a/functest/opnfv_tests/vnf/rnc/__init__.py b/functest/opnfv_tests/vnf/rnc/__init__.py deleted file mode 100644 index e69de29b..00000000 --- a/functest/opnfv_tests/vnf/rnc/__init__.py +++ /dev/null diff --git a/functest/opnfv_tests/vnf/rnc/parser.py b/functest/opnfv_tests/vnf/rnc/parser.py deleted file mode 100644 index 133145d7..00000000 --- a/functest/opnfv_tests/vnf/rnc/parser.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/python -# -# Copyright 2016 ZTE Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import functest.core.feature as base - - -class Parser(base.Feature): - def __init__(self): - super(Parser, self).__init__(project='parser', - case='parser-basics', - repo='dir_repo_parser') - self.cmd = 'cd %s/tests && ./functest_run.sh' % self.repo diff --git a/functest/opnfv_tests/vnf/router/vyos_vrouter.py b/functest/opnfv_tests/vnf/router/vyos_vrouter.py index e188c3fb..5654278d 100644 --- a/functest/opnfv_tests/vnf/router/vyos_vrouter.py +++ b/functest/opnfv_tests/vnf/router/vyos_vrouter.py @@ -14,10 +14,11 @@ RESULT_DETAILS_FILE = "test_result.json" class VrouterVnf(base.Feature): - def __init__(self): - super(VrouterVnf, self).__init__(project='functest', - case='vyos_vrouter', - repo='dir_repo_vrouter') + def __init__(self, **kwargs): + kwargs["repo"] = 'dir_repo_vrouter' + if "case_name" not in kwargs: + kwargs["case_name"] = "vyos_vrouter" + super(VrouterVnf, self).__init__(**kwargs) self.cmd = 'cd %s && ./run.sh' % self.repo def set_result_details(self): @@ -28,6 +29,6 @@ class VrouterVnf(base.Feature): f.close() def log_results(self): - if self.criteria == 'PASS': + if self.result == 'PASS': self.set_result_details() super(VrouterVnf, self).log_results() |