aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests
diff options
context:
space:
mode:
Diffstat (limited to 'functest/opnfv_tests')
-rw-r--r--functest/opnfv_tests/features/__init__.py0
-rw-r--r--functest/opnfv_tests/features/barometer.py24
-rw-r--r--functest/opnfv_tests/openstack/rally/rally.py15
-rwxr-xr-xfunctest/opnfv_tests/openstack/refstack_client/refstack_client.py24
-rwxr-xr-xfunctest/opnfv_tests/openstack/refstack_client/tempest_conf.py8
-rw-r--r--functest/opnfv_tests/openstack/tempest/conf_utils.py27
-rw-r--r--functest/opnfv_tests/openstack/vping/vping_base.py6
-rwxr-xr-xfunctest/opnfv_tests/openstack/vping/vping_ssh.py6
-rwxr-xr-xfunctest/opnfv_tests/openstack/vping/vping_userdata.py2
-rwxr-xr-xfunctest/opnfv_tests/sdn/odl/odl.py8
-rw-r--r--functest/opnfv_tests/sdn/onos/onos.py5
-rw-r--r--functest/opnfv_tests/sdn/onos/teston/adapters/foundation.py3
-rwxr-xr-xfunctest/opnfv_tests/vnf/aaa/aaa.py53
-rw-r--r--functest/opnfv_tests/vnf/ims/clearwater_ims_base.py17
-rw-r--r--functest/opnfv_tests/vnf/ims/cloudify_ims.py116
-rw-r--r--functest/opnfv_tests/vnf/ims/opera_ims.py8
-rwxr-xr-xfunctest/opnfv_tests/vnf/ims/orchestra_ims.py188
17 files changed, 211 insertions, 299 deletions
diff --git a/functest/opnfv_tests/features/__init__.py b/functest/opnfv_tests/features/__init__.py
deleted file mode 100644
index e69de29b..00000000
--- a/functest/opnfv_tests/features/__init__.py
+++ /dev/null
diff --git a/functest/opnfv_tests/features/barometer.py b/functest/opnfv_tests/features/barometer.py
deleted file mode 100644
index e210f333..00000000
--- a/functest/opnfv_tests/features/barometer.py
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/env 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 logging
-
-from baro_tests import collectd
-
-import functest.core.feature as base
-
-
-class BarometerCollectd(base.Feature):
- '''
- Class for executing barometercollectd testcase.
- '''
-
- __logger = logging.getLogger(__name__)
-
- def execute(self):
- return collectd.main(self.__logger)
diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py
index 2ae6817d..8970a5c0 100644
--- a/functest/opnfv_tests/openstack/rally/rally.py
+++ b/functest/opnfv_tests/openstack/rally/rally.py
@@ -13,6 +13,7 @@ from __future__ import division
import json
import logging
import os
+import pkg_resources
import re
import subprocess
import time
@@ -38,12 +39,14 @@ class RallyBase(testcase.OSGCTestCase):
GLANCE_IMAGE_FORMAT = CONST.__getattribute__('openstack_image_disk_format')
FLAVOR_NAME = "m1.tiny"
- RALLY_DIR = os.path.join(
- CONST.__getattribute__('dir_repo_functest'),
- CONST.__getattribute__('dir_rally'))
- RALLY_SCENARIO_DIR = os.path.join(RALLY_DIR, "scenario")
- TEMPLATE_DIR = os.path.join(RALLY_SCENARIO_DIR, "templates")
- SUPPORT_DIR = os.path.join(RALLY_SCENARIO_DIR, "support")
+ RALLY_DIR = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/openstack/rally')
+ RALLY_SCENARIO_DIR = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/openstack/rally/scenario')
+ TEMPLATE_DIR = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/openstack/rally/scenario/templates')
+ SUPPORT_DIR = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/openstack/rally/scenario/support')
USERS_AMOUNT = 2
TENANTS_AMOUNT = 3
ITERATIONS_AMOUNT = 10
diff --git a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
index b2a21533..30d1cf08 100755
--- a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
+++ b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
@@ -12,6 +12,7 @@ from __future__ import division
import argparse
import logging
import os
+import pkg_resources
import re
import sys
import subprocess
@@ -33,13 +34,16 @@ class RefstackClient(testcase.OSGCTestCase):
if "case_name" not in kwargs:
kwargs["case_name"] = "refstack_defcore"
super(RefstackClient, self).__init__(**kwargs)
- self.FUNCTEST_TEST = CONST.__getattribute__('dir_functest_test')
- self.CONF_PATH = CONST.__getattribute__('refstack_tempest_conf_path')
- self.DEFCORE_LIST = CONST.__getattribute__('refstack_defcore_list')
+ self.CONF_PATH = pkg_resources.resource_filename(
+ 'functest',
+ 'opnfv_tests/openstack/refstack_client/refstack_tempest.conf')
+ self.FUNCTEST_TEST = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests')
+ self.DEFCORE_LIST = 'openstack/refstack_client/defcore.txt'
self.confpath = os.path.join(self.FUNCTEST_TEST,
self.CONF_PATH)
- self.defcorelist = os.path.join(self.FUNCTEST_TEST,
- self.DEFCORE_LIST)
+ self.defcorelist = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/openstack/refstack_client/defcore.txt')
def source_venv(self):
@@ -202,9 +206,13 @@ class RefstackClient(testcase.OSGCTestCase):
class RefstackClientParser(object):
def __init__(self):
- self.FUNCTEST_TEST = CONST.__getattribute__('dir_functest_test')
- self.CONF_PATH = CONST.__getattribute__('refstack_tempest_conf_path')
- self.DEFCORE_LIST = CONST.__getattribute__('refstack_defcore_list')
+ self.FUNCTEST_TEST = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests')
+ self.CONF_PATH = pkg_resources.resource_filename(
+ 'functest',
+ 'opnfv_tests/openstack/refstack_client/refstack_tempest.conf')
+ self.DEFCORE_LIST = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/openstack/refstack_client/defcore.txt')
self.confpath = os.path.join(self.FUNCTEST_TEST,
self.CONF_PATH)
self.defcorelist = os.path.join(self.FUNCTEST_TEST,
diff --git a/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
index fbaad589..5d429e7c 100755
--- a/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
+++ b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
@@ -6,7 +6,7 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
import logging
-import os
+import pkg_resources
from functest.opnfv_tests.openstack.tempest import conf_utils
from functest.utils import openstack_utils
@@ -24,9 +24,9 @@ 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.__getattribute__('dir_functest_test'),
- CONST.__getattribute__('refstack_tempest_conf_path'))
+ self.confpath = pkg_resources.resource_filename(
+ 'functest',
+ 'opnfv_tests/openstack/refstack_client/refstack_tempest.conf')
def generate_tempestconf(self):
try:
diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py
index 15365ccf..fa8f00fc 100644
--- a/functest/opnfv_tests/openstack/tempest/conf_utils.py
+++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py
@@ -10,6 +10,7 @@
import ConfigParser
import logging
import os
+import pkg_resources
import re
import shutil
import subprocess
@@ -21,19 +22,18 @@ import functest.utils.openstack_utils as os_utils
IMAGE_ID_ALT = None
FLAVOR_ID_ALT = None
-REPO_PATH = CONST.__getattribute__('dir_repo_functest')
GLANCE_IMAGE_PATH = os.path.join(
CONST.__getattribute__('dir_functest_images'),
CONST.__getattribute__('openstack_image_file_name'))
-TEMPEST_TEST_LIST_DIR = CONST.__getattribute__('dir_tempest_cases')
TEMPEST_RESULTS_DIR = os.path.join(CONST.__getattribute__('dir_results'),
'tempest')
-TEMPEST_CUSTOM = os.path.join(REPO_PATH, TEMPEST_TEST_LIST_DIR,
- 'test_list.txt')
-TEMPEST_BLACKLIST = os.path.join(REPO_PATH, TEMPEST_TEST_LIST_DIR,
- 'blacklist.txt')
-TEMPEST_DEFCORE = os.path.join(REPO_PATH, TEMPEST_TEST_LIST_DIR,
- 'defcore_req.txt')
+TEMPEST_CUSTOM = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/openstack/tempest/custom_tests/test_list.txt')
+TEMPEST_BLACKLIST = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/openstack/tempest/custom_tests/blacklist.txt')
+TEMPEST_DEFCORE = pkg_resources.resource_filename(
+ 'functest',
+ 'opnfv_tests/openstack/tempest/custom_tests/defcore_req.txt')
TEMPEST_RAW_LIST = os.path.join(TEMPEST_RESULTS_DIR, 'test_raw_list.txt')
TEMPEST_LIST = os.path.join(TEMPEST_RESULTS_DIR, 'test_list.txt')
REFSTACK_RESULTS_DIR = os.path.join(CONST.__getattribute__('dir_results'),
@@ -253,9 +253,9 @@ def configure_tempest_defcore(deployment_dir, img_flavor_dict):
with open(conf_file, 'wb') as config_file:
config.write(config_file)
- confpath = os.path.join(
- CONST.__getattribute__('dir_functest_test'),
- CONST.__getattribute__('refstack_tempest_conf_path'))
+ confpath = pkg_resources.resource_filename(
+ 'functest',
+ 'opnfv_tests/openstack/refstack_client/refstack_tempest.conf')
shutil.copyfile(conf_file, confpath)
@@ -290,6 +290,11 @@ def configure_tempest_update_params(tempest_conf_file,
config.set('identity', 'password',
CONST.__getattribute__('tempest_identity_user_password'))
config.set('identity', 'region', 'RegionOne')
+ if os_utils.is_keystone_v3():
+ auth_version = 'v3'
+ else:
+ auth_version = 'v2'
+ config.set('identity', 'auth_version', auth_version)
config.set(
'validation', 'ssh_timeout',
CONST.__getattribute__('tempest_validation_ssh_timeout'))
diff --git a/functest/opnfv_tests/openstack/vping/vping_base.py b/functest/opnfv_tests/openstack/vping/vping_base.py
index 856d5f22..71460676 100644
--- a/functest/opnfv_tests/openstack/vping/vping_base.py
+++ b/functest/opnfv_tests/openstack/vping/vping_base.py
@@ -10,6 +10,7 @@
from datetime import datetime
import logging
import os
+import pkg_resources
import time
import uuid
@@ -37,7 +38,8 @@ class VPingBase(testcase.OSGCTestCase):
self.logger = logging.getLogger(self.__class__.__name__)
- self.functest_repo = CONST.__getattribute__('dir_repo_functest')
+ self.functest_repo = pkg_resources.resource_filename(
+ 'functest', '..')
self.guid = ''
if CONST.__getattribute__('vping_unique_names'):
self.guid = '-' + str(uuid.uuid4())
@@ -45,8 +47,6 @@ class VPingBase(testcase.OSGCTestCase):
self.os_creds = openstack_tests.get_credentials(
os_env_file=CONST.__getattribute__('openstack_creds'))
- self.repo = CONST.__getattribute__('dir_vping')
-
self.creators = list()
self.image_creator = None
self.network_creator = None
diff --git a/functest/opnfv_tests/openstack/vping/vping_ssh.py b/functest/opnfv_tests/openstack/vping/vping_ssh.py
index 6ac0d676..1f663307 100755
--- a/functest/opnfv_tests/openstack/vping/vping_ssh.py
+++ b/functest/opnfv_tests/openstack/vping/vping_ssh.py
@@ -8,7 +8,7 @@
# http://www.apache.org/licenses/LICENSE-2.0
import argparse
-import os
+import pkg_resources
from scp import SCPClient
import sys
import time
@@ -156,8 +156,8 @@ class VPingSSH(vping_base.VPingBase):
"""
self.logger.info("Trying to transfer ping.sh")
scp = SCPClient(ssh.get_transport())
- local_path = self.functest_repo + "/" + self.repo
- ping_script = os.path.join(local_path, "ping.sh")
+ ping_script = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/openstack/vping/ping.sh')
try:
scp.put(ping_script, "~/")
except:
diff --git a/functest/opnfv_tests/openstack/vping/vping_userdata.py b/functest/opnfv_tests/openstack/vping/vping_userdata.py
index b69b3955..718f47f0 100755
--- a/functest/opnfv_tests/openstack/vping/vping_userdata.py
+++ b/functest/opnfv_tests/openstack/vping/vping_userdata.py
@@ -97,7 +97,7 @@ class VPingUserdata(vping_base.VPingBase):
while True:
time.sleep(1)
- p_console = vm_creator.get_vm_inst().get_console_output()
+ p_console = vm_creator.get_os_vm_server_obj().get_console_output()
if "vPing OK" in p_console:
self.logger.info("vPing detected!")
exit_code = TestCase.EX_OK
diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py
index b2b0b77c..fb5dcbc6 100755
--- a/functest/opnfv_tests/sdn/odl/odl.py
+++ b/functest/opnfv_tests/sdn/odl/odl.py
@@ -34,6 +34,7 @@ from six import StringIO
from six.moves import urllib
from functest.core import testcase
+from functest.utils import constants
import functest.utils.openstack_utils as op_utils
__author__ = "Cedric Ollivier <cedric.ollivier@orange.com>"
@@ -65,14 +66,15 @@ class ODLResultVisitor(robot.api.ResultVisitor):
class ODLTests(testcase.TestCase):
"""ODL test runner."""
- repos = "/home/opnfv/repos/"
- odl_test_repo = os.path.join(repos, "odl_test")
+ odl_test_repo = os.path.join(
+ constants.CONST.__getattribute__('dir_repos'), 'odl_test')
neutron_suite_dir = os.path.join(odl_test_repo,
"csit/suites/openstack/neutron")
basic_suite_dir = os.path.join(odl_test_repo,
"csit/suites/integration/basic")
default_suites = [basic_suite_dir, neutron_suite_dir]
- res_dir = '/home/opnfv/functest/results/odl/'
+ res_dir = os.path.join(
+ constants.CONST.__getattribute__('dir_results'), 'odl')
__logger = logging.getLogger(__name__)
@classmethod
diff --git a/functest/opnfv_tests/sdn/onos/onos.py b/functest/opnfv_tests/sdn/onos/onos.py
index adcb4166..08ba4da3 100644
--- a/functest/opnfv_tests/sdn/onos/onos.py
+++ b/functest/opnfv_tests/sdn/onos/onos.py
@@ -9,6 +9,7 @@
import logging
import os
+import pkg_resources
import re
import subprocess
import shutil
@@ -27,8 +28,8 @@ class OnosBase(testcase.TestCase):
onos_sfc_image_path = os.path.join(
CONST.__getattribute__('dir_functest_images'),
CONST.__getattribute__('onos_sfc_image_file_name'))
- onos_sfc_path = os.path.join(CONST.__getattribute__('dir_repo_functest'),
- CONST.__getattribute__('dir_onos_sfc'))
+ onos_sfc_path = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/sdn/onos/sfc')
installer_type = CONST.__getattribute__('INSTALLER_TYPE')
logger = logging.getLogger(__name__)
diff --git a/functest/opnfv_tests/sdn/onos/teston/adapters/foundation.py b/functest/opnfv_tests/sdn/onos/teston/adapters/foundation.py
index f9eee7af..aed98ee4 100644
--- a/functest/opnfv_tests/sdn/onos/teston/adapters/foundation.py
+++ b/functest/opnfv_tests/sdn/onos/teston/adapters/foundation.py
@@ -18,7 +18,6 @@ import re
import time
from functest.utils.constants import CONST
-import functest.utils.functest_utils as ft_utils
class Foundation(object):
@@ -55,7 +54,7 @@ class Foundation(object):
"""
Get Default Parameters value
"""
- self.Result_DB = ft_utils.get_db_url()
+ self.Result_DB = CONST.__getattribute__("results_test_db_url")
self.masterusername = CONST.__getattribute__('ONOS_onosbench_username')
self.masterpassword = CONST.__getattribute__('ONOS_onosbench_password')
self.agentusername = CONST.__getattribute__('ONOS_onoscli_username')
diff --git a/functest/opnfv_tests/vnf/aaa/aaa.py b/functest/opnfv_tests/vnf/aaa/aaa.py
index 0030256c..71e3c972 100755
--- a/functest/opnfv_tests/vnf/aaa/aaa.py
+++ b/functest/opnfv_tests/vnf/aaa/aaa.py
@@ -8,15 +8,12 @@
# http://www.apache.org/licenses/LICENSE-2.0
import logging
-import sys
-import argparse
-
-import functest.core.testcase as testcase
import functest.core.vnf as vnf
class AaaVnf(vnf.VnfOnBoarding):
+ """AAA VNF sample"""
logger = logging.getLogger(__name__)
@@ -27,48 +24,18 @@ class AaaVnf(vnf.VnfOnBoarding):
def deploy_orchestrator(self):
self.logger.info("No VNFM needed to deploy a free radius here")
- return None
+ return True
-# TODO see how to use build in exception form releng module
def deploy_vnf(self):
self.logger.info("Freeradius VNF deployment")
- # TODO apt-get update + config tuning
- deploy_vnf = {}
- deploy_vnf['status'] = "PASS"
- deploy_vnf['result'] = {}
- return deploy_vnf
+ # find a way to deploy freeradius and tester (heat,manual, ..)
+ deploy_vnf = {'status': 'PASS', 'version': 'xxxx'}
+ self.details['deploy_vnf'] = deploy_vnf
+ return True
def test_vnf(self):
self.logger.info("Run test towards freeradius")
- # TODO: once the freeradius is deployed..make some tests
- test_vnf = {}
- test_vnf['status'] = "PASS"
- test_vnf['result'] = {}
- return test_vnf
-
- def main(self, **kwargs):
- self.logger.info("AAA VNF onboarding")
- self.execute()
- if self.result is "PASS":
- return self.EX_OK
- else:
- return self.EX_RUN_ERROR
-
- def run(self):
- kwargs = {}
- return self.main(**kwargs)
-
-
-if __name__ == '__main__':
- logging.basicConfig()
- parser = argparse.ArgumentParser()
- args = vars(parser.parse_args())
- aaa_vnf = AaaVnf()
- try:
- result = aaa_vnf.main(**args)
- if result != testcase.TestCase.EX_OK:
- sys.exit(result)
- if args['pushtodb']:
- sys.exit(aaa_vnf.push_to_db())
- except Exception:
- sys.exit(testcase.TestCase.EX_RUN_ERROR)
+ # once the freeradius is deployed..make some tests
+ test_vnf = {'status': 'PASS', 'version': 'xxxx'}
+ self.details['test_vnf'] = test_vnf
+ return True
diff --git a/functest/opnfv_tests/vnf/ims/clearwater_ims_base.py b/functest/opnfv_tests/vnf/ims/clearwater_ims_base.py
index 42d31e3b..c1a35be3 100644
--- a/functest/opnfv_tests/vnf/ims/clearwater_ims_base.py
+++ b/functest/opnfv_tests/vnf/ims/clearwater_ims_base.py
@@ -9,6 +9,7 @@
import json
import logging
import os
+import pkg_resources
import shutil
import requests
@@ -17,16 +18,22 @@ import functest.core.vnf as vnf
from functest.utils.constants import CONST
import functest.utils.functest_utils as ft_utils
+__author__ = ("Valentin Boucher <valentin.boucher@orange.com>, "
+ "Helen Yao <helanyao@gmail.com>")
+
class ClearwaterOnBoardingBase(vnf.VnfOnBoarding):
+ """ vIMS clearwater base usable by several orchestrators"""
def __init__(self, **kwargs):
self.logger = logging.getLogger(__name__)
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, self.case_name)
- self.test_dir = CONST.dir_repo_vims_test
+ self.case_dir = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/vnf/ims')
+ self.data_dir = CONST.__getattribute__('dir_ims_data')
+ self.result_dir = os.path.join(CONST.__getattribute__('dir_results'),
+ self.case_name)
+ self.test_dir = CONST.__getattribute__('dir_repo_vims_test')
if not os.path.exists(self.data_dir):
os.makedirs(self.data_dir)
@@ -58,7 +65,7 @@ class ClearwaterOnBoardingBase(vnf.VnfOnBoarding):
if rq.status_code != 201:
raise Exception('Failed to get cookie for Ellis')
cookies = rq.cookies
- self.logger.info('Cookies: %s' % cookies)
+ self.logger.info('Cookies: %s', cookies)
number_url = 'http://{0}/accounts/{1}/numbers'.format(
ellis_ip,
diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.py b/functest/opnfv_tests/vnf/ims/cloudify_ims.py
index ba4c5790..89c84afd 100644
--- a/functest/opnfv_tests/vnf/ims/cloudify_ims.py
+++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.py
@@ -22,14 +22,21 @@ from functest.utils.constants import CONST
import functest.utils.functest_utils as ft_utils
import functest.utils.openstack_utils as os_utils
+__author__ = "Valentin Boucher <valentin.boucher@orange.com>"
+
class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
+ """Clearwater vIMS deployed with Cloudify Orchestrator Case"""
def __init__(self, **kwargs):
if "case_name" not in kwargs:
kwargs["case_name"] = "cloudify_ims"
super(CloudifyIms, self).__init__(**kwargs)
self.logger = logging.getLogger(__name__)
+ self.neutron_client = ''
+ self.glance_client = ''
+ self.keystone_client = ''
+ self.nova_client = ''
# Retrieve the configuration
try:
@@ -44,7 +51,7 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
blueprint=get_config("cloudify.blueprint", config_file),
inputs=get_config("cloudify.inputs", config_file)
)
- self.logger.debug("Orchestrator configuration: %s" % self.orchestrator)
+ self.logger.debug("Orchestrator configuration: %s", self.orchestrator)
self.vnf = dict(
blueprint=get_config("clearwater.blueprint", config_file),
deployment_name=get_config("clearwater.deployment_name",
@@ -52,12 +59,12 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
inputs=get_config("clearwater.inputs", config_file),
requirements=get_config("clearwater.requirements", config_file)
)
- self.logger.debug("VNF configuration: %s" % self.vnf)
+ self.logger.debug("VNF configuration: %s", self.vnf)
self.images = get_config("tenant_images", config_file)
- self.logger.info("Images needed for vIMS: %s" % self.images)
+ self.logger.info("Images needed for vIMS: %s", self.images)
- def deploy_orchestrator(self, **kwargs):
+ def deploy_orchestrator(self):
self.logger.info("Additional pre-configuration steps")
self.neutron_client = os_utils.get_neutron_client(self.admin_creds)
@@ -69,45 +76,45 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
self.logger.info("Upload some OS images if it doesn't exist")
temp_dir = os.path.join(self.data_dir, "tmp/")
for image_name, image_url in self.images.iteritems():
- self.logger.info("image: %s, url: %s" % (image_name, image_url))
+ self.logger.info("image: %s, url: %s", image_name, image_url)
try:
image_id = os_utils.get_image_id(self.glance_client,
image_name)
- self.logger.debug("image_id: %s" % image_id)
+ self.logger.debug("image_id: %s", image_id)
except Exception:
- self.logger.error("Unexpected error: %s" % sys.exc_info()[0])
+ self.logger.error("Unexpected error: %s", sys.exc_info()[0])
if image_id == '':
- self.logger.info("""%s image doesn't exist on glance repository. Try
- downloading this image and upload on glance !""" % image_name)
- image_id = download_and_add_image_on_glance(self.glance_client,
- image_name,
- image_url,
- temp_dir)
- if image_id == '':
- self.step_failure(
- "Failed to find or upload required OS "
- "image for this deployment")
+ self.logger.info("""%s image does not exist on glance repo.
+ Try downloading this image
+ and upload on glance !""",
+ image_name)
+ image_id = os_utils.download_and_add_image_on_glance(
+ self.glance_client,
+ image_name,
+ image_url,
+ temp_dir)
# Need to extend quota
self.logger.info("Update security group quota for this tenant")
tenant_id = os_utils.get_tenant_id(self.keystone_client,
self.tenant_name)
- self.logger.debug("Tenant id found %s" % tenant_id)
+ self.logger.debug("Tenant id found %s", tenant_id)
if not os_utils.update_sg_quota(self.neutron_client,
tenant_id, 50, 100):
- self.step_failure("Failed to update security group quota" +
+ self.logger.error("Failed to update security group quota"
" for tenant " + self.tenant_name)
+
self.logger.debug("group quota extended")
# start the deployment of cloudify
public_auth_url = os_utils.get_endpoint('identity')
- self.logger.debug("CFY inputs: %s" % self.orchestrator['inputs'])
+ self.logger.debug("CFY inputs: %s", self.orchestrator['inputs'])
cfy = Orchestrator(self.data_dir, self.orchestrator['inputs'])
self.orchestrator['object'] = cfy
self.logger.debug("Orchestrator object created")
- self.logger.debug("Tenant name: %s" % self.tenant_name)
+ self.logger.debug("Tenant name: %s", self.tenant_name)
cfy.set_credentials(username=self.tenant_name,
password=self.tenant_name,
@@ -117,7 +124,7 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
# orchestrator VM flavor
self.logger.info("Check Flavor is available, if not create one")
- self.logger.debug("Flavor details %s " %
+ self.logger.debug("Flavor details %s ",
self.orchestrator['requirements']['ram_min'])
flavor_exist, flavor_id = os_utils.get_or_create_flavor(
"m1.large",
@@ -125,13 +132,12 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
'50',
'2',
public=True)
- self.logger.debug("Flavor id: %s" % flavor_id)
+ self.logger.debug("Flavor id: %s", flavor_id)
if not flavor_id:
self.logger.info("Available flavors are: ")
self.logger.info(self.nova_client.flavor.list())
- self.step_failure("Failed to find required flavor"
- "for this deployment")
+
cfy.set_flavor_id(flavor_id)
self.logger.debug("Flavor OK")
@@ -141,23 +147,16 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
image_id = os_utils.get_image_id(
self.glance_client,
self.orchestrator['requirements']['os_image'])
- self.logger.debug("Orchestrator image id: %s" % image_id)
+ self.logger.debug("Orchestrator image id: %s", image_id)
if image_id == '':
self.logger.error("CFY image not found")
- self.step_failure("Failed to find required OS image"
- " for cloudify manager")
- else:
- self.step_failure("Failed to find required OS image"
- " for cloudify manager")
cfy.set_image_id(image_id)
self.logger.debug("Orchestrator image set")
self.logger.debug("Get External network")
ext_net = os_utils.get_external_net(self.neutron_client)
- self.logger.debug("External network: %s" % ext_net)
- if not ext_net:
- self.step_failure("Failed to get external network")
+ self.logger.debug("External network: %s", ext_net)
cfy.set_external_network_name(ext_net)
self.logger.debug("CFY External network set")
@@ -199,12 +198,10 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
'30',
'1',
public=True)
- self.logger.debug("Flavor id: %s" % flavor_id)
+ self.logger.debug("Flavor id: %s", flavor_id)
if not flavor_id:
self.logger.info("Available flavors are: ")
self.logger.info(self.nova_client.flavor.list())
- self.step_failure("Failed to find required flavor"
- " for this deployment")
cw.set_flavor_id(flavor_id)
@@ -212,19 +209,9 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
if 'os_image' in self.vnf['requirements'].keys():
image_id = os_utils.get_image_id(
self.glance_client, self.vnf['requirements']['os_image'])
- if image_id == '':
- self.step_failure("Failed to find required OS image"
- " for clearwater VMs")
- else:
- self.step_failure("Failed to find required OS image"
- " for clearwater VMs")
cw.set_image_id(image_id)
-
ext_net = os_utils.get_external_net(self.neutron_client)
- if not ext_net:
- self.step_failure("Failed to get external network")
-
cw.set_external_network_name(ext_net)
error = cw.deploy_vnf(self.vnf['blueprint'])
@@ -245,8 +232,8 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
mgr_ip = os.popen(cmd).read()
mgr_ip = mgr_ip.splitlines()[0]
except Exception:
- self.step_failure("Unable to retrieve the IP of the "
- "cloudify manager server !")
+ self.logger.exception("Unable to retrieve the IP of the "
+ "cloudify manager server !")
self.logger.info('Cloudify Manager: %s', mgr_ip)
api_url = 'http://{0}/api/v2/deployments/{1}/outputs'.format(
@@ -262,7 +249,7 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
if dns_ip != "":
vims_test_result = self.run_clearwater_live_test(
dns_ip=dns_ip,
- public_domain=self.inputs["public_domain"])
+ public_domain="") # self.inputs["public_domain"]
if vims_test_result != '':
return {'status': 'PASS', 'result': vims_test_result}
else:
@@ -273,19 +260,6 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
self.orchestrator['object'].undeploy_manager()
super(CloudifyIms, self).clean()
- def main(self, **kwargs):
- self.logger.info("Cloudify IMS VNF onboarding test starting")
- self.execute()
- self.logger.info("Cloudify IMS VNF onboarding test executed")
- if self.result is "PASS":
- return self.EX_OK
- else:
- return self.EX_RUN_ERROR
-
- def run(self):
- kwargs = {}
- return self.main(**kwargs)
-
# ----------------------------------------------------------
#
@@ -308,19 +282,3 @@ def get_config(parameter, file):
raise ValueError("The parameter %s is not defined in"
" reporting.yaml" % parameter)
return value
-
-
-def download_and_add_image_on_glance(glance, image_name, image_url, data_dir):
- dest_path = data_dir
- if not os.path.exists(dest_path):
- os.makedirs(dest_path)
- file_name = image_url.rsplit('/')[-1]
- if not ft_utils.download_url(image_url, dest_path):
- return False
-
- image = os_utils.create_glance_image(
- glance, image_name, dest_path + file_name)
- if not image:
- return False
-
- return image
diff --git a/functest/opnfv_tests/vnf/ims/opera_ims.py b/functest/opnfv_tests/vnf/ims/opera_ims.py
index 8c33d16e..d420705a 100644
--- a/functest/opnfv_tests/vnf/ims/opera_ims.py
+++ b/functest/opnfv_tests/vnf/ims/opera_ims.py
@@ -16,6 +16,7 @@ from opera import openo_connect
import requests
import functest.opnfv_tests.vnf.ims.clearwater_ims_base as clearwater_ims_base
+from functest.utils.constants import CONST
class OperaIms(clearwater_ims_base.ClearwaterOnBoardingBase):
@@ -25,9 +26,10 @@ class OperaIms(clearwater_ims_base.ClearwaterOnBoardingBase):
kwargs["case_name"] = "opera_ims"
super(OperaIms, self).__init__(**kwargs)
self.logger = logging.getLogger(__name__)
- self.ellis_file = os.path.join(self.result_dir, 'ellis.info')
- self.live_test_file = os.path.join(self.result_dir,
- 'live_test_report.json')
+ self.ellis_file = os.path.join(
+ CONST.__getattribute__('dir_results'), 'ellis.info')
+ self.live_test_file = os.path.join(
+ CONST.__getattribute__('dir_results'), 'live_test_report.json')
try:
self.openo_msb_endpoint = os.environ['OPENO_MSB_ENDPOINT']
except KeyError:
diff --git a/functest/opnfv_tests/vnf/ims/orchestra_ims.py b/functest/opnfv_tests/vnf/ims/orchestra_ims.py
index 6f341970..207d6a67 100755
--- a/functest/opnfv_tests/vnf/ims/orchestra_ims.py
+++ b/functest/opnfv_tests/vnf/ims/orchestra_ims.py
@@ -10,19 +10,21 @@
import json
import logging
import os
+import pkg_resources
import socket
import sys
import time
import yaml
import functest.core.vnf as vnf
-import functest.utils.functest_utils as ft_utils
import functest.utils.openstack_utils as os_utils
from functest.utils.constants import CONST
from org.openbaton.cli.agents.agents import MainAgent
from org.openbaton.cli.errors.errors import NfvoException
+
+__author__ = "Pauls, Michael <michael.pauls@fokus.fraunhofer.de>"
# ----------------------------------------------------------
#
# UTILS
@@ -30,7 +32,7 @@ from org.openbaton.cli.errors.errors import NfvoException
# -----------------------------------------------------------
-def get_config(parameter, file):
+def get_config(parameter, my_file):
"""
Returns the value of a given parameter in file.yaml
parameter must be given in string format with dots
@@ -44,25 +46,10 @@ def get_config(parameter, file):
value = value.get(element)
if value is None:
raise ValueError("The parameter %s is not defined in"
- " %s" % (parameter, file))
+ " %s" % (parameter, my_file))
return value
-def download_and_add_image_on_glance(glance, image_name,
- image_url, data_dir):
- dest_path = data_dir
- if not os.path.exists(dest_path):
- os.makedirs(dest_path)
- file_name = image_url.rsplit('/')[-1]
- if not ft_utils.download_url(image_url, dest_path):
- return False
- image = os_utils.create_glance_image(
- glance, image_name, dest_path + file_name)
- if not image:
- return False
- return image
-
-
def servertest(host, port):
args = socket.getaddrinfo(host, port, socket.AF_INET, socket.SOCK_STREAM)
for family, socktype, proto, canonname, sockaddr in args:
@@ -77,20 +64,23 @@ def servertest(host, port):
class ImsVnf(vnf.VnfOnBoarding):
+ """OpenIMS VNF deployed with openBaton orchestrator"""
def __init__(self, project='functest', case_name='orchestra_ims',
repo='', cmd=''):
super(ImsVnf, self).__init__(project, case_name, repo, cmd)
+ self.logger = logging.getLogger(__name__)
+ self.logger.info("Orchestra IMS VNF onboarding test starting")
self.ob_password = "openbaton"
self.ob_username = "admin"
self.ob_https = False
self.ob_port = "8080"
self.ob_ip = "localhost"
self.ob_instance_id = ""
- self.logger = logging.getLogger(__name__)
- self.case_dir = os.path.join(CONST.dir_functest_test, 'vnf/ims/')
- self.data_dir = CONST.dir_ims_data
- self.test_dir = CONST.dir_repo_vims_test
+ self.case_dir = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/vnf/ims/')
+ self.data_dir = CONST.__getattribute__('dir_ims_data')
+ self.test_dir = CONST.__getattribute__('dir_repo_vims_test')
self.ob_projectid = ""
self.keystone_client = os_utils.get_keystone_client()
self.ob_nsr_id = ""
@@ -118,7 +108,7 @@ class ImsVnf(vnf.VnfOnBoarding):
self.userdata_file = get_config("openbaton.userdata.file",
config_file)
- def deploy_orchestrator(self, **kwargs):
+ def deploy_orchestrator(self):
self.logger.info("Additional pre-configuration steps")
nova_client = os_utils.get_nova_client()
neutron_client = os_utils.get_neutron_client()
@@ -129,25 +119,28 @@ class ImsVnf(vnf.VnfOnBoarding):
self.logger.info("Upload some OS images if it doesn't exist")
temp_dir = os.path.join(self.data_dir, "tmp/")
for image_name, image_url in self.images.iteritems():
- self.logger.info("image: %s, url: %s" % (image_name, image_url))
+ self.logger.info("image: %s, url: %s", image_name, image_url)
try:
image_id = os_utils.get_image_id(glance_client,
image_name)
- self.logger.info("image_id: %s" % image_id)
+ self.logger.info("image_id: %s", image_id)
except BaseException:
- self.logger.error("Unexpected error: %s" % sys.exc_info()[0])
+ self.logger.error("Unexpected error: %s", sys.exc_info()[0])
if image_id == '':
- self.logger.info("""%s image doesn't exist on glance repository. Try
- downloading this image and upload on glance !""" % image_name)
- image_id = download_and_add_image_on_glance(glance_client,
- image_name,
- image_url,
- temp_dir)
+ self.logger.info("""%s image doesn't exist on glance
+ repository. Try downloading this image
+ and upload on glance !""" % image_name)
+ image_id = os_utils.download_and_add_image_on_glance(
+ glance_client,
+ image_name,
+ image_url,
+ temp_dir)
if image_id == '':
- self.step_failure(
- "Failed to find or upload required OS "
- "image for this deployment")
+ self.logger.error("Failed to find or upload required OS "
+ "image for this deployment")
+ return False
+
network_dic = os_utils.create_network_full(neutron_client,
"openbaton_mgmt",
"openbaton_mgmt_subnet",
@@ -177,6 +170,7 @@ class ImsVnf(vnf.VnfOnBoarding):
if floatip is None:
self.logger.error("Cannot create floating IP.")
+ return False
userdata = "#!/bin/bash\n"
userdata += "echo \"Executing userdata...\"\n"
@@ -249,8 +243,10 @@ class ImsVnf(vnf.VnfOnBoarding):
self.logger.info("flavor: m1.medium\n"
"image: %s\n"
"network_id: %s\n"
- "userdata: %s\n"
- % (self.imagename, network_id, userdata))
+ "userdata: %s\n",
+ self.imagename,
+ network_id,
+ userdata)
instance = os_utils.create_instance_and_wait_for_active(
"orchestra",
@@ -266,10 +262,12 @@ class ImsVnf(vnf.VnfOnBoarding):
os_utils.add_secgroup_to_instance(nova_client,
self.ob_instance_id, sg_id)
- self.logger.info("Associating floating ip: '%s' to VM '%s' "
- % (floatip, "orchestra-openbaton"))
+ self.logger.info("Associating floating ip: '%s' to VM '%s' ",
+ floatip,
+ "orchestra-openbaton")
if not os_utils.add_floating_ip(nova_client, instance.id, floatip):
- self.step_failure("Cannot associate floating IP to VM.")
+ self.logger.error("Cannot associate floating IP to VM.")
+ return False
self.logger.info("Waiting for Open Baton NFVO to be up and running...")
x = 0
@@ -284,7 +282,7 @@ class ImsVnf(vnf.VnfOnBoarding):
x += 1
if x == 100:
- self.step_failure("Open Baton is not started correctly")
+ self.logger.error("Open Baton is not started correctly")
self.ob_ip = floatip
self.ob_password = "openbaton"
@@ -296,6 +294,7 @@ class ImsVnf(vnf.VnfOnBoarding):
self.details["orchestrator"] = {
'status': "PASS", 'result': "Deploy Open Baton NFVO: OK"}
self.logger.info("Deploy Open Baton NFVO: OK")
+ return True
def deploy_vnf(self):
self.logger.info("Starting vIMS Deployment...")
@@ -315,22 +314,22 @@ class ImsVnf(vnf.VnfOnBoarding):
'20',
'1',
public=True)
- self.logger.debug("Flavor id: %s" % flavor_id)
+ 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()):
if p.get("name") == "default":
self.ob_projectid = p.get("id")
- self.logger.info("Found project 'default': %s" % p)
+ self.logger.info("Found project 'default': %s", p)
break
- self.logger.debug("project id: %s" % self.ob_projectid)
+ self.logger.debug("project id: %s", self.ob_projectid)
if self.ob_projectid == "":
- self.step_failure("Default project id was not found!")
+ self.logger.error("Default project id was not found!")
creds = os_utils.get_credentials()
- self.logger.info("PoP creds: %s" % creds)
+ self.logger.info("PoP creds: %s", creds)
if os_utils.is_keystone_v3():
self.logger.info(
@@ -343,7 +342,7 @@ class ImsVnf(vnf.VnfOnBoarding):
"Using v2 API of OpenStack... -> Using OS_TENANT_NAME")
project_id = creds.get("tenant_name")
- self.logger.debug("project id: %s" % project_id)
+ self.logger.debug("project id: %s", project_id)
vim_json = {
"name": "vim-instance",
@@ -363,7 +362,7 @@ class ImsVnf(vnf.VnfOnBoarding):
}
}
- self.logger.debug("Registering VIM: %s" % vim_json)
+ self.logger.debug("Registering VIM: %s", vim_json)
self.main_agent.get_agent(
"vim",
@@ -374,28 +373,29 @@ class ImsVnf(vnf.VnfOnBoarding):
nsd = {}
try:
- self.logger.info("sending: %s" % self.market_link)
+ self.logger.info("sending: %s", self.market_link)
nsd = market_agent.create(entity=self.market_link)
self.logger.info("Onboarded NSD: " + nsd.get("name"))
except NfvoException as e:
- self.step_failure(e.message)
+ self.logger.error(e.message)
nsr_agent = self.main_agent.get_agent("nsr",
project_id=self.ob_projectid)
nsd_id = nsd.get('id')
if nsd_id is None:
- self.step_failure("NSD not onboarded correctly")
+ self.logger.error("NSD not onboarded correctly")
try:
self.nsr = nsr_agent.create(nsd_id)
except NfvoException as e:
- self.step_failure(e.message)
+ self.logger.error(e.message)
if self.nsr.get('code') is not None:
self.logger.error(
- "vIMS cannot be deployed: %s -> %s" %
- (self.nsr.get('code'), self.nsr.get('message')))
- self.step_failure("vIMS cannot be deployed")
+ "vIMS cannot be deployed: %s -> %s",
+ self.nsr.get('code'),
+ self.nsr.get('message'))
+ self.logger.error("vIMS cannot be deployed")
i = 0
self.logger.info("Waiting for NSR to go to ACTIVE...")
@@ -403,8 +403,8 @@ class ImsVnf(vnf.VnfOnBoarding):
"status") != 'ERROR':
i += 1
if i == 150:
- self.step_failure("After %s sec the NSR did not go to ACTIVE.."
- % 5 * i)
+ self.logger.error("INACTIVE NSR after %s sec..", 5 * i)
+
time.sleep(5)
self.nsr = json.loads(nsr_agent.find(self.nsr.get('id')))
@@ -414,60 +414,66 @@ class ImsVnf(vnf.VnfOnBoarding):
else:
self.details["vnf"] = {'status': "FAIL", 'result': self.nsr}
self.logger.error(self.nsr)
- self.step_failure("Deploy VNF: ERROR")
+ self.logger.error("Deploy VNF: ERROR")
+ return False
+
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 self.details.get("vnf")
+ return True
def test_vnf(self):
# Adaptations probably needed
# code used for cloudify_ims
# ruby client on jumphost calling the vIMS on the SUT
self.logger.info(
- "Testing if %s works properly..." %
- self.nsr.get('name'))
+ "Testing if %s works properly...", self.nsr.get('name'))
for vnfr in self.nsr.get('vnfr'):
self.logger.info(
- "Checking ports %s of VNF %s" %
- (self.ims_conf.get(
- vnfr.get('name')).get('ports'),
- vnfr.get('name')))
+ "Checking ports %s of VNF %s",
+ self.ims_conf.get(vnfr.get('name')).get('ports'),
+ vnfr.get('name'))
for vdu in vnfr.get('vdu'):
for vnfci in vdu.get('vnfc_instance'):
self.logger.debug(
- "Checking ports of VNFC instance %s" %
+ "Checking ports of VNFC instance %s",
vnfci.get('hostname'))
for floatingIp in vnfci.get('floatingIps'):
self.logger.debug(
- "Testing %s:%s" %
- (vnfci.get('hostname'), floatingIp.get('ip')))
+ "Testing %s:%s",
+ vnfci.get('hostname'),
+ floatingIp.get('ip'))
for port in self.ims_conf.get(
vnfr.get('name')).get('ports'):
if servertest(floatingIp.get('ip'), port):
self.logger.info(
- "VNFC instance %s is reachable at %s:%s" %
- (vnfci.get('hostname'),
- floatingIp.get('ip'),
- port))
+ "VNFC instance %s is reachable at %s:%s",
+ vnfci.get('hostname'),
+ floatingIp.get('ip'),
+ port)
else:
self.logger.error(
"VNFC instance %s is not reachable "
- "at %s:%s" % (vnfci.get('hostname'),
- floatingIp.get('ip'), port))
+ "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")
+ "not reachable",
+ port,
+ vnfci.get('hostname'),
+ floatingIp.get('ip'))}
+ self.logger.error("Test VNF: ERROR")
+ return False
+
self.details["test_vnf"] = {
'status': "PASS",
'result': "All tests have been executed successfully"}
self.logger.info("Test VNF: OK")
- return self.details.get('test_vnf')
+ return True
def clean(self):
self.main_agent.get_agent(
@@ -476,28 +482,6 @@ class ImsVnf(vnf.VnfOnBoarding):
time.sleep(5)
os_utils.delete_instance(nova_client=os_utils.get_nova_client(),
instance_id=self.ob_instance_id)
- # TODO question is the clean removing also the VM?
+ # question is the clean removing also the VM?
# I think so since is goinf to remove the tenant...
super(ImsVnf, self).clean()
-
- def main(self, **kwargs):
- self.logger.info("Orchestra IMS VNF onboarding test starting")
- self.execute()
- self.logger.info("Orchestra IMS VNF onboarding test executed")
- if self.result is "PASS":
- return self.EX_OK
- else:
- return self.EX_RUN_ERROR
-
- def run(self):
- kwargs = {}
- return self.main(**kwargs)
-
-
-if __name__ == '__main__':
- logging.basicConfig()
- test = ImsVnf()
- test.deploy_orchestrator()
- test.deploy_vnf()
- test.test_vnf()
- test.clean()