diff options
Diffstat (limited to 'functest/opnfv_tests')
29 files changed, 129 insertions, 114 deletions
diff --git a/functest/opnfv_tests/features/barometer.py b/functest/opnfv_tests/features/barometer.py index 6011340f..6207f581 100644 --- a/functest/opnfv_tests/features/barometer.py +++ b/functest/opnfv_tests/features/barometer.py @@ -16,9 +16,9 @@ class BarometerCollectd(base.Feature): Class for executing barometercollectd testcase. ''' - def __init__(self): + def __init__(self, case_name='barometercollectd'): super(BarometerCollectd, self).__init__(project='barometer', - case='barometercollectd', + case_name=case_name, repo='dir_repo_barometer') def execute(self): diff --git a/functest/opnfv_tests/features/copper.py b/functest/opnfv_tests/features/copper.py index 689341ea..5b88a499 100644 --- a/functest/opnfv_tests/features/copper.py +++ b/functest/opnfv_tests/features/copper.py @@ -18,8 +18,8 @@ import functest.core.feature as base class Copper(base.Feature): - def __init__(self): + def __init__(self, case_name='copper-notification'): super(Copper, self).__init__(project='copper', - case='copper-notification', + 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 index d32bbfc9..fd181a04 100644 --- a/functest/opnfv_tests/features/doctor.py +++ b/functest/opnfv_tests/features/doctor.py @@ -17,8 +17,8 @@ import functest.core.feature as base class Doctor(base.Feature): - def __init__(self): + def __init__(self, case_name='doctor-notification'): super(Doctor, self).__init__(project='doctor', - case='doctor-notification', + 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 index e34429bc..1c620235 100644 --- a/functest/opnfv_tests/features/domino.py +++ b/functest/opnfv_tests/features/domino.py @@ -18,8 +18,8 @@ import functest.core.feature as base class Domino(base.Feature): - def __init__(self): + def __init__(self, case_name='domino-multinode'): super(Domino, self).__init__(project='domino', - case='domino-multinode', + 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 index 88f377c2..ada322c1 100644 --- a/functest/opnfv_tests/features/netready.py +++ b/functest/opnfv_tests/features/netready.py @@ -13,9 +13,9 @@ import functest.core.feature as base class GluonVping(base.Feature): - def __init__(self): + def __init__(self, case_name='gluon_vping'): super(GluonVping, self).__init__(project='netready', - case='gluon_vping', + 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' % diff --git a/functest/opnfv_tests/features/odl_sfc.py b/functest/opnfv_tests/features/odl_sfc.py index fff7f2b0..f96683e3 100644 --- a/functest/opnfv_tests/features/odl_sfc.py +++ b/functest/opnfv_tests/features/odl_sfc.py @@ -12,9 +12,9 @@ import functest.core.feature as base class OpenDaylightSFC(base.Feature): - def __init__(self): + def __init__(self, case_name='functest-odl-sfc'): super(OpenDaylightSFC, self).__init__(project='sfc', - case='functest-odl-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 index a7f4e628..e3dc7fdf 100644 --- a/functest/opnfv_tests/features/promise.py +++ b/functest/opnfv_tests/features/promise.py @@ -16,9 +16,9 @@ import functest.core.feature as base class Promise(base.Feature): - def __init__(self): + def __init__(self, case_name='promise'): super(Promise, self).__init__(project='promise', - case='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 index 10e3146c..5e9254a0 100644 --- a/functest/opnfv_tests/features/sdnvpn.py +++ b/functest/opnfv_tests/features/sdnvpn.py @@ -12,9 +12,9 @@ import functest.core.feature as base class SdnVpnTests(base.Feature): - def __init__(self): + def __init__(self, case_name='bgpvpn'): super(SdnVpnTests, self).__init__(project='sdnvpn', - case='bgpvpn', + 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 index 2374b39f..e7256380 100644 --- a/functest/opnfv_tests/features/security_scan.py +++ b/functest/opnfv_tests/features/security_scan.py @@ -13,9 +13,9 @@ from functest.utils.constants import CONST class SecurityScan(base.Feature): - def __init__(self): + def __init__(self, case_name='security_scan'): super(SecurityScan, self).__init__(project='securityscanning', - case='security_scan', + case_name=case_name, repo='dir_repo_securityscan') self.cmd = ('. {0}/stackrc && ' 'cd {1} && ' diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py index 8c6abc15..e7411c51 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): - super(RallyBase, self).__init__() + def __init__(self, case_name=''): + super(RallyBase, self).__init__(case_name) self.mode = '' self.summary = [] self.scenario_dir = '' @@ -536,9 +536,8 @@ class RallyBase(testcase.TestCase): class RallySanity(RallyBase): - def __init__(self): - super(RallySanity, self).__init__() - self.case_name = 'rally_sanity' + def __init__(self, case_name="rally_sanity"): + super(RallySanity, self).__init__(case_name) self.mode = 'sanity' self.test_name = 'all' self.smoke = True @@ -546,9 +545,8 @@ class RallySanity(RallyBase): class RallyFull(RallyBase): - def __init__(self): - super(RallyFull, self).__init__() - self.case_name = 'rally_full' + def __init__(self, case_name="rally_full"): + super(RallyFull, self).__init__(case_name) 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 37aa9e39..441abfee 100755 --- a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py +++ b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py @@ -25,9 +25,8 @@ logger = ft_logger.Logger("refstack_defcore").getLogger() class RefstackClient(testcase.TestCase): - def __init__(self): - super(RefstackClient, self).__init__() - self.case_name = "refstack_defcore" + def __init__(self, case_name="refstack_defcore"): + super(RefstackClient, self).__init__(case_name) self.FUNCTEST_TEST = CONST.dir_functest_test self.CONF_PATH = CONST.refstack_tempest_conf_path self.DEFCORE_LIST = CONST.refstack_defcore_list @@ -192,10 +191,9 @@ class RefstackClient(testcase.TestCase): return res -class RefstackClientParser(testcase.TestCase): +class RefstackClientParser(object): def __init__(self): - super(RefstackClientParser, self).__init__() self.FUNCTEST_TEST = CONST.dir_functest_test self.CONF_PATH = CONST.refstack_tempest_conf_path self.DEFCORE_LIST = CONST.refstack_defcore_list diff --git a/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py index 5624ed79..d01f0872 100755 --- a/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py +++ b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py @@ -5,9 +5,8 @@ # 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 sys +import os -from functest.core import testcase from functest.opnfv_tests.openstack.tempest import conf_utils from functest.utils import openstack_utils from functest.utils.constants import CONST @@ -25,6 +24,8 @@ class TempestConf(object): self.DEPLOYMENT_ID = conf_utils.get_verifier_deployment_id() self.DEPLOYMENT_DIR = conf_utils.get_verifier_deployment_dir( self.VERIFIER_ID, self.DEPLOYMENT_ID) + self.confpath = os.path.join(CONST.dir_functest_test, + CONST.refstack_tempest_conf_path) def generate_tempestconf(self): try: @@ -33,21 +34,19 @@ class TempestConf(object): use_custom_images=True, use_custom_flavors=True) conf_utils.configure_tempest_defcore( self.DEPLOYMENT_DIR, img_flavor_dict) - except KeyError as e: - logger.error("defcore prepare env error with: %s", e) + except Exception as e: + logger.error("error with generating refstack client " + "reference tempest conf file: %s", e) def main(self): try: self.generate_tempestconf() - res = testcase.TestCase.EX_OK + logger.info("a reference tempest conf file generated " + "at %s", self.confpath) except Exception as e: logger.error('Error with run: %s', e) - res = testcase.TestCase.EX_RUN_ERROR - return res if __name__ == '__main__': tempestconf = TempestConf() - result = tempestconf.main() - if result != testcase.TestCase.EX_OK: - sys.exit(result) + tempestconf.main() diff --git a/functest/opnfv_tests/openstack/snaps/api_check.py b/functest/opnfv_tests/openstack/snaps/api_check.py index ad77d9be..dea1ca75 100644 --- a/functest/opnfv_tests/openstack/snaps/api_check.py +++ b/functest/opnfv_tests/openstack/snaps/api_check.py @@ -20,11 +20,10 @@ class ApiCheck(SnapsTestRunner): that exercise many of the OpenStack APIs within Keystone, Glance, Neutron, and Nova """ - def __init__(self): - super(ApiCheck, self).__init__() + def __init__(self, case_name="api_check"): + super(ApiCheck, self).__init__(case_name) self.suite = unittest.TestSuite() - self.case_name = "api_check" test_suite_builder.add_openstack_api_tests( self.suite, diff --git a/functest/opnfv_tests/openstack/snaps/connection_check.py b/functest/opnfv_tests/openstack/snaps/connection_check.py index 0637bcfb..57b74d4c 100644 --- a/functest/opnfv_tests/openstack/snaps/connection_check.py +++ b/functest/opnfv_tests/openstack/snaps/connection_check.py @@ -20,11 +20,10 @@ class ConnectionCheck(SnapsTestRunner): that simply obtain the different OpenStack clients and may perform simple queries """ - def __init__(self): - super(ConnectionCheck, self).__init__() + def __init__(self, case_name="connection_check"): + super(ConnectionCheck, self).__init__(case_name) self.suite = unittest.TestSuite() - self.case_name = "connection_check" test_suite_builder.add_openstack_client_tests( self.suite, diff --git a/functest/opnfv_tests/openstack/snaps/health_check.py b/functest/opnfv_tests/openstack/snaps/health_check.py index 8fece746..6b3cfdd0 100644 --- a/functest/opnfv_tests/openstack/snaps/health_check.py +++ b/functest/opnfv_tests/openstack/snaps/health_check.py @@ -21,11 +21,10 @@ 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): - super(HealthCheck, self).__init__() + def __init__(self, case_name="snaps_health_check"): + super(HealthCheck, self).__init__(case_name) self.suite = unittest.TestSuite() - self.case_name = "snaps_health_check" image_custom_config = None if hasattr(CONST, 'snaps_health_check'): diff --git a/functest/opnfv_tests/openstack/snaps/smoke.py b/functest/opnfv_tests/openstack/snaps/smoke.py index 45fa6de8..63d5c122 100644 --- a/functest/opnfv_tests/openstack/snaps/smoke.py +++ b/functest/opnfv_tests/openstack/snaps/smoke.py @@ -21,11 +21,10 @@ 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, case_name="snaps_smoke"): + super(SnapsSmoke, self).__init__(case_name) 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 diff --git a/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py b/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py index 9d723905..044a0bb0 100644 --- a/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py +++ b/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py @@ -19,8 +19,8 @@ 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): - super(SnapsTestRunner, self).__init__() + def __init__(self, case_name=''): + super(SnapsTestRunner, self).__init__(case_name) self.ext_net_name = snaps_utils.get_ext_net_name() self.logger = ft_logger.Logger(self.project_name).getLogger() diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py index 0addbd17..c3184e35 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): - super(TempestCommon, self).__init__() + def __init__(self, case_name=''): + super(TempestCommon, self).__init__(case_name) self.MODE = "" self.OPTION = "" self.VERIFIER_ID = conf_utils.get_verifier_id() @@ -234,35 +234,31 @@ class TempestCommon(testcase.TestCase): class TempestSmokeSerial(TempestCommon): - def __init__(self): - TempestCommon.__init__(self) - self.case_name = "tempest_smoke_serial" + def __init__(self, case_name='tempest_smoke_serial'): + TempestCommon.__init__(self, case_name) self.MODE = "smoke" self.OPTION = "--concurrency 1" class TempestSmokeParallel(TempestCommon): - def __init__(self): - TempestCommon.__init__(self) - self.case_name = "tempest_smoke_parallel" + def __init__(self, case_name='tempest_smoke_parallel'): + TempestCommon.__init__(self, case_name) self.MODE = "smoke" self.OPTION = "" class TempestFullParallel(TempestCommon): - def __init__(self): - TempestCommon.__init__(self) - self.case_name = "tempest_full_parallel" + def __init__(self, case_name="tempest_full_parallel"): + TempestCommon.__init__(self, case_name) self.MODE = "full" class TempestMultisite(TempestCommon): - def __init__(self): - TempestCommon.__init__(self) - self.case_name = "multisite" + def __init__(self, case_name="multisite"): + TempestCommon.__init__(self, case_name) self.MODE = "feature_multisite" self.OPTION = "--concurrency 1" conf_utils.install_verifier_ext(CONST.dir_repo_kingbird) @@ -270,17 +266,15 @@ class TempestMultisite(TempestCommon): class TempestCustom(TempestCommon): - def __init__(self): - TempestCommon.__init__(self) - self.case_name = "tempest_custom" + def __init__(self, case_name="tempest_custom"): + TempestCommon.__init__(self, case_name) self.MODE = "custom" self.OPTION = "--concurrency 1" class TempestDefcore(TempestCommon): - def __init__(self): - TempestCommon.__init__(self) - self.case_name = "tempest_defcore" + def __init__(self, case_name="tempest_defcore"): + TempestCommon.__init__(self, case_name) 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 584ded38..64cb0004 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): - super(VPingBase, self).__init__() + def __init__(self, case_name=''): + super(VPingBase, self).__init__(case_name) self.logger = None self.functest_repo = CONST.dir_repo_functest self.repo = CONST.dir_vping diff --git a/functest/opnfv_tests/openstack/vping/vping_ssh.py b/functest/opnfv_tests/openstack/vping/vping_ssh.py index fc2f01c6..a68b0ff7 100755 --- a/functest/opnfv_tests/openstack/vping/vping_ssh.py +++ b/functest/opnfv_tests/openstack/vping/vping_ssh.py @@ -24,9 +24,8 @@ import functest.core.testcase as testcase class VPingSSH(vping_base.VPingBase): - def __init__(self): - super(VPingSSH, self).__init__() - self.case_name = 'vping_ssh' + def __init__(self, case_name='vping_ssh'): + super(VPingSSH, self).__init__(case_name) 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 fa91c12a..e9b86998 100755 --- a/functest/opnfv_tests/openstack/vping/vping_userdata.py +++ b/functest/opnfv_tests/openstack/vping/vping_userdata.py @@ -18,9 +18,8 @@ import vping_base class VPingUserdata(vping_base.VPingBase): - def __init__(self): - super(VPingUserdata, self).__init__() - self.case_name = 'vping_userdata' + def __init__(self, case_name='vping_userdata'): + super(VPingUserdata, self).__init__(case_name) 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 ccc1101a..c0e2a9ae 100755 --- a/functest/opnfv_tests/sdn/odl/odl.py +++ b/functest/opnfv_tests/sdn/odl/odl.py @@ -72,10 +72,6 @@ class ODLTests(testcase.TestCase): res_dir = '/home/opnfv/functest/results/odl/' logger = ft_logger.Logger("opendaylight").getLogger() - def __init__(self): - testcase.TestCase.__init__(self) - self.case_name = "odl" - @classmethod def set_robotframework_vars(cls, odlusername="admin", odlpassword="admin"): """Set credentials in csit/variables/Variables.py. diff --git a/functest/opnfv_tests/sdn/onos/onos.py b/functest/opnfv_tests/sdn/onos/onos.py index d482ae32..fe37669a 100644 --- a/functest/opnfv_tests/sdn/onos/onos.py +++ b/functest/opnfv_tests/sdn/onos/onos.py @@ -32,9 +32,6 @@ class OnosBase(testcase.TestCase): onos_sfc_path = os.path.join(CONST.dir_repo_functest, CONST.dir_onos_sfc) - def __init__(self): - super(OnosBase, self).__init__() - def run(self): self.start_time = time.time() try: @@ -52,9 +49,8 @@ class OnosBase(testcase.TestCase): class Onos(OnosBase): - def __init__(self): - super(Onos, self).__init__() - self.case_name = 'onos' + def __init__(self, case_name='onos'): + super(Onos, self).__init__(case_name) self.log_path = os.path.join(self.onos_repo_path, 'TestON/logs') def set_onos_ip(self): diff --git a/functest/opnfv_tests/vnf/aaa/aaa.py b/functest/opnfv_tests/vnf/aaa/aaa.py index bdedcf7c..f80e7bcc 100755 --- a/functest/opnfv_tests/vnf/aaa/aaa.py +++ b/functest/opnfv_tests/vnf/aaa/aaa.py @@ -21,7 +21,7 @@ class AaaVnf(vnf_base.VnfOnBoardingBase): logger = ft_logger.Logger("VNF AAA").getLogger() def __init__(self): - super(AaaVnf, self).__init__(case="aaa") + super(AaaVnf, self).__init__(case_name="aaa") def deploy_orchestrator(self): self.logger.info("No VNFM needed to deploy a free radius here") @@ -56,6 +56,7 @@ class AaaVnf(vnf_base.VnfOnBoardingBase): kwargs = {} return self.main(**kwargs) + if __name__ == '__main__': parser = argparse.ArgumentParser() args = vars(parser.parse_args()) diff --git a/functest/opnfv_tests/vnf/ims/clearwater_ims_base.py b/functest/opnfv_tests/vnf/ims/clearwater_ims_base.py index f21ce3f9..2fc5449c 100644 --- a/functest/opnfv_tests/vnf/ims/clearwater_ims_base.py +++ b/functest/opnfv_tests/vnf/ims/clearwater_ims_base.py @@ -46,8 +46,7 @@ class ClearwaterOnBoardingBase(vnf_base.VnfOnBoardingBase): rq = requests.post(account_url, data=params) output_dict['login'] = params if rq.status_code != 201 and rq.status_code != 409: - raise Exception("Unable to create an account for number" - " provision: %s" % rq.json()['reason']) + raise Exception("Unable to create an account for number provision") self.logger.info('Account is created on Ellis: %s', params) session_url = 'http://{0}/session'.format(ellis_ip) diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.py b/functest/opnfv_tests/vnf/ims/cloudify_ims.py index 404f208e..d739335d 100644 --- a/functest/opnfv_tests/vnf/ims/cloudify_ims.py +++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.py @@ -25,9 +25,9 @@ import functest.utils.openstack_utils as os_utils class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase): - def __init__(self, project='functest', case='cloudify_ims', + def __init__(self, project='functest', case_name='cloudify_ims', repo='', cmd=''): - super(CloudifyIms, self).__init__(project, case, repo, cmd) + super(CloudifyIms, self).__init__(project, case_name, repo, cmd) self.logger = ft_logger.Logger(__name__).getLogger() # Retrieve the configuration diff --git a/functest/opnfv_tests/vnf/ims/opera_ims.py b/functest/opnfv_tests/vnf/ims/opera_ims.py index d022b3c7..7ca96ae1 100644 --- a/functest/opnfv_tests/vnf/ims/opera_ims.py +++ b/functest/opnfv_tests/vnf/ims/opera_ims.py @@ -21,9 +21,9 @@ import functest.utils.functest_logger as ft_logger class OperaIms(clearwater_ims_base.ClearwaterOnBoardingBase): - def __init__(self, project='functest', case='opera_ims', + def __init__(self, project='functest', case_name='opera_ims', repo=CONST.dir_repo_opera, cmd=''): - super(OperaIms, self).__init__(project, case, repo, cmd) + super(OperaIms, self).__init__(project, case_name, repo, cmd) self.logger = ft_logger.Logger(__name__).getLogger() self.ellis_file = os.path.join(self.result_dir, 'ellis.info') self.live_test_file = os.path.join(self.result_dir, diff --git a/functest/opnfv_tests/vnf/ims/orchestra_ims.py b/functest/opnfv_tests/vnf/ims/orchestra_ims.py index 5c19be09..c95a17e2 100755 --- a/functest/opnfv_tests/vnf/ims/orchestra_ims.py +++ b/functest/opnfv_tests/vnf/ims/orchestra_ims.py @@ -78,9 +78,9 @@ def servertest(host, port): class ImsVnf(vnf_base.VnfOnBoardingBase): - def __init__(self, project='functest', case='orchestra_ims', + def __init__(self, project='functest', case_name='orchestra_ims', repo='', cmd=''): - super(ImsVnf, self).__init__(project, case, repo, cmd) + super(ImsVnf, self).__init__(project, case_name, repo, cmd) self.ob_password = "openbaton" self.ob_username = "admin" self.ob_https = False @@ -103,7 +103,7 @@ class ImsVnf(vnf_base.VnfOnBoardingBase): try: self.config = CONST.__getattribute__( 'vnf_{}_config'.format(self.case_name)) - except: + except BaseException: raise Exception("Orchestra VNF config file not found") config_file = self.case_dir + self.config self.imagename = get_config("openbaton.imagename", config_file) @@ -115,6 +115,8 @@ class ImsVnf(vnf_base.VnfOnBoardingBase): config_file) self.images = get_config("tenant_images", config_file) self.ims_conf = get_config("vIMS", config_file) + self.userdata_file = get_config("openbaton.userdata.file", + config_file) def deploy_orchestrator(self, **kwargs): self.logger.info("Additional pre-configuration steps") @@ -132,7 +134,7 @@ class ImsVnf(vnf_base.VnfOnBoardingBase): image_id = os_utils.get_image_id(glance_client, image_name) self.logger.info("image_id: %s" % image_id) - except: + except BaseException: self.logger.error("Unexpected error: %s" % sys.exc_info()[0]) if image_id == '': @@ -153,7 +155,8 @@ class ImsVnf(vnf_base.VnfOnBoardingBase): "192.168.100.0/24") # orchestrator VM flavor - self.logger.info("Check if Flavor is available, if not create one") + self.logger.info( + "Check if orchestra Flavor is available, if not create one") flavor_exist, flavor_id = os_utils.get_or_create_flavor( "orchestra", "4096", @@ -210,8 +213,13 @@ class ImsVnf(vnf_base.VnfOnBoardingBase): bootstrap = "sh ./bootstrap release -configFile=./config_file" userdata += bootstrap + "\n" userdata += "echo \"Setting 'nfvo.plugin.timeout' to '300000'\"\n" - userdata += ("echo \"nfvo.plugin.timeout=300000\" >> " + userdata += ("echo \"nfvo.plugin.timeout=600000\" >> " "/etc/openbaton/openbaton-nfvo.properties\n") + userdata += ( + "wget %s -O /etc/openbaton/openbaton-vnfm-generic-user-data.sh\n" % + self.userdata_file) + userdata += "sed -i '113i\ \ \ \ sleep 60' " \ + "/etc/openbaton/openbaton-vnfm-generic-user-data.sh\n" userdata += "echo \"Starting NFVO\"\n" userdata += "service openbaton-nfvo restart\n" userdata += "echo \"Starting Generic VNFM\"\n" @@ -283,7 +291,10 @@ class ImsVnf(vnf_base.VnfOnBoardingBase): self.ob_username = "admin" self.ob_https = False self.ob_port = "8080" - + self.logger.info("Waiting for all components up and running...") + time.sleep(60) + self.details["orchestrator"] = { + 'status': "PASS", 'result': "Deploy Open Baton NFVO: OK"} self.logger.info("Deploy Open Baton NFVO: OK") def deploy_vnf(self): @@ -296,6 +307,16 @@ class ImsVnf(vnf_base.VnfOnBoardingBase): username=self.ob_username, password=self.ob_password) + self.logger.info( + "Check if openims Flavor is available, if not create one") + flavor_exist, flavor_id = os_utils.get_or_create_flavor( + "m1.small", + "2048", + '20', + '1', + public=True) + self.logger.debug("Flavor id: %s" % flavor_id) + self.logger.info("Getting project 'default'...") project_agent = self.main_agent.get_agent("project", self.ob_projectid) for p in json.loads(project_agent.find()): @@ -311,9 +332,16 @@ class ImsVnf(vnf_base.VnfOnBoardingBase): creds = os_utils.get_credentials() self.logger.info("PoP creds: %s" % creds) - project_id = os_utils.get_tenant_id( - os_utils.get_keystone_client(), - creds.get("project_name")) + if os_utils.is_keystone_v3(): + self.logger.info( + "Using v3 API of OpenStack... -> Using OS_PROJECT_ID") + project_id = os_utils.get_tenant_id( + os_utils.get_keystone_client(), + creds.get("project_name")) + else: + self.logger.info( + "Using v2 API of OpenStack... -> Using OS_TENANT_NAME") + project_id = creds.get("tenant_name") self.logger.debug("project id: %s" % project_id) @@ -381,16 +409,17 @@ class ImsVnf(vnf_base.VnfOnBoardingBase): self.nsr = json.loads(nsr_agent.find(self.nsr.get('id'))) if self.nsr.get("status") == 'ACTIVE': - deploy_vnf = {'status': "PASS", 'result': self.nsr} + self.details["vnf"] = {'status': "PASS", 'result': self.nsr} self.logger.info("Deploy VNF: OK") else: - deploy_vnf = {'status': "FAIL", 'result': self.nsr} + self.details["vnf"] = {'status': "FAIL", 'result': self.nsr} + self.logger.error(self.nsr) self.step_failure("Deploy VNF: ERROR") self.ob_nsr_id = self.nsr.get("id") self.logger.info( "Sleep for 60s to ensure that all services are up and running...") time.sleep(60) - return deploy_vnf + return self.details.get("vnf") def test_vnf(self): # Adaptations probably needed @@ -427,9 +456,18 @@ class ImsVnf(vnf_base.VnfOnBoardingBase): "VNFC instance %s is not reachable " "at %s:%s" % (vnfci.get('hostname'), floatingIp.get('ip'), port)) + self.details["test_vnf"] = { + 'status': "FAIL", 'result': ( + "Port %s of server %s -> %s is " + "not reachable" % + (port, vnfci.get('hostname'), + floatingIp.get('ip')))} self.step_failure("Test VNF: ERROR") + self.details["test_vnf"] = { + 'status': "PASS", + 'result': "All tests have been executed successfully"} self.logger.info("Test VNF: OK") - return + return self.details.get('test_vnf') def clean(self): self.main_agent.get_agent( diff --git a/functest/opnfv_tests/vnf/ims/orchestra_ims.yaml b/functest/opnfv_tests/vnf/ims/orchestra_ims.yaml index 5923a775..5b25d3c9 100644 --- a/functest/opnfv_tests/vnf/ims/orchestra_ims.yaml +++ b/functest/opnfv_tests/vnf/ims/orchestra_ims.yaml @@ -4,6 +4,8 @@ tenant_images: openbaton: bootstrap_link: http://get.openbaton.org/bootstraps/bootstrap_3.2.0_opnfv/bootstrap bootstrap_config_link: http://get.openbaton.org/bootstraps/bootstrap_3.2.0_opnfv/bootstrap-config-file + userdata: + file: https://raw.githubusercontent.com/openbaton/generic-vnfm/3.2.0/src/main/resources/user-data.sh marketplace_link: http://marketplace.openbaton.org:8082/api/v1/nsds/fokus/OpenImsCore/3.2.0/json imagename: ubuntu_14.04 vIMS: |