aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests
diff options
context:
space:
mode:
Diffstat (limited to 'functest/opnfv_tests')
-rw-r--r--functest/opnfv_tests/features/barometer.py5
-rwxr-xr-xfunctest/opnfv_tests/features/security_scan.py4
-rw-r--r--functest/opnfv_tests/openstack/rally/scenario/templates/server_with_ports.yaml.template2
-rw-r--r--functest/opnfv_tests/openstack/rally/scenario/templates/server_with_volume.yaml.template2
-rw-r--r--functest/opnfv_tests/openstack/snaps/api_check.py9
-rw-r--r--functest/opnfv_tests/openstack/snaps/connection_check.py9
-rw-r--r--functest/opnfv_tests/openstack/snaps/health_check.py21
-rw-r--r--functest/opnfv_tests/openstack/snaps/smoke.py16
-rw-r--r--functest/opnfv_tests/openstack/snaps/snaps_test_runner.py30
-rw-r--r--functest/opnfv_tests/openstack/tempest/conf_utils.py24
-rw-r--r--functest/opnfv_tests/openstack/tempest/custom_tests/blacklist.txt19
-rw-r--r--functest/opnfv_tests/openstack/tempest/tempest.py4
-rwxr-xr-xfunctest/opnfv_tests/sdn/odl/odl.py16
-rw-r--r--functest/opnfv_tests/sdn/onos/__init__.py0
-rw-r--r--functest/opnfv_tests/sdn/onos/onos.py225
-rw-r--r--functest/opnfv_tests/sdn/onos/teston/adapters/foundation.py38
-rwxr-xr-xfunctest/opnfv_tests/sdn/onos/teston/onos.py261
-rw-r--r--functest/opnfv_tests/vnf/ims/cloudify_ims.py2
-rw-r--r--functest/opnfv_tests/vnf/ims/orchestra_ims.py211
-rw-r--r--functest/opnfv_tests/vnf/ims/orchestra_ims.yaml14
20 files changed, 499 insertions, 413 deletions
diff --git a/functest/opnfv_tests/features/barometer.py b/functest/opnfv_tests/features/barometer.py
index aec2bce5..32067284 100644
--- a/functest/opnfv_tests/features/barometer.py
+++ b/functest/opnfv_tests/features/barometer.py
@@ -6,11 +6,9 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
+from baro_tests import collectd
import functest.core.feature_base as base
-import functest.utils.functest_logger as ft_logger
-
-from baro_tests import collectd
class BarometerCollectd(base.FeatureBase):
@@ -22,7 +20,6 @@ class BarometerCollectd(base.FeatureBase):
super(BarometerCollectd, self).__init__(project='barometer',
case='barometercollectd',
repo='dir_repo_barometer')
- self.logger = ft_logger.Logger("BarometerCollectd").getLogger()
def execute(self):
return collectd.main(self.logger)
diff --git a/functest/opnfv_tests/features/security_scan.py b/functest/opnfv_tests/features/security_scan.py
index 2db44175..58f0ec74 100755
--- a/functest/opnfv_tests/features/security_scan.py
+++ b/functest/opnfv_tests/features/security_scan.py
@@ -17,8 +17,8 @@ class SecurityScan(base.FeatureBase):
super(SecurityScan, self).__init__(project='securityscanning',
case='security_scan',
repo='dir_repo_securityscan')
- self.cmd = ('bash {0} && '
+ self.cmd = ('. {0}/stackrc && '
'cd {1} && '
'python security_scan.py --config config.ini && '
- 'cd -'.format(CONST.openstack_creds,
+ 'cd -'.format(CONST.dir_functest_conf,
self.repo))
diff --git a/functest/opnfv_tests/openstack/rally/scenario/templates/server_with_ports.yaml.template b/functest/opnfv_tests/openstack/rally/scenario/templates/server_with_ports.yaml.template
index 909f45d2..ed5e61fe 100644
--- a/functest/opnfv_tests/openstack/rally/scenario/templates/server_with_ports.yaml.template
+++ b/functest/opnfv_tests/openstack/rally/scenario/templates/server_with_ports.yaml.template
@@ -7,7 +7,7 @@ parameters:
default: public
image:
type: string
- default: cirros-0.3.4-x86_64-uec
+ default: cirros-0.3.5-x86_64-uec
flavor:
type: string
default: m1.tiny
diff --git a/functest/opnfv_tests/openstack/rally/scenario/templates/server_with_volume.yaml.template b/functest/opnfv_tests/openstack/rally/scenario/templates/server_with_volume.yaml.template
index 826ca9da..116b5bb6 100644
--- a/functest/opnfv_tests/openstack/rally/scenario/templates/server_with_volume.yaml.template
+++ b/functest/opnfv_tests/openstack/rally/scenario/templates/server_with_volume.yaml.template
@@ -4,7 +4,7 @@ parameters:
# set all correct defaults for parameters before launch test
image:
type: string
- default: cirros-0.3.4-x86_64-uec
+ default: cirros-0.3.5-x86_64-uec
flavor:
type: string
default: m1.tiny
diff --git a/functest/opnfv_tests/openstack/snaps/api_check.py b/functest/opnfv_tests/openstack/snaps/api_check.py
index 17d05b92..ad77d9be 100644
--- a/functest/opnfv_tests/openstack/snaps/api_check.py
+++ b/functest/opnfv_tests/openstack/snaps/api_check.py
@@ -9,12 +9,12 @@ import unittest
from snaps import test_suite_builder
-from functest.core.pytest_suite_runner import PyTestSuiteRunner
-from functest.opnfv_tests.openstack.snaps import snaps_utils
+from functest.opnfv_tests.openstack.snaps.snaps_test_runner import \
+ SnapsTestRunner
from functest.utils.constants import CONST
-class ApiCheck(PyTestSuiteRunner):
+class ApiCheck(SnapsTestRunner):
"""
This test executes the Python Tests included with the SNAPS libraries
that exercise many of the OpenStack APIs within Keystone, Glance, Neutron,
@@ -25,10 +25,9 @@ class ApiCheck(PyTestSuiteRunner):
self.suite = unittest.TestSuite()
self.case_name = "api_check"
- ext_net_name = snaps_utils.get_ext_net_name()
test_suite_builder.add_openstack_api_tests(
self.suite,
CONST.openstack_creds,
- ext_net_name,
+ self.ext_net_name,
use_keystone=CONST.snaps_use_keystone)
diff --git a/functest/opnfv_tests/openstack/snaps/connection_check.py b/functest/opnfv_tests/openstack/snaps/connection_check.py
index 11f8ad07..0637bcfb 100644
--- a/functest/opnfv_tests/openstack/snaps/connection_check.py
+++ b/functest/opnfv_tests/openstack/snaps/connection_check.py
@@ -9,12 +9,12 @@ import unittest
from snaps import test_suite_builder
-from functest.core.pytest_suite_runner import PyTestSuiteRunner
-from functest.opnfv_tests.openstack.snaps import snaps_utils
+from functest.opnfv_tests.openstack.snaps.snaps_test_runner import \
+ SnapsTestRunner
from functest.utils.constants import CONST
-class ConnectionCheck(PyTestSuiteRunner):
+class ConnectionCheck(SnapsTestRunner):
"""
This test executes the Python Tests included with the SNAPS libraries
that simply obtain the different OpenStack clients and may perform
@@ -25,10 +25,9 @@ class ConnectionCheck(PyTestSuiteRunner):
self.suite = unittest.TestSuite()
self.case_name = "connection_check"
- ext_net_name = snaps_utils.get_ext_net_name()
test_suite_builder.add_openstack_client_tests(
self.suite,
CONST.openstack_creds,
- ext_net_name,
+ self.ext_net_name,
use_keystone=CONST.snaps_use_keystone)
diff --git a/functest/opnfv_tests/openstack/snaps/health_check.py b/functest/opnfv_tests/openstack/snaps/health_check.py
index 993c1000..8fece746 100644
--- a/functest/opnfv_tests/openstack/snaps/health_check.py
+++ b/functest/opnfv_tests/openstack/snaps/health_check.py
@@ -7,15 +7,15 @@
import unittest
+from functest.opnfv_tests.openstack.snaps.snaps_test_runner import \
+ SnapsTestRunner
+from functest.utils.constants import CONST
+
from snaps.openstack.tests.os_source_file_test import OSIntegrationTestCase
from snaps.openstack.tests.create_instance_tests import SimpleHealthCheck
-from functest.core.pytest_suite_runner import PyTestSuiteRunner
-from functest.opnfv_tests.openstack.snaps import snaps_utils
-from functest.utils.constants import CONST
-
-class HealthCheck(PyTestSuiteRunner):
+class HealthCheck(SnapsTestRunner):
"""
This test executes the SNAPS Python Test case SimpleHealthCheck which
creates a VM with a single port with an IPv4 address that is assigned by
@@ -26,9 +26,14 @@ class HealthCheck(PyTestSuiteRunner):
self.suite = unittest.TestSuite()
self.case_name = "snaps_health_check"
- ext_net_name = snaps_utils.get_ext_net_name()
+
+ image_custom_config = None
+ if hasattr(CONST, 'snaps_health_check'):
+ image_custom_config = CONST.snaps_health_check
self.suite.addTest(
OSIntegrationTestCase.parameterize(
- SimpleHealthCheck, CONST.openstack_creds, ext_net_name,
- use_keystone=CONST.snaps_use_keystone))
+ SimpleHealthCheck, CONST.openstack_creds, self.ext_net_name,
+ use_keystone=CONST.snaps_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 83eb6600..864bca5e 100644
--- a/functest/opnfv_tests/openstack/snaps/smoke.py
+++ b/functest/opnfv_tests/openstack/snaps/smoke.py
@@ -10,12 +10,12 @@ import unittest
from snaps import test_suite_builder
-from functest.core.pytest_suite_runner import PyTestSuiteRunner
-from functest.opnfv_tests.openstack.snaps import snaps_utils
+from functest.opnfv_tests.openstack.snaps.snaps_test_runner import \
+ SnapsTestRunner
from functest.utils.constants import CONST
-class SnapsSmoke(PyTestSuiteRunner):
+class SnapsSmoke(SnapsTestRunner):
"""
This test executes the Python Tests included with the SNAPS libraries
that exercise many of the OpenStack APIs within Keystone, Glance, Neutron,
@@ -27,7 +27,12 @@ class SnapsSmoke(PyTestSuiteRunner):
self.suite = unittest.TestSuite()
self.case_name = "snaps_smoke"
use_fip = CONST.snaps_use_floating_ips
- ext_net_name = snaps_utils.get_ext_net_name()
+
+ # 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
# Tests requiring floating IPs leverage files contained within the
# SNAPS repository and are found relative to that path
@@ -38,6 +43,7 @@ class SnapsSmoke(PyTestSuiteRunner):
test_suite_builder.add_openstack_integration_tests(
self.suite,
CONST.openstack_creds,
- ext_net_name,
+ self.ext_net_name,
use_keystone=CONST.snaps_use_keystone,
+ image_metadata=image_custom_config,
use_floating_ips=use_fip)
diff --git a/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py b/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py
new file mode 100644
index 00000000..67cd9415
--- /dev/null
+++ b/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py
@@ -0,0 +1,30 @@
+# 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
+
+from functest.core.pytest_suite_runner import PyTestSuiteRunner
+from functest.opnfv_tests.openstack.snaps import snaps_utils
+from functest.utils import functest_utils
+
+from snaps.openstack import create_flavor
+
+
+class SnapsTestRunner(PyTestSuiteRunner):
+ """
+ This test executes the SNAPS Python Test case SimpleHealthCheck which
+ 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__()
+
+ self.ext_net_name = snaps_utils.get_ext_net_name()
+
+ 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
diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py
index 893fff8c..2c113367 100644
--- a/functest/opnfv_tests/openstack/tempest/conf_utils.py
+++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py
@@ -106,6 +106,17 @@ def get_verifier_deployment_dir(verifier_id, deployment_id):
'for-deployment-{}'.format(deployment_id))
+def get_repo_tag(repo):
+ """
+ Returns last tag of current branch
+ """
+ cmd = ("git -C {0} describe --abbrev=0 HEAD".format(repo))
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
+ tag = p.stdout.readline().rstrip()
+
+ return str(tag)
+
+
def backup_tempest_config(conf_file):
"""
Copy config file to tempest results directory
@@ -276,3 +287,16 @@ def configure_tempest_multisite_params(tempest_conf_file):
config.write(config_file)
backup_tempest_config(tempest_conf_file)
+
+
+def install_verifier_ext(path):
+ """
+ Install extension to active verifier
+ """
+ logger.info("Installing verifier from existing repo...")
+ tag = get_repo_tag(path)
+ cmd = ("rally verify add-verifier-ext --source {0} "
+ "--version {1}"
+ .format(path, tag))
+ error_msg = ("Problem while adding verifier extension from %s" % path)
+ ft_utils.execute_command_raise(cmd, error_msg=error_msg)
diff --git a/functest/opnfv_tests/openstack/tempest/custom_tests/blacklist.txt b/functest/opnfv_tests/openstack/tempest/custom_tests/blacklist.txt
index 0a4256ce..fcdfe225 100644
--- a/functest/opnfv_tests/openstack/tempest/custom_tests/blacklist.txt
+++ b/functest/opnfv_tests/openstack/tempest/custom_tests/blacklist.txt
@@ -1,22 +1,3 @@
--
- scenarios:
- - os-odl_l2-bgpvpn-ha
- - os-odl_l2-bgpvpn-noha
- installers:
- - fuel
- - apex
- tests:
- - tempest.api.compute.servers.test_create_server.ServersTestJSON.test_list_servers
- - tempest.api.compute.servers.test_create_server.ServersTestJSON.test_verify_server_details
- - tempest.api.compute.servers.test_create_server.ServersTestManualDisk.test_list_servers
- - tempest.api.compute.servers.test_create_server.ServersTestManualDisk.test_verify_server_details
- - tempest.api.compute.servers.test_server_actions.ServerActionsTestJSON.test_reboot_server_hard
- - tempest.api.network.test_floating_ips.FloatingIPTestJSON.test_create_list_show_update_delete_floating_ip
- - tempest.api.network.test_floating_ips.FloatingIPTestJSON.test_create_floating_ip_specifying_a_fixed_ip_address
- - tempest.scenario.test_network_basic_ops.TestNetworkBasicOps.test_network_basic_ops
- - tempest.scenario.test_server_basic_ops.TestServerBasicOps.test_server_basic_ops
- - tempest.scenario.test_volume_boot_pattern.TestVolumeBootPattern.test_volume_boot_pattern
- - tempest.scenario.test_volume_boot_pattern.TestVolumeBootPatternV2.test_volume_boot_pattern
-
scenarios:
diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py
index ae4eed09..a6ce4ee6 100644
--- a/functest/opnfv_tests/openstack/tempest/tempest.py
+++ b/functest/opnfv_tests/openstack/tempest/tempest.py
@@ -161,7 +161,8 @@ class TempestCommon(testcase_base.TestcaseBase):
result_file.close()
def run_verifier_tests(self):
- self.OPTION += (" --load-list {}".format(conf_utils.TEMPEST_LIST))
+ self.OPTION += (" --load-list {} --detailed"
+ .format(conf_utils.TEMPEST_LIST))
cmd_line = "rally verify start " + self.OPTION
logger.info("Starting Tempest test suite: '%s'." % cmd_line)
@@ -315,6 +316,7 @@ class TempestMultisite(TempestCommon):
self.case_name = "multisite"
self.MODE = "feature_multisite"
self.OPTION = "--concurrency 1"
+ conf_utils.install_verifier_ext(CONST.dir_repo_kingbird)
class TempestCustom(TempestCommon):
diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py
index 69818f5a..c8e9c492 100755
--- a/functest/opnfv_tests/sdn/odl/odl.py
+++ b/functest/opnfv_tests/sdn/odl/odl.py
@@ -94,8 +94,11 @@ class ODLTests(testcase_base.TestcaseBase):
try:
odlusername = kwargs['odlusername']
odlpassword = kwargs['odlpassword']
- variables = ['KEYSTONE:' + kwargs['keystoneip'],
+ osauthurl = kwargs['osauthurl']
+ keystoneip = urlparse.urlparse(osauthurl).hostname
+ variables = ['KEYSTONE:' + keystoneip,
'NEUTRON:' + kwargs['neutronip'],
+ 'OS_AUTH_URL:"' + osauthurl + '"',
'OSUSERNAME:"' + kwargs['osusername'] + '"',
'OSTENANTNAME:"' + kwargs['ostenantname'] + '"',
'OSPASSWORD:"' + kwargs['ospassword'] + '"',
@@ -147,10 +150,8 @@ class ODLTests(testcase_base.TestcaseBase):
suites = kwargs["suites"]
except KeyError:
pass
- keystone_url = op_utils.get_endpoint(service_type='identity')
neutron_url = op_utils.get_endpoint(service_type='network')
- kwargs = {'keystoneip': urlparse.urlparse(keystone_url).hostname}
- kwargs['neutronip'] = urlparse.urlparse(neutron_url).hostname
+ kwargs = {'neutronip': urlparse.urlparse(neutron_url).hostname}
kwargs['odlip'] = kwargs['neutronip']
kwargs['odlwebport'] = '8080'
kwargs['odlrestconfport'] = '8181'
@@ -161,6 +162,7 @@ class ODLTests(testcase_base.TestcaseBase):
installer_type = os.environ['INSTALLER_TYPE']
kwargs['osusername'] = os.environ['OS_USERNAME']
kwargs['ostenantname'] = os.environ['OS_TENANT_NAME']
+ kwargs['osauthurl'] = os.environ['OS_AUTH_URL']
kwargs['ospassword'] = os.environ['OS_PASSWORD']
if installer_type == 'fuel':
kwargs['odlwebport'] = '8282'
@@ -191,12 +193,12 @@ class ODLParser(object):
def __init__(self):
self.parser = argparse.ArgumentParser()
self.parser.add_argument(
- '-k', '--keystoneip', help='Keystone IP',
- default='127.0.0.1')
- self.parser.add_argument(
'-n', '--neutronip', help='Neutron IP',
default='127.0.0.1')
self.parser.add_argument(
+ '-k', '--osauthurl', help='OS_AUTH_URL as defined by OpenStack',
+ default='http://127.0.0.1:5000/v2.0')
+ self.parser.add_argument(
'-a', '--osusername', help='Username for OpenStack',
default='admin')
self.parser.add_argument(
diff --git a/functest/opnfv_tests/sdn/onos/__init__.py b/functest/opnfv_tests/sdn/onos/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/functest/opnfv_tests/sdn/onos/__init__.py
diff --git a/functest/opnfv_tests/sdn/onos/onos.py b/functest/opnfv_tests/sdn/onos/onos.py
new file mode 100644
index 00000000..8bc73832
--- /dev/null
+++ b/functest/opnfv_tests/sdn/onos/onos.py
@@ -0,0 +1,225 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2017 HUAWEI TECHNOLOGIES CO.,LTD and others.
+#
+# 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 os
+import re
+import subprocess
+import shutil
+import time
+import urlparse
+
+from functest.core import testcase_base
+from functest.utils.constants import CONST
+import functest.utils.functest_logger as ft_logger
+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_base.TestcaseBase):
+ 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)
+
+ def __init__(self):
+ super(OnosBase, self).__init__()
+
+ def run(self):
+ self.start_time = time.time()
+ try:
+ self._run()
+ res = testcase_base.TestcaseBase.EX_OK
+ except Exception as e:
+ logger.error('Error with run: %s', e)
+ res = testcase_base.TestcaseBase.EX_RUN_ERROR
+
+ self.stop_time = time.time()
+ return res
+
+ def _run(self):
+ raise NotImplementedError('_run is not implemented')
+
+
+class Onos(OnosBase):
+ def __init__(self):
+ super(Onos, self).__init__()
+ self.case_name = 'onos'
+ 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'):
+ 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)
+
+ 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)
+ ft_utils.execute_command_raise(
+ cmd,
+ error_msg=('Error when running ONOS script: %s'
+ % (testname)))
+
+ def clean_existing_logs(self):
+ log_dir = [f for f in os.listdir(self.log_path)]
+ for log in log_dir:
+ try:
+ if os.path.isdir(log):
+ shutil.rmtree(log)
+ elif os.path.isfile(log):
+ os.remove(log)
+ except OSError as e:
+ logger.error('Error with deleting file %s: %s',
+ log, e.strerror)
+
+ def get_result(self):
+ cmd = 'grep -rnh Fail {0}'.format(self.log_path)
+ p = subprocess.Popen(cmd,
+ shell=True,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+
+ for line in p.stdout:
+ logger.debug(line)
+ if re.search("\s+[1-9]+\s+", line):
+ logger.debug("Testcase Fails\n" + line)
+
+ cmd = "grep -rnh 'Execution Time' {0}".format(self.log_path)
+ result_buffer = os.popen(cmd).read()
+ time1 = result_buffer[114:128]
+ time2 = result_buffer[28:42]
+ cmd = "grep -rnh 'Success Percentage' {0}".format(
+ os.path.join(self.log_path, "FUNCvirNetNB_*"))
+ result_buffer = os.popen(cmd).read()
+ if result_buffer.find('100%') >= 0:
+ result1 = 'Success'
+ else:
+ result1 = 'Failed'
+ cmd = "grep -rnh 'Success Percentage' {0}".format(
+ os.path.join(self.log_path, "FUNCvirNetNBL3*"))
+ result_buffer = os.popen(cmd).read()
+ if result_buffer.find('100%') >= 0:
+ result2 = 'Success'
+ else:
+ result2 = 'Failed'
+ status1 = []
+ status2 = []
+ cmd = "grep -rnh 'h3' {0}".format(
+ os.path.join(self.log_path, "FUNCvirNetNB_*"))
+ result_buffer = os.popen(cmd).read()
+ pattern = re.compile("<h3>([^-]+) - ([^-]+) - (\S*)</h3>")
+ # res = pattern.search(result_buffer).groups()
+ res = pattern.findall(result_buffer)
+ i = 0
+ for index in range(len(res)):
+ status1.append({'Case name:': res[i][0] + res[i][1],
+ 'Case result': res[i][2]})
+ i = i + 1
+ cmd = "grep -rnh 'h3' {0}".format(
+ os.path.join(self.log_path, "FUNCvirNetNBL3*"))
+ result_buffer = os.popen(cmd).read()
+ pattern = re.compile("<h3>([^-]+) - ([^-]+) - (\S*)</h3>")
+ res = pattern.findall(result_buffer)
+ i = 0
+ for index in range(len(res)):
+ status2.append({'Case name:': res[i][0] + res[i][1],
+ 'Case result': res[i][2]})
+ i = i + 1
+ payload = {'FUNCvirNet': {'duration': time1,
+ 'result': result1,
+ 'status': status1},
+ 'FUNCvirNetL3': {'duration': time2,
+ 'result': result2,
+ 'status': status2}}
+ return payload
+
+ def parse_result(self):
+ result = self.get_result()
+ status = "FAIL"
+ try:
+ if (result['FUNCvirNet']['result'] == "Success" and
+ result['FUNCvirNetL3']['result'] == "Success"):
+ status = "PASS"
+ except:
+ logger.error("Unable to set ONOS criteria")
+
+ self.criteria = status
+ self.details = result
+
+ def _run(self):
+ self.clean_existing_logs()
+ self.set_onos_ip()
+ self.run_onos_script('FUNCvirNetNB')
+ self.run_onos_script('FUNCvirNetNBL3')
+ self.parse_result()
+
+
+class OnosSfc(OnosBase):
+ def __init__(self):
+ super(OnosSfc, self).__init__()
+ self.case_name = 'onos_sfc'
+
+ def get_ip(type):
+ url = openstack_utils.get_endpoint(service_type=type)
+ logger.debug('get_ip for %s: %s' % (type, url))
+ return urlparse.urlparse(url).hostname
+
+ def update_sfc_onos_file(self, before, after):
+ file_dir = os.path.join(self.onos_sfc_path, "sfc_onos.py")
+ cmd = "sed -i 's/{0}/{1}/g' {2}".format(before,
+ after,
+ file_dir)
+ ft_utils.execute_command_raise(
+ cmd,
+ error_msg=('Error with replacing %s with %s'
+ % (before, after)))
+
+ def create_image(self):
+ glance_client = openstack_utils.get_glance_client()
+ image_id = openstack_utils.create_glance_image(
+ glance_client,
+ self.onos_sfc_image_name,
+ self.onos_sfc_image_path)
+ 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))
+
+ 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)
+ 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")
+
+ def sfc_test(self):
+ cmd = 'python {0}'.format(os.path.join(self.onos_sfc_path, 'sfc.py'))
+ ft_utils.execute_command_raise(cmd,
+ error_msg='Error with testing SFC')
+
+ def _run(self):
+ self.create_image()
+ self.set_sfc_conf()
+ self.sfc_test()
diff --git a/functest/opnfv_tests/sdn/onos/teston/adapters/foundation.py b/functest/opnfv_tests/sdn/onos/teston/adapters/foundation.py
index 2bef5cc6..25421d40 100644
--- a/functest/opnfv_tests/sdn/onos/teston/adapters/foundation.py
+++ b/functest/opnfv_tests/sdn/onos/teston/adapters/foundation.py
@@ -17,7 +17,7 @@ import os
import re
import time
-import functest.utils.functest_constants as ft_constants
+from functest.utils.constants import CONST
import functest.utils.functest_utils as ft_utils
@@ -26,7 +26,7 @@ class Foundation(object):
def __init__(self):
# currentpath = os.getcwd()
- currentpath = '%s/sdn/onos/teston/ci' % ft_constants.FUNCTEST_TEST_DIR
+ currentpath = '%s/sdn/onos/teston/ci' % CONST.dir_functest_data
self.cipath = currentpath
self.logdir = os.path.join(currentpath, 'log')
self.workhome = currentpath[0: currentpath.rfind('opnfv_tests') - 1]
@@ -54,23 +54,23 @@ class Foundation(object):
"""
Get Default Parameters value
"""
- self.Result_DB = str(ft_utils.get_db_url())
- self.masterusername = str(ft_constants.ONOSBENCH_USERNAME)
- self.masterpassword = str(ft_constants.ONOSBENCH_PASSWORD)
- self.agentusername = str(ft_constants.ONOSCLI_USERNAME)
- self.agentpassword = str(ft_constants.ONOSCLI_PASSWORD)
- self.runtimeout = ft_constants.ONOS_RUNTIMEOUT
- self.OCT = str(ft_constants.ONOS_OCT)
- self.OC1 = str(ft_constants.ONOS_OC1)
- self.OC2 = str(ft_constants.ONOS_OC2)
- self.OC3 = str(ft_constants.ONOS_OC3)
- self.OCN = str(ft_constants.ONOS_OCN)
- self.OCN2 = str(ft_constants.ONOS_OCN2)
- self.installer_master = str(ft_constants.ONOS_INSTALLER_MASTER)
- self.installer_master_username = \
- str(ft_constants.ONOS_INSTALLER_MASTER_USERNAME)
- self.installer_master_password = \
- ft_constants.ONOS_INSTALLER_MASTER_PASSWORD
+ self.Result_DB = ft_utils.get_db_url()
+ self.masterusername = CONST.ONOS_onosbench_username
+ self.masterpassword = CONST.ONOS_onosbench_password
+ self.agentusername = CONST.ONOS_onoscli_username
+ self.agentpassword = CONST.ONOS_onoscli_password
+ self.runtimeout = CONST.ONOS_runtimeout
+ self.OCT = CONST.ONOS_environment_OCT
+ self.OC1 = CONST.ONOS_environment_OC1
+ self.OC2 = CONST.ONOS_environment_OC2
+ self.OC3 = CONST.ONOS_environment_OC3
+ self.OCN = CONST.ONOS_environment_OCN
+ self.OCN2 = CONST.ONOS_environment_OCN2
+ self.installer_master = CONST.ONOS_environment_installer_master
+ self.installer_master_username = (
+ CONST.ONOS_environment_installer_master_username)
+ self.installer_master_password = (
+ CONST.ONOS_environment_installer_master_password)
self.hosts = [self.OC1, self.OCN, self.OCN2]
self.localhost = self.OCT
diff --git a/functest/opnfv_tests/sdn/onos/teston/onos.py b/functest/opnfv_tests/sdn/onos/teston/onos.py
deleted file mode 100755
index 2537e18d..00000000
--- a/functest/opnfv_tests/sdn/onos/teston/onos.py
+++ /dev/null
@@ -1,261 +0,0 @@
-"""
-Description: This test is to run onos Teston VTN scripts
-
-List of test cases:
-CASE1 - Northbound NBI test network/subnet/ports
-CASE2 - Ovsdb test&Default configuration&Vm go online
-
-lanqinglong@huawei.com
-#
-# 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 datetime
-import os
-import re
-import time
-import urlparse
-
-import argparse
-from neutronclient.v2_0 import client as neutronclient
-
-import functest.utils.functest_constants as ft_constants
-import functest.utils.functest_logger as ft_logger
-import functest.utils.functest_utils as ft_utils
-import functest.utils.openstack_utils as openstack_utils
-
-
-parser = argparse.ArgumentParser()
-parser.add_argument("-t", "--testcase", help="Testcase name")
-args = parser.parse_args()
-
-
-""" logging configuration """
-logger = ft_logger.Logger("onos").getLogger()
-
-# onos parameters
-ONOSCI_PATH = ft_constants.REPOS_DIR + "/"
-starttime = datetime.datetime.now()
-
-INSTALLER_TYPE = ft_constants.CI_INSTALLER_TYPE
-ONOS_SFC_IMAGE_NAME = ft_constants.ONOS_SFC_IMAGE_NAME
-ONOS_SFC_IMAGE_PATH = os.path.join(ft_constants.FUNCTEST_DATA_DIR,
- ft_constants.ONOS_SFC_IMAGE_FILENAME)
-ONOS_SFC_PATH = os.path.join(ft_constants.FUNCTEST_REPO_DIR,
- ft_constants.ONOS_SFC_RELATIVE_PATH)
-
-
-def RunScript(testname):
- """
- Run ONOS Test Script
- Parameters:
- testname: ONOS Testcase Name
- """
- runtest = ONOSCI_PATH + "onos/TestON/bin/cli.py run " + testname
- logger.debug("Run script " + testname)
- os.system(runtest)
-
-
-def DownloadCodes(url="https://github.com/wuwenbin2/OnosSystemTest.git"):
- """
- Download Onos Teston codes
- Parameters:
- url: github url
- """
- downloadcode = "git clone " + url + " " + ONOSCI_PATH + "OnosSystemTest"
- logger.debug("Download Onos Teston codes " + url)
- os.system(downloadcode)
-
-
-def GetResult():
- LOGPATH = ONOSCI_PATH + "onos/TestON/logs"
- cmd = "grep -rnh " + "Fail" + " " + LOGPATH
- Resultbuffer = os.popen(cmd).read()
- # duration = datetime.datetime.now() - starttime
- time.sleep(2)
-
- if re.search("\s+[1-9]+\s+", Resultbuffer):
- logger.debug("Testcase Fails\n" + Resultbuffer)
- # Result = "Failed"
- else:
- logger.debug("Testcases Success")
- # Result = "Success"
- # payload={'timestart': str(starttime),
- # 'duration': str(duration),
- # 'status': Result}
- cmd = "grep -rnh 'Execution Time' " + LOGPATH
- Resultbuffer = os.popen(cmd).read()
- time1 = Resultbuffer[114:128]
- time2 = Resultbuffer[28:42]
- cmd = "grep -rnh 'Success Percentage' " + LOGPATH + "/FUNCvirNetNB_*"
- Resultbuffer = os.popen(cmd).read()
- if Resultbuffer.find('100%') >= 0:
- result1 = 'Success'
- else:
- result1 = 'Failed'
- cmd = "grep -rnh 'Success Percentage' " + LOGPATH + "/FUNCvirNetNBL3*"
- Resultbuffer = os.popen(cmd).read()
- if Resultbuffer.find('100%') >= 0:
- result2 = 'Success'
- else:
- result2 = 'Failed'
- status1 = []
- status2 = []
- cmd = "grep -rnh 'h3' " + LOGPATH + "/FUNCvirNetNB_*"
- Resultbuffer = os.popen(cmd).read()
- pattern = re.compile("<h3>([^-]+) - ([^-]+) - (\S*)</h3>")
- # res = pattern.search(Resultbuffer).groups()
- res = pattern.findall(Resultbuffer)
- i = 0
- for index in range(len(res)):
- status1.append({'Case name:': res[i][0] + res[i][1],
- 'Case result': res[i][2]})
- i = i + 1
- cmd = "grep -rnh 'h3' " + LOGPATH + "/FUNCvirNetNBL3*"
- Resultbuffer = os.popen(cmd).read()
- pattern = re.compile("<h3>([^-]+) - ([^-]+) - (\S*)</h3>")
- # res = pattern.search(Resultbuffer).groups()
- res = pattern.findall(Resultbuffer)
- i = 0
- for index in range(len(res)):
- status2.append({'Case name:': res[i][0] + res[i][1],
- 'Case result': res[i][2]})
- i = i + 1
- payload = {'timestart': str(starttime),
- 'FUNCvirNet': {'duration': time1,
- 'result': result1,
- 'status': status1},
- 'FUNCvirNetL3': {'duration': time2,
- 'result': result2,
- 'status': status2}}
- return payload
-
-
-def SetOnosIp():
- # cmd = "openstack catalog show network | grep publicURL"
- neutron_url = openstack_utils.get_endpoint(service_type='network')
- OC1 = urlparse.urlparse(neutron_url).hostname
- os.environ['OC1'] = OC1
- time.sleep(2)
- logger.debug("ONOS IP is " + OC1)
-
-
-def SetOnosIpForJoid():
- cmd = "env | grep SDN_CONTROLLER"
- cmd_output = os.popen(cmd).read()
- OC1 = re.search(r"\d+\.\d+\.\d+\.\d+", cmd_output).group()
- os.environ['OC1'] = OC1
- time.sleep(2)
- logger.debug("ONOS IP is " + OC1)
-
-
-def CleanOnosTest():
- TESTONPATH = ONOSCI_PATH + "onos/"
- cmd = "rm -rf " + TESTONPATH
- os.system(cmd)
- time.sleep(2)
- logger.debug("Clean ONOS Teston")
-
-
-def CreateImage():
- glance_client = openstack_utils.get_glance_client()
- image_id = openstack_utils.create_glance_image(glance_client,
- ONOS_SFC_IMAGE_NAME,
- ONOS_SFC_IMAGE_PATH)
- EXIT_CODE = -1
- if not image_id:
- logger.error("Failed to create a Glance image...")
- return(EXIT_CODE)
- logger.debug("Image '%s' with ID=%s created successfully."
- % (ONOS_SFC_IMAGE_NAME, image_id))
-
-
-def SfcTest():
- cmd = "python " + ONOS_SFC_PATH + "/sfc.py"
- logger.debug("Run sfc tests")
- os.system(cmd)
-
-
-def GetIp(type):
- # cmd = "openstack catalog show " + type + " | grep publicURL"
- url = openstack_utils.get_endpoint(service_type=type)
- return urlparse.urlparse(url).hostname
-
-
-def Replace(before, after):
- file = "/sfc_onos.py"
- cmd = "sed -i 's/" + before + "/" + after + "/g' " + ONOS_SFC_PATH + file
- os.system(cmd)
-
-
-def SetSfcConf():
- Replace("keystone_ip", GetIp("keystone"))
- Replace("neutron_ip", GetIp("neutron"))
- Replace("nova_ip", GetIp("nova"))
- Replace("glance_ip", GetIp("glance"))
- pwd = ft_constants.OS_PASSWORD
- Replace("console", pwd)
- creds_neutron = openstack_utils.get_credentials()
- neutron_client = neutronclient.Client(**creds_neutron)
- ext_net = openstack_utils.get_external_net(neutron_client)
- Replace("admin_floating_net", ext_net)
- logger.info("Modify configuration for SFC")
-
-
-def OnosTest():
- start_time = time.time()
- stop_time = start_time
- if INSTALLER_TYPE == "joid":
- logger.debug("Installer is Joid")
- SetOnosIpForJoid()
- else:
- SetOnosIp()
- RunScript("FUNCvirNetNB")
- RunScript("FUNCvirNetNBL3")
- try:
- logger.debug("Push ONOS results into DB")
- # TODO check path result for the file
- result = GetResult()
- stop_time = time.time()
-
- # ONOS success criteria = all tests OK
- # i.e. FUNCvirNet & FUNCvirNetL3
- status = "FAIL"
- try:
- if (result['FUNCvirNet']['result'] == "Success" and
- result['FUNCvirNetL3']['result'] == "Success"):
- status = "PASS"
- except:
- logger.error("Unable to set ONOS criteria")
-
- ft_utils.push_results_to_db("functest",
- "onos",
- start_time,
- stop_time,
- status,
- result)
-
- except:
- logger.error("Error pushing results into Database")
-
- if status == "FAIL":
- EXIT_CODE = -1
- exit(EXIT_CODE)
-
-
-def main():
-
- if args.testcase == "sfc":
- CreateImage()
- SetSfcConf()
- SfcTest()
- else:
- OnosTest()
-
-
-if __name__ == '__main__':
- main()
diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.py b/functest/opnfv_tests/vnf/ims/cloudify_ims.py
index c2c251ad..e2401d0f 100644
--- a/functest/opnfv_tests/vnf/ims/cloudify_ims.py
+++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.py
@@ -234,7 +234,7 @@ class ImsVnf(vnf_base.VnfOnBoardingBase):
cw.set_external_network_name(ext_net)
- error = cw.deploy_vnf()
+ error = cw.deploy_vnf(self.vnf['blueprint'])
if error:
self.logger.error(error)
return {'status': 'FAIL', 'result': error}
diff --git a/functest/opnfv_tests/vnf/ims/orchestra_ims.py b/functest/opnfv_tests/vnf/ims/orchestra_ims.py
index 352b609b..42b218e6 100644
--- a/functest/opnfv_tests/vnf/ims/orchestra_ims.py
+++ b/functest/opnfv_tests/vnf/ims/orchestra_ims.py
@@ -23,6 +23,45 @@ from functest.utils.constants import CONST
from org.openbaton.cli.agents.agents import MainAgent
from org.openbaton.cli.errors.errors import NfvoException
+# ----------------------------------------------------------
+#
+# UTILS
+#
+# -----------------------------------------------------------
+
+
+def get_config(parameter, file):
+ """
+ Returns the value of a given parameter in file.yaml
+ parameter must be given in string format with dots
+ Example: general.openstack.image_name
+ """
+ with open(file) as f:
+ file_yaml = yaml.safe_load(f)
+ f.close()
+ value = file_yaml
+ for element in parameter.split("."):
+ value = value.get(element)
+ if value is None:
+ raise ValueError("The parameter %s is not defined in"
+ " %s" % (parameter, 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)
@@ -38,6 +77,7 @@ def servertest(host, port):
class ImsVnf(vnf_base.VnfOnBoardingBase):
+
def __init__(self, project='functest', case='orchestra_ims',
repo='', cmd=''):
super(ImsVnf, self).__init__(project, case, repo, cmd)
@@ -54,6 +94,7 @@ class ImsVnf(vnf_base.VnfOnBoardingBase):
self.ob_projectid = ""
self.keystone_client = os_utils.get_keystone_client()
self.ob_nsr_id = ""
+ self.nsr = None
self.main_agent = None
# vIMS Data directory creation
if not os.path.exists(self.data_dir):
@@ -66,9 +107,14 @@ class ImsVnf(vnf_base.VnfOnBoardingBase):
raise Exception("Orchestra VNF config file not found")
config_file = self.case_dir + self.config
self.imagename = get_config("openbaton.imagename", config_file)
+ self.bootstrap_link = get_config("openbaton.bootstrap_link",
+ config_file)
+ self.bootstrap_config_link = get_config(
+ "openbaton.bootstrap_config_link", config_file)
self.market_link = get_config("openbaton.marketplace_link",
config_file)
self.images = get_config("tenant_images", config_file)
+ self.ims_conf = get_config("vIMS", config_file)
def deploy_orchestrator(self, **kwargs):
self.logger.info("Additional pre-configuration steps")
@@ -77,6 +123,7 @@ class ImsVnf(vnf_base.VnfOnBoardingBase):
glance_client = os_utils.get_glance_client()
# Import images if needed
+ # needs some images
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():
@@ -106,9 +153,9 @@ class ImsVnf(vnf_base.VnfOnBoardingBase):
"192.168.100.0/24")
# orchestrator VM flavor
- self.logger.info("Check medium Flavor is available, if not create one")
+ self.logger.info("Check if Flavor is available, if not create one")
flavor_exist, flavor_id = os_utils.get_or_create_flavor(
- "m1.medium",
+ "orchestra",
"4096",
'20',
'2',
@@ -129,13 +176,14 @@ class ImsVnf(vnf_base.VnfOnBoardingBase):
self.logger.error("Cannot create floating IP.")
userdata = "#!/bin/bash\n"
+ userdata += "echo \"Executing userdata...\"\n"
userdata += "set -x\n"
userdata += "set -e\n"
+ userdata += "echo \"Set nameserver to '8.8.8.8'...\"\n"
userdata += "echo \"nameserver 8.8.8.8\" >> /etc/resolv.conf\n"
+ userdata += "echo \"Install curl...\"\n"
userdata += "apt-get install curl\n"
- userdata += ("echo \"rabbitmq_broker_ip=%s\" > ./config_file\n"
- % floatip)
- userdata += "echo \"mysql=no\" >> ./config_file\n"
+ userdata += "echo \"Inject public key...\"\n"
userdata += ("echo \"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCuPXrV3"
"geeHc6QUdyUr/1Z+yQiqLcOskiEGBiXr4z76MK4abiFmDZ18OMQlc"
"fl0p3kS0WynVgyaOHwZkgy/DIoIplONVr2CKBKHtPK+Qcme2PVnCtv"
@@ -145,17 +193,30 @@ class ImsVnf(vnf_base.VnfOnBoardingBase):
"7YAdalAnyD/jwCHuwIrUw/lxo7UdNCmaUxeobEYyyFA1YVXzpNFZya"
"XPGAAYIJwEq/ openbaton@opnfv\" >> /home/ubuntu/.ssh/aut"
"horized_keys\n")
- userdata += "cat ./config_file\n"
- userdata += ("curl -s http://get.openbaton.org/bootstrap "
- "> ./bootstrap\n")
+ userdata += "echo \"Download bootstrap...\"\n"
+ userdata += ("curl -s %s "
+ "> ./bootstrap\n" % self.bootstrap_link)
+ userdata += ("curl -s %s"
+ "> ./config_file\n" % self.bootstrap_config_link)
+ userdata += ("echo \"Disable usage of mysql...\"\n")
+ userdata += "sed -i s/mysql=.*/mysql=no/g /config_file\n"
+ userdata += ("echo \"Setting 'rabbitmq_broker_ip' to '%s'\"\n"
+ % floatip)
+ userdata += ("sed -i s/rabbitmq_broker_ip=localhost/rabbitmq_broker_ip"
+ "=%s/g /config_file\n" % floatip)
+ userdata += "echo \"Set autostart of components to 'false'\"\n"
userdata += "export OPENBATON_COMPONENT_AUTOSTART=false\n"
+ userdata += "echo \"Execute bootstrap...\"\n"
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\" >> "
"/etc/openbaton/openbaton-nfvo.properties\n")
+ userdata += "echo \"Starting NFVO\"\n"
userdata += "service openbaton-nfvo restart\n"
+ userdata += "echo \"Starting Generic VNFM\"\n"
userdata += "service openbaton-vnfm-generic restart\n"
+ userdata += "echo \"...end of userdata...\"\n"
sg_id = os_utils.create_security_group_full(neutron_client,
"orchestra-sec-group",
@@ -200,22 +261,22 @@ class ImsVnf(vnf_base.VnfOnBoardingBase):
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.logger.error("Cannot associate floating IP to VM.")
self.step_failure("Cannot associate floating IP to VM.")
- self.logger.info("Waiting for nfvo to be up and running...")
+ self.logger.info("Waiting for Open Baton NFVO to be up and running...")
x = 0
while x < 100:
if servertest(floatip, "8080"):
break
else:
- self.logger.debug("openbaton is not started yet")
+ self.logger.debug(
+ "Open Baton NFVO is not started yet (%ss)" %
+ (x * 5))
time.sleep(5)
x += 1
if x == 100:
- self.logger.error("Openbaton is not started correctly")
- self.step_failure("Openbaton is not started correctly")
+ self.step_failure("Open Baton is not started correctly")
self.ob_ip = floatip
self.ob_password = "openbaton"
@@ -223,10 +284,10 @@ class ImsVnf(vnf_base.VnfOnBoardingBase):
self.ob_https = False
self.ob_port = "8080"
- self.logger.info("Deploy orchestrator: OK")
+ self.logger.info("Deploy Open Baton NFVO: OK")
def deploy_vnf(self):
- self.logger.info("vIMS Deployment")
+ self.logger.info("Starting vIMS Deployment...")
self.main_agent = MainAgent(nfvo_ip=self.ob_ip,
nfvo_port=self.ob_port,
@@ -235,15 +296,16 @@ class ImsVnf(vnf_base.VnfOnBoardingBase):
username=self.ob_username,
password=self.ob_password)
+ 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)
break
self.logger.debug("project id: %s" % self.ob_projectid)
if self.ob_projectid == "":
- self.logger.error("Default project id was not found!")
self.step_failure("Default project id was not found!")
vim_json = {
@@ -252,9 +314,6 @@ class ImsVnf(vnf_base.VnfOnBoardingBase):
"tenant": os_utils.get_credentials().get("tenant_name"),
"username": os_utils.get_credentials().get("username"),
"password": os_utils.get_credentials().get("password"),
- "keyPair": "opnfv",
- # TODO change the keypair to correct value
- # or upload a correct one or remove it
"securityGroups": [
"default",
"orchestra-sec-group"
@@ -267,7 +326,7 @@ class ImsVnf(vnf_base.VnfOnBoardingBase):
}
}
- self.logger.debug("vim: %s" % vim_json)
+ self.logger.debug("Registering VIM: %s" % vim_json)
self.main_agent.get_agent(
"vim",
@@ -280,7 +339,7 @@ class ImsVnf(vnf_base.VnfOnBoardingBase):
try:
self.logger.info("sending: %s" % self.market_link)
nsd = market_agent.create(entity=self.market_link)
- self.logger.info("Onboarded nsd: " + nsd.get("name"))
+ self.logger.info("Onboarded NSD: " + nsd.get("name"))
except NfvoException as e:
self.step_failure(e.message)
@@ -290,34 +349,77 @@ class ImsVnf(vnf_base.VnfOnBoardingBase):
if nsd_id is None:
self.step_failure("NSD not onboarded correctly")
- nsr = None
try:
- nsr = nsr_agent.create(nsd_id)
+ self.nsr = nsr_agent.create(nsd_id)
except NfvoException as e:
self.step_failure(e.message)
- if nsr is None:
- self.step_failure("NSR not deployed correctly")
+ 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")
i = 0
- self.logger.info("waiting NSR to go to active...")
- while nsr.get("status") != 'ACTIVE':
+ self.logger.info("Waiting for NSR to go to ACTIVE...")
+ while self.nsr.get("status") != 'ACTIVE' and self.nsr.get(
+ "status") != 'ERROR':
i += 1
- if i == 100:
- self.step_failure("After %s sec the nsr did not go to active.."
- % 5 * 100)
+ if i == 150:
+ self.step_failure("After %s sec the NSR did not go to ACTIVE.."
+ % 5 * i)
time.sleep(5)
- nsr = json.loads(nsr_agent.find(nsr.get('id')))
+ self.nsr = json.loads(nsr_agent.find(self.nsr.get('id')))
- deploy_vnf = {'status': "PASS", 'result': nsr}
- self.ob_nsr_id = nsr.get("id")
- self.logger.info("Deploy VNF: OK")
+ if self.nsr.get("status") == 'ACTIVE':
+ deploy_vnf = {'status': "PASS", 'result': self.nsr}
+ self.logger.info("Deploy VNF: OK")
+ else:
+ deploy_vnf = {'status': "FAIL", 'result': 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
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'))
+ 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')))
+ for vdu in vnfr.get('vdu'):
+ for vnfci in vdu.get('vnfc_instance'):
+ self.logger.debug(
+ "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')))
+ 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))
+ else:
+ self.logger.error(
+ "VNFC instance %s is not reachable "
+ "at %s:%s" % (vnfci.get('hostname'),
+ floatingIp.get('ip'), port))
+ self.step_failure("Test VNF: ERROR")
+ self.logger.info("Test VNF: OK")
return
def clean(self):
@@ -349,42 +451,5 @@ if __name__ == '__main__':
test = ImsVnf()
test.deploy_orchestrator()
test.deploy_vnf()
+ test.test_vnf()
test.clean()
-
-
-# ----------------------------------------------------------
-#
-# UTILS
-#
-# -----------------------------------------------------------
-def get_config(parameter, file):
- """
- Returns the value of a given parameter in file.yaml
- parameter must be given in string format with dots
- Example: general.openstack.image_name
- """
- with open(file) as f:
- file_yaml = yaml.safe_load(f)
- f.close()
- value = file_yaml
- for element in parameter.split("."):
- value = value.get(element)
- if value is None:
- 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/orchestra_ims.yaml b/functest/opnfv_tests/vnf/ims/orchestra_ims.yaml
index 2fb33df5..86d6e604 100644
--- a/functest/opnfv_tests/vnf/ims/orchestra_ims.yaml
+++ b/functest/opnfv_tests/vnf/ims/orchestra_ims.yaml
@@ -2,6 +2,18 @@ tenant_images:
ubuntu_14.04: http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img
openims: http://marketplace.openbaton.org:8082/api/v1/images/52e2ccc0-1dce-4663-894d-28aab49323aa/img
openbaton:
- bootstrap: sh <(curl -s http://get.openbaton.org/bootstrap) release -configFile=
+ bootstrap_link: http://get.openbaton.org/bootstrap
+ bootstrap_config_link: http://get.openbaton.org/bootstrap-config-file
marketplace_link: http://marketplace.openbaton.org:8082/api/v1/nsds/fokus/OpenImsCore/3.2.0/json
imagename: ubuntu_14.04
+vIMS:
+ scscf:
+ ports: [3870, 6060]
+ pcscf:
+ ports: [4060]
+ icscf:
+ ports: [3869, 5060]
+ fhoss:
+ ports: [3868]
+ bind9:
+ ports: [] \ No newline at end of file