aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests
diff options
context:
space:
mode:
Diffstat (limited to 'functest/opnfv_tests')
-rwxr-xr-xfunctest/opnfv_tests/features/copper.py2
-rwxr-xr-xfunctest/opnfv_tests/features/domino.py65
-rw-r--r--functest/opnfv_tests/features/odl_sfc.py4
-rwxr-xr-xfunctest/opnfv_tests/features/sdnvpn.py70
-rwxr-xr-xfunctest/opnfv_tests/mano/orchestra.py24
-rwxr-xr-xfunctest/opnfv_tests/openstack/examples/create_instance_and_ip.py28
-rwxr-xr-xfunctest/opnfv_tests/openstack/healthcheck/healthcheck.sh5
-rwxr-xr-xfunctest/opnfv_tests/openstack/rally/run_rally-cert.py70
-rw-r--r--functest/opnfv_tests/openstack/snaps/api_check.py18
-rw-r--r--functest/opnfv_tests/openstack/snaps/connection_check.py18
-rw-r--r--functest/opnfv_tests/openstack/snaps/smoke.py22
-rw-r--r--functest/opnfv_tests/openstack/snaps/snaps_utils.py5
-rw-r--r--functest/opnfv_tests/openstack/tempest/conf_utils.py86
-rw-r--r--functest/opnfv_tests/openstack/tempest/tempest.py304
-rw-r--r--functest/opnfv_tests/openstack/vping/vping_base.py45
-rwxr-xr-xfunctest/opnfv_tests/sdn/odl/odl.py91
-rwxr-xr-xfunctest/opnfv_tests/sdn/onos/teston/onos.py16
-rw-r--r--functest/opnfv_tests/vnf/aaa/__init__.py0
-rw-r--r--functest/opnfv_tests/vnf/aaa/aaa.py70
-rw-r--r--functest/opnfv_tests/vnf/ims/__init__.py0
-rw-r--r--functest/opnfv_tests/vnf/ims/cloudify_ims.py278
-rw-r--r--functest/opnfv_tests/vnf/ims/opera_ims.py155
-rw-r--r--functest/opnfv_tests/vnf/ims/orchestra_ims.py157
-rw-r--r--functest/opnfv_tests/vnf/ims/orchestrator_cloudify.py (renamed from functest/opnfv_tests/vnf/ims/orchestrator.py)0
-rwxr-xr-xfunctest/opnfv_tests/vnf/ims/vims.py521
25 files changed, 1097 insertions, 957 deletions
diff --git a/functest/opnfv_tests/features/copper.py b/functest/opnfv_tests/features/copper.py
index 8d5393c9..a10364e2 100755
--- a/functest/opnfv_tests/features/copper.py
+++ b/functest/opnfv_tests/features/copper.py
@@ -22,4 +22,4 @@ class Copper(base.FeatureBase):
super(Copper, self).__init__(project='copper',
case='copper-notification',
repo='dir_repo_copper')
- self.cmd = "%s/tests/run.sh %s/tests" % (self.repo, self.repo)
+ self.cmd = 'bash %s/tests/run.sh' % self.repo
diff --git a/functest/opnfv_tests/features/domino.py b/functest/opnfv_tests/features/domino.py
index 341648f4..b36220fa 100755
--- a/functest/opnfv_tests/features/domino.py
+++ b/functest/opnfv_tests/features/domino.py
@@ -14,65 +14,12 @@
# 0.3: add report flag to push results when needed
# 0.4: refactoring to match Test abstraction class
-import argparse
-import os
-import sys
-import time
+import functest.core.feature_base as base
-import functest.core.testcase_base as testcase_base
-import functest.utils.functest_constants as ft_constants
-import functest.utils.functest_logger as ft_logger
-import functest.utils.functest_utils as ft_utils
-
-
-class DominoCases(testcase_base.TestcaseBase):
- DOMINO_REPO = ft_constants.DOMINO_REPO_DIR
- RESULTS_DIR = ft_constants.FUNCTEST_RESULTS_DIR
- logger = ft_logger.Logger("domino").getLogger()
+class Domino(base.FeatureBase):
def __init__(self):
- super(DominoCases, self).__init__()
- self.project_name = "domino"
- self.case_name = "domino-multinode"
-
- def main(self, **kwargs):
- cmd = 'cd %s && ./tests/run_multinode.sh' % self.DOMINO_REPO
- log_file = os.path.join(self.RESULTS_DIR, "domino.log")
- start_time = time.time()
-
- ret = ft_utils.execute_command(cmd,
- output_file=log_file)
-
- stop_time = time.time()
- if ret == 0:
- self.logger.info("domino OK")
- status = 'PASS'
- else:
- self.logger.info("domino FAILED")
- status = "FAIL"
-
- # report status only if tests run (FAIL OR PASS)
- self.criteria = status
- self.start_time = start_time
- self.stop_time = stop_time
- self.details = {}
-
- def run(self):
- kwargs = {}
- return self.main(**kwargs)
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser()
- parser.add_argument("-r", "--report",
- help="Create json result file",
- action="store_true")
- args = vars(parser.parse_args())
- domino = DominoCases()
- try:
- result = domino.main(**args)
- if result != testcase_base.TestcaseBase.EX_OK:
- sys.exit(result)
- if args['report']:
- sys.exit(domino.push_to_db())
- except Exception:
- sys.exit(testcase_base.TestcaseBase.EX_RUN_ERROR)
+ super(Domino, self).__init__(project='domino',
+ case='domino-multinode',
+ repo='dir_repo_domino')
+ self.cmd = 'cd %s && ./tests/run_multinode.sh' % self.repo
diff --git a/functest/opnfv_tests/features/odl_sfc.py b/functest/opnfv_tests/features/odl_sfc.py
index b194b284..3b68d420 100644
--- a/functest/opnfv_tests/features/odl_sfc.py
+++ b/functest/opnfv_tests/features/odl_sfc.py
@@ -7,7 +7,6 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
#
-
import functest.core.feature_base as base
@@ -17,4 +16,5 @@ class OpenDaylightSFC(base.FeatureBase):
super(OpenDaylightSFC, self).__init__(project='sfc',
case='functest-odl-sfc"',
repo='dir_repo_sfc')
- self.cmd = 'cd %s/tests/functest && python ./run_tests.py' % self.repo
+ 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/sdnvpn.py b/functest/opnfv_tests/features/sdnvpn.py
index 451299eb..1919a03c 100755
--- a/functest/opnfv_tests/features/sdnvpn.py
+++ b/functest/opnfv_tests/features/sdnvpn.py
@@ -7,70 +7,14 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
#
+import functest.core.feature_base as base
-import argparse
-import os
-import sys
-import time
-
-import functest.core.testcase_base as testcase_base
-import functest.utils.functest_constants as ft_constants
-import functest.utils.functest_logger as ft_logger
-import functest.utils.functest_utils as ft_utils
-
-
-class SdnVpnTests(testcase_base.TestcaseBase):
- SDNVPN_REPO_TESTS = os.path.join(
- ft_constants.SDNVPN_REPO_DIR, "tests/functest")
- logger = ft_logger.Logger("sdnvpn").getLogger()
+class SdnVpnTests(base.FeatureBase):
def __init__(self):
- super(SdnVpnTests, self).__init__()
- self.project_name = "sdnvpn"
- self.case_name = "bgpvpn"
-
- def main(self, **kwargs):
- os.chdir(self.SDNVPN_REPO_TESTS)
- cmd = 'run_tests.py'
- log_file = os.path.join(
- ft_constants.FUNCTEST_RESULTS_DIR, "sdnvpn.log")
- start_time = time.time()
-
- ret = ft_utils.execute_command(cmd,
- output_file=log_file)
-
- stop_time = time.time()
- if ret == 0:
- self.logger.info("%s OK" % self.case_name)
- status = 'PASS'
- else:
- self.logger.info("%s FAILED" % self.case_name)
- status = "FAIL"
-
- # report status only if tests run (FAIL OR PASS)
- self.criteria = status
- self.start_time = start_time
- self.stop_time = stop_time
- self.details = {}
-
- def run(self):
- kwargs = {}
- return self.main(**kwargs)
-
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser()
- parser.add_argument("-r", "--report",
- help="Create json result file",
- action="store_true")
- args = vars(parser.parse_args())
- sdnvpn = SdnVpnTests()
- try:
- result = sdnvpn.main(**args)
- if result != testcase_base.TestcaseBase.EX_OK:
- sys.exit(result)
- if args['report']:
- sys.exit(sdnvpn.push_to_db())
- except Exception:
- sys.exit(testcase_base.TestcaseBase.EX_RUN_ERROR)
+ super(SdnVpnTests, self).__init__(project='sdnvpn',
+ case='bgpvpn',
+ 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/mano/orchestra.py b/functest/opnfv_tests/mano/orchestra.py
new file mode 100755
index 00000000..fd5e40d0
--- /dev/null
+++ b/functest/opnfv_tests/mano/orchestra.py
@@ -0,0 +1,24 @@
+#!/usr/bin/python
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+import functest.core.feature_base as base
+
+
+class Orchestra(base.FeatureBase):
+ def __init__(self):
+ super(Orchestra, self).__init__(project='orchestra',
+ case='orchestra',
+ repo='dir_repo_orchestra')
+ # TODO
+ # self.cmd = "%s/tests/run.sh %s/tests" % (self.repo, self.repo)
diff --git a/functest/opnfv_tests/openstack/examples/create_instance_and_ip.py b/functest/opnfv_tests/openstack/examples/create_instance_and_ip.py
index 4a9ff713..b4400864 100755
--- a/functest/opnfv_tests/openstack/examples/create_instance_and_ip.py
+++ b/functest/opnfv_tests/openstack/examples/create_instance_and_ip.py
@@ -14,9 +14,9 @@ import argparse
import os
import sys
+from functest.utils.constants import CONST
import functest.utils.functest_logger as ft_logger
import functest.utils.openstack_utils as os_utils
-import functest.utils.functest_constants as ft_constants
parser = argparse.ArgumentParser()
@@ -29,26 +29,26 @@ args = parser.parse_args()
""" logging configuration """
logger = ft_logger.Logger("create_instance_and_ip").getLogger()
-HOME = ft_constants.HOME + "/"
+HOME = CONST.dir_home + "/"
VM_BOOT_TIMEOUT = 180
-EXAMPLE_INSTANCE_NAME = ft_constants.EXAMPLE_INSTANCE_NAME
-EXAMPLE_FLAVOR = ft_constants.EXAMPLE_FLAVOR
-EXAMPLE_IMAGE_NAME = ft_constants.EXAMPLE_IMAGE_NAME
-IMAGE_FILENAME = ft_constants.GLANCE_IMAGE_FILENAME
-IMAGE_FORMAT = ft_constants.GLANCE_IMAGE_FORMAT
-IMAGE_PATH = os.path.join(ft_constants.FUNCTEST_DATA_DIR, IMAGE_FILENAME)
+EXAMPLE_INSTANCE_NAME = CONST.example_vm_name
+EXAMPLE_FLAVOR = CONST.example_flavor
+EXAMPLE_IMAGE_NAME = CONST.example_image_name
+IMAGE_FILENAME = CONST.openstack_image_file_name
+IMAGE_FORMAT = CONST.openstack_image_disk_format
+IMAGE_PATH = os.path.join(CONST.dir_functest_data, IMAGE_FILENAME)
# NEUTRON Private Network parameters
-EXAMPLE_PRIVATE_NET_NAME = ft_constants.EXAMPLE_PRIVATE_NET_NAME
-EXAMPLE_PRIVATE_SUBNET_NAME = ft_constants.EXAMPLE_PRIVATE_SUBNET_NAME
-EXAMPLE_PRIVATE_SUBNET_CIDR = ft_constants.EXAMPLE_PRIVATE_SUBNET_CIDR
-EXAMPLE_ROUTER_NAME = ft_constants.EXAMPLE_ROUTER_NAME
+EXAMPLE_PRIVATE_NET_NAME = CONST.example_private_net_name
+EXAMPLE_PRIVATE_SUBNET_NAME = CONST.example_private_subnet_name
+EXAMPLE_PRIVATE_SUBNET_CIDR = CONST.example_private_subnet_cidr
+EXAMPLE_ROUTER_NAME = CONST.example_router_name
-EXAMPLE_SECGROUP_NAME = ft_constants.EXAMPLE_SECGROUP_NAME
-EXAMPLE_SECGROUP_DESCR = ft_constants.EXAMPLE_SECGROUP_DESCR
+EXAMPLE_SECGROUP_NAME = CONST.example_sg_name
+EXAMPLE_SECGROUP_DESCR = CONST.example_sg_desc
def main():
diff --git a/functest/opnfv_tests/openstack/healthcheck/healthcheck.sh b/functest/opnfv_tests/openstack/healthcheck/healthcheck.sh
index e27cf4b4..57aa0c70 100755
--- a/functest/opnfv_tests/openstack/healthcheck/healthcheck.sh
+++ b/functest/opnfv_tests/openstack/healthcheck/healthcheck.sh
@@ -228,10 +228,11 @@ sleep ${wait_time}
# Check if flavor exists
-if [[ -z $(nova flavor-list|grep $flavor) ]]; then
+if [[ -z $(openstack flavor list -f value -c Name | fgrep -x $flavor) ]]; then
# if given flavor doesn't exist, we create one
debug "Flavor $flavor doesn't exist. Creating a new flavor."
- nova flavor-create --is-public false ${flavor} auto 512 1 1 --is-public True
+ openstack flavor create ${flavor} --id auto --ram 512 --disk 1 --vcpus 1
+ openstack flavor set ${flavor} --property hw:mem_page_size=any
fi
debug "Using flavor $flavor to boot the instances."
diff --git a/functest/opnfv_tests/openstack/rally/run_rally-cert.py b/functest/opnfv_tests/openstack/rally/run_rally-cert.py
index 6d8f0160..b02fd427 100755
--- a/functest/opnfv_tests/openstack/rally/run_rally-cert.py
+++ b/functest/opnfv_tests/openstack/rally/run_rally-cert.py
@@ -1,34 +1,27 @@
-#!/usr/bin/env python
+#!/usr/bin/python
#
-# Copyright (c) 2015 Orange
-# guyrodrigue.koffi@orange.com
-# morgan.richomme@orange.com
-# All rights reserved. This program and the accompanying materials
+# Copyright (c) 2015 All rights reserved
+# This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
#
-# 0.1 (05/2015) initial commit
-# 0.2 (28/09/2015) extract Tempest, format json result, add ceilometer suite
-# 0.3 (19/10/2015) remove Tempest from run_rally
-# and push result into test DB
+# http://www.apache.org/licenses/LICENSE-2.0
#
-""" tests configuration """
+import argparse
import json
import os
import re
import subprocess
import time
-import argparse
import iniparse
import yaml
+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 os_utils
-import functest.utils.functest_constants as ft_constants
tests = ['authenticate', 'glance', 'cinder', 'heat', 'keystone',
'neutron', 'nova', 'quotas', 'requests', 'vm', 'all']
@@ -71,8 +64,7 @@ else:
""" logging configuration """
logger = ft_logger.Logger("run_rally-cert").getLogger()
-RALLY_DIR = os.path.join(ft_constants.FUNCTEST_REPO_DIR,
- ft_constants.RALLY_RELATIVE_PATH)
+RALLY_DIR = os.path.join(CONST.dir_repo_functest, CONST.dir_rally)
RALLY_SCENARIO_DIR = os.path.join(RALLY_DIR, "scenario")
SANITY_MODE_DIR = os.path.join(RALLY_SCENARIO_DIR, "sanity")
FULL_MODE_DIR = os.path.join(RALLY_SCENARIO_DIR, "full")
@@ -87,19 +79,19 @@ TENANTS_AMOUNT = 3
ITERATIONS_AMOUNT = 10
CONCURRENCY = 4
-RESULTS_DIR = os.path.join(ft_constants.FUNCTEST_RESULTS_DIR, 'rally')
-TEMPEST_CONF_FILE = os.path.join(ft_constants.FUNCTEST_RESULTS_DIR,
+RESULTS_DIR = os.path.join(CONST.dir_results, 'rally')
+TEMPEST_CONF_FILE = os.path.join(CONST.dir_results,
'tempest/tempest.conf')
-RALLY_PRIVATE_NET_NAME = ft_constants.RALLY_PRIVATE_NET_NAME
-RALLY_PRIVATE_SUBNET_NAME = ft_constants.RALLY_PRIVATE_SUBNET_NAME
-RALLY_PRIVATE_SUBNET_CIDR = ft_constants.RALLY_PRIVATE_SUBNET_CIDR
-RALLY_ROUTER_NAME = ft_constants.RALLY_ROUTER_NAME
+RALLY_PRIVATE_NET_NAME = CONST.rally_network_name
+RALLY_PRIVATE_SUBNET_NAME = CONST.rally_subnet_name
+RALLY_PRIVATE_SUBNET_CIDR = CONST.rally_subnet_cidr
+RALLY_ROUTER_NAME = CONST.rally_router_name
-GLANCE_IMAGE_NAME = ft_constants.GLANCE_IMAGE_NAME
-GLANCE_IMAGE_FILENAME = ft_constants.GLANCE_IMAGE_FILENAME
-GLANCE_IMAGE_FORMAT = ft_constants.GLANCE_IMAGE_FORMAT
-GLANCE_IMAGE_PATH = os.path.join(ft_constants.FUNCTEST_DATA_DIR,
+GLANCE_IMAGE_NAME = CONST.openstack_image_name
+GLANCE_IMAGE_FILENAME = CONST.openstack_image_file_name
+GLANCE_IMAGE_FORMAT = CONST.openstack_image_disk_format
+GLANCE_IMAGE_PATH = os.path.join(CONST.dir_functest_data,
GLANCE_IMAGE_FILENAME)
CINDER_VOLUME_TYPE_NAME = "volume_test"
@@ -181,7 +173,7 @@ def build_task_args(test_file_name):
net_id = GlobalVariables.network_dict['net_id']
task_args['netid'] = str(net_id)
- auth_url = ft_constants.OS_AUTH_URL
+ auth_url = CONST.OS_AUTH_URL
if auth_url is not None:
task_args['request_url'] = auth_url.rsplit(":", 1)[0]
else:
@@ -271,8 +263,8 @@ def excl_scenario():
with open(BLACKLIST_FILE, 'r') as black_list_file:
black_list_yaml = yaml.safe_load(black_list_file)
- installer_type = ft_constants.CI_INSTALLER_TYPE
- deploy_scenario = ft_constants.CI_SCENARIO
+ installer_type = CONST.INSTALLER_TYPE
+ deploy_scenario = CONST.DEPLOY_SCENARIO
if (bool(installer_type) * bool(deploy_scenario)):
if 'scenario' in black_list_yaml.keys():
for item in black_list_yaml['scenario']:
@@ -392,10 +384,11 @@ def run_task(test_name):
logger.info('No tests for scenario "{}"'.format(test_name))
return
- cmd_line = ("rally task start --abort-on-sla-failure " +
- "--task {} ".format(task_file) +
- "--task-args \"{}\" ".format(build_task_args(test_name)))
- logger.debug('running command line : {}'.format(cmd_line))
+ cmd_line = ("rally task start --abort-on-sla-failure "
+ "--task {0} "
+ "--task-args \"{1}\""
+ .format(task_file, build_task_args(test_name)))
+ logger.debug('running command line: {}'.format(cmd_line))
p = subprocess.Popen(cmd_line, stdout=subprocess.PIPE,
stderr=RALLY_STDERR, shell=True)
@@ -405,10 +398,11 @@ def run_task(test_name):
if task_id is None:
logger.error('Failed to retrieve task_id, validating task...')
- cmd_line = ("rally task validate " +
- "--task {} ".format(task_file) +
- "--task-args \"{}\" ".format(build_task_args(test_name)))
- logger.debug('running command line : {}'.format(cmd_line))
+ cmd_line = ("rally task validate "
+ "--task {0} "
+ "--task-args \"{1}\""
+ .format(task_file, build_task_args(test_name)))
+ logger.debug('running command line: {}'.format(cmd_line))
p = subprocess.Popen(cmd_line, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, shell=True)
output = get_cmd_output(p)
@@ -426,12 +420,12 @@ def run_task(test_name):
cmd_line = "rally task report {} --out {}".format(task_id,
report_html_dir)
- logger.debug('running command line : {}'.format(cmd_line))
+ logger.debug('running command line: {}'.format(cmd_line))
os.popen(cmd_line)
# get and save rally operation JSON result
cmd_line = "rally task results %s" % task_id
- logger.debug('running command line : {}'.format(cmd_line))
+ logger.debug('running command line: {}'.format(cmd_line))
cmd = os.popen(cmd_line)
json_results = cmd.read()
report_json_name = 'opnfv-{}.json'.format(test_name)
diff --git a/functest/opnfv_tests/openstack/snaps/api_check.py b/functest/opnfv_tests/openstack/snaps/api_check.py
index 27889209..17d05b92 100644
--- a/functest/opnfv_tests/openstack/snaps/api_check.py
+++ b/functest/opnfv_tests/openstack/snaps/api_check.py
@@ -5,11 +5,13 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
-import functest.utils.functest_utils as ft_utils
+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 snaps import test_suite_builder
-import unittest
+from functest.utils.constants import CONST
class ApiCheck(PyTestSuiteRunner):
@@ -23,10 +25,10 @@ class ApiCheck(PyTestSuiteRunner):
self.suite = unittest.TestSuite()
self.case_name = "api_check"
- creds_file = ft_utils.get_functest_config('general.openstack.creds')
- use_key = ft_utils.get_functest_config('snaps.use_keystone')
ext_net_name = snaps_utils.get_ext_net_name()
- test_suite_builder.add_openstack_api_tests(self.suite, creds_file,
- ext_net_name,
- use_keystone=use_key)
+ test_suite_builder.add_openstack_api_tests(
+ self.suite,
+ CONST.openstack_creds,
+ 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 c2f5b102..11f8ad07 100644
--- a/functest/opnfv_tests/openstack/snaps/connection_check.py
+++ b/functest/opnfv_tests/openstack/snaps/connection_check.py
@@ -5,11 +5,13 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
-import functest.utils.functest_utils as ft_utils
+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 snaps import test_suite_builder
-import unittest
+from functest.utils.constants import CONST
class ConnectionCheck(PyTestSuiteRunner):
@@ -23,10 +25,10 @@ class ConnectionCheck(PyTestSuiteRunner):
self.suite = unittest.TestSuite()
self.case_name = "connection_check"
- creds_file = ft_utils.get_functest_config('general.openstack.creds')
- use_key = ft_utils.get_functest_config('snaps.use_keystone')
ext_net_name = snaps_utils.get_ext_net_name()
- test_suite_builder.add_openstack_client_tests(self.suite, creds_file,
- ext_net_name,
- use_keystone=use_key)
+ test_suite_builder.add_openstack_client_tests(
+ self.suite,
+ CONST.openstack_creds,
+ ext_net_name,
+ use_keystone=CONST.snaps_use_keystone)
diff --git a/functest/opnfv_tests/openstack/snaps/smoke.py b/functest/opnfv_tests/openstack/snaps/smoke.py
index f66c17ff..83eb6600 100644
--- a/functest/opnfv_tests/openstack/snaps/smoke.py
+++ b/functest/opnfv_tests/openstack/snaps/smoke.py
@@ -5,12 +5,14 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
-import functest.utils.functest_utils as ft_utils
+import os
+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 snaps import test_suite_builder
-import unittest
-import os
+from functest.utils.constants import CONST
class SnapsSmoke(PyTestSuiteRunner):
@@ -24,18 +26,18 @@ class SnapsSmoke(PyTestSuiteRunner):
self.suite = unittest.TestSuite()
self.case_name = "snaps_smoke"
- creds_file = ft_utils.get_functest_config('general.openstack.creds')
- use_key = ft_utils.get_functest_config('snaps.use_keystone')
- use_fip = ft_utils.get_functest_config('snaps.use_floating_ips')
+ use_fip = CONST.snaps_use_floating_ips
ext_net_name = snaps_utils.get_ext_net_name()
# Tests requiring floating IPs leverage files contained within the
# SNAPS repository and are found relative to that path
if use_fip:
- snaps_dir = ft_utils.get_functest_config(
- 'general.directories.dir_repo_snaps') + '/snaps'
+ snaps_dir = CONST.dir_repo_snaps + '/snaps'
os.chdir(snaps_dir)
test_suite_builder.add_openstack_integration_tests(
- self.suite, creds_file, ext_net_name, use_keystone=use_key,
+ self.suite,
+ CONST.openstack_creds,
+ ext_net_name,
+ use_keystone=CONST.snaps_use_keystone,
use_floating_ips=use_fip)
diff --git a/functest/opnfv_tests/openstack/snaps/snaps_utils.py b/functest/opnfv_tests/openstack/snaps/snaps_utils.py
index a25ad3e0..4ea1a04a 100644
--- a/functest/opnfv_tests/openstack/snaps/snaps_utils.py
+++ b/functest/opnfv_tests/openstack/snaps/snaps_utils.py
@@ -5,17 +5,18 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
-import functest.utils.functest_utils as ft_utils
from snaps.openstack.tests import openstack_tests
from snaps.openstack.utils import neutron_utils
+from functest.utils.constants import CONST
+
def get_ext_net_name():
"""
Returns the first external network name
:return:
"""
- os_env_file = ft_utils.get_functest_config('general.openstack.creds')
+ os_env_file = CONST.openstack_creds
os_creds = openstack_tests.get_credentials(os_env_file=os_env_file)
neutron = neutron_utils.neutron_client(os_creds)
ext_nets = neutron_utils.get_external_networks(neutron)
diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py
index 38b97e74..67b52796 100644
--- a/functest/opnfv_tests/openstack/tempest/conf_utils.py
+++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py
@@ -12,18 +12,20 @@ import os
import re
import shutil
-import functest.utils.functest_constants as ft_constants
-import functest.utils.functest_utils as ft_utils
import opnfv.utils.constants as releng_constants
+from functest.utils.constants import CONST
+import functest.utils.functest_utils as ft_utils
+import functest.utils.openstack_utils as os_utils
+
IMAGE_ID_ALT = None
FLAVOR_ID_ALT = None
-REPO_PATH = ft_constants.FUNCTEST_REPO_DIR
-GLANCE_IMAGE_PATH = os.path.join(ft_constants.FUNCTEST_DATA_DIR,
- ft_constants.GLANCE_IMAGE_FILENAME)
-TEMPEST_TEST_LIST_DIR = ft_constants.TEMPEST_TEST_LIST_DIR
-TEMPEST_RESULTS_DIR = os.path.join(ft_constants.FUNCTEST_RESULTS_DIR,
+REPO_PATH = CONST.dir_repo_functest
+GLANCE_IMAGE_PATH = os.path.join(CONST.dir_functest_data,
+ CONST.openstack_image_file_name)
+TEMPEST_TEST_LIST_DIR = CONST.dir_tempest_cases
+TEMPEST_RESULTS_DIR = os.path.join(CONST.dir_results,
'tempest')
TEMPEST_CUSTOM = os.path.join(REPO_PATH, TEMPEST_TEST_LIST_DIR,
'test_list.txt')
@@ -34,24 +36,25 @@ TEMPEST_DEFCORE = os.path.join(REPO_PATH, TEMPEST_TEST_LIST_DIR,
TEMPEST_RAW_LIST = os.path.join(TEMPEST_RESULTS_DIR, 'test_raw_list.txt')
TEMPEST_LIST = os.path.join(TEMPEST_RESULTS_DIR, 'test_list.txt')
-CI_INSTALLER_TYPE = ft_constants.CI_INSTALLER_TYPE
-CI_INSTALLER_IP = ft_constants.CI_INSTALLER_IP
+CI_INSTALLER_TYPE = CONST.INSTALLER_TYPE
+CI_INSTALLER_IP = CONST.INSTALLER_IP
def configure_tempest(logger, deployment_dir, IMAGE_ID=None, FLAVOR_ID=None):
"""
Add/update needed parameters into tempest.conf file generated by Rally
"""
- tempest_conf_file = deployment_dir + "/tempest.conf"
+ tempest_conf_file = os.path.join(deployment_dir, "tempest.conf")
if os.path.isfile(tempest_conf_file):
- logger.debug("Deleting old tempest.conf file...")
- os.remove(tempest_conf_file)
-
- logger.debug("Generating new tempest.conf file...")
- cmd = "rally verify genconfig"
+ logger.debug("Verifier is already configured.")
+ logger.debug("Reconfiguring the current verifier...")
+ cmd = "rally verify configure-verifier --reconfigure"
+ else:
+ logger.info("Configuring the verifier...")
+ cmd = "rally verify configure-verifier"
ft_utils.execute_command(cmd)
- logger.debug("Finding tempest.conf file...")
+ logger.debug("Looking for tempest.conf file...")
if not os.path.isfile(tempest_conf_file):
logger.error("Tempest configuration file %s NOT found."
% tempest_conf_file)
@@ -63,24 +66,24 @@ def configure_tempest(logger, deployment_dir, IMAGE_ID=None, FLAVOR_ID=None):
config.set(
'compute',
'fixed_network_name',
- ft_constants.TEMPEST_PRIVATE_NET_NAME)
- if ft_constants.TEMPEST_USE_CUSTOM_IMAGES:
+ CONST.tempest_private_net_name)
+ if CONST.tempest_use_custom_images:
if IMAGE_ID is not None:
config.set('compute', 'image_ref', IMAGE_ID)
if IMAGE_ID_ALT is not None:
config.set('compute', 'image_ref_alt', IMAGE_ID_ALT)
- if ft_constants.TEMPEST_USE_CUSTOM_FLAVORS:
+ if CONST.tempest_use_custom_flavors:
if FLAVOR_ID is not None:
config.set('compute', 'flavor_ref', FLAVOR_ID)
if FLAVOR_ID_ALT is not None:
config.set('compute', 'flavor_ref_alt', FLAVOR_ID_ALT)
- config.set('identity', 'tenant_name', ft_constants.TEMPEST_TENANT_NAME)
- config.set('identity', 'username', ft_constants.TEMPEST_USER_NAME)
- config.set('identity', 'password', ft_constants.TEMPEST_USER_PASSWORD)
+ config.set('identity', 'tenant_name', CONST.tempest_identity_tenant_name)
+ config.set('identity', 'username', CONST.tempest_identity_user_name)
+ config.set('identity', 'password', CONST.tempest_identity_user_password)
config.set(
- 'validation', 'ssh_timeout', ft_constants.TEMPEST_SSH_TIMEOUT)
+ 'validation', 'ssh_timeout', CONST.tempest_validation_ssh_timeout)
- if ft_constants.OS_ENDPOINT_TYPE is not None:
+ if CONST.OS_ENDPOINT_TYPE is not None:
services_list = ['compute',
'volume',
'image',
@@ -93,14 +96,14 @@ def configure_tempest(logger, deployment_dir, IMAGE_ID=None, FLAVOR_ID=None):
if service not in sections:
config.add_section(service)
config.set(service, 'endpoint_type',
- ft_constants.OS_ENDPOINT_TYPE)
+ CONST.OS_ENDPOINT_TYPE)
with open(tempest_conf_file, 'wb') as config_file:
config.write(config_file)
# Copy tempest.conf to /home/opnfv/functest/results/tempest/
- shutil.copyfile(
- tempest_conf_file, TEMPEST_RESULTS_DIR + '/tempest.conf')
+ shutil.copyfile(tempest_conf_file,
+ os.path.join(TEMPEST_RESULTS_DIR, 'tempest.conf'))
return releng_constants.EXIT_OK
@@ -113,7 +116,7 @@ def configure_tempest_multisite(logger, deployment_dir):
configure_tempest(logger, deployment_dir)
logger.debug("Finding tempest.conf file...")
- tempest_conf_old = os.path.join(deployment_dir, '/tempest.conf')
+ tempest_conf_old = os.path.join(deployment_dir, 'tempest.conf')
if not os.path.isfile(tempest_conf_old):
logger.error("Tempest configuration file %s NOT found."
% tempest_conf_old)
@@ -121,7 +124,7 @@ def configure_tempest_multisite(logger, deployment_dir):
# Copy tempest.conf to /home/opnfv/functest/results/tempest/
cur_path = os.path.split(os.path.realpath(__file__))[0]
- tempest_conf_file = os.path.join(cur_path, '/tempest_multisite.conf')
+ tempest_conf_file = os.path.join(cur_path, 'tempest_multisite.conf')
shutil.copyfile(tempest_conf_old, tempest_conf_file)
logger.debug("Updating selected tempest.conf parameters...")
@@ -129,21 +132,21 @@ def configure_tempest_multisite(logger, deployment_dir):
config.read(tempest_conf_file)
config.set('service_available', 'kingbird', 'true')
- cmd = ("openstack endpoint show kingbird | grep publicurl |"
- "awk '{print $4}' | awk -F '/' '{print $4}'")
- kingbird_api_version = os.popen(cmd).read()
+ # cmd = ("openstack endpoint show kingbird | grep publicurl |"
+ # "awk '{print $4}' | awk -F '/' '{print $4}'")
+ # kingbird_api_version = os.popen(cmd).read()
+ kingbird_api_version = os_utils.get_endpoint(service_type='kingbird')
+
if CI_INSTALLER_TYPE == 'fuel':
# For MOS based setup, the service is accessible
# via bind host
kingbird_conf_path = "/etc/kingbird/kingbird.conf"
installer_type = CI_INSTALLER_TYPE
installer_ip = CI_INSTALLER_IP
- installer_username = ft_utils.get_functest_config(
- "multisite." + installer_type +
- "_environment.installer_username")
- installer_password = ft_utils.get_functest_config(
- "multisite." + installer_type +
- "_environment.installer_password")
+ installer_username = CONST.__getattribute__(
+ 'multisite_{}_installer_username'.format(installer_type))
+ installer_password = CONST.__getattribute__(
+ 'multisite_{}_installer_password'.format(installer_type))
ssh_options = ("-o UserKnownHostsFile=/dev/null -o "
"StrictHostKeyChecking=no")
@@ -174,9 +177,10 @@ def configure_tempest_multisite(logger, deployment_dir):
bind_details)[0]
kingbird_endpoint_url = "http://%s:%s/" % (bind_host, bind_port)
else:
- cmd = "openstack endpoint show kingbird | grep publicurl |\
- awk '{print $4}' | awk -F '/' '{print $3}'"
- kingbird_endpoint_url = os.popen(cmd).read()
+ # cmd = "openstack endpoint show kingbird | grep publicurl |\
+ # awk '{print $4}' | awk -F '/' '{print $3}'"
+ # kingbird_endpoint_url = os.popen(cmd).read()
+ kingbird_endpoint_url = os_utils.get_endpoint(service_type='kingbird')
try:
config.add_section("kingbird")
diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py
index ec0ca766..0014b718 100644
--- a/functest/opnfv_tests/openstack/tempest/tempest.py
+++ b/functest/opnfv_tests/openstack/tempest/tempest.py
@@ -16,13 +16,12 @@ import time
import yaml
-import conf_utils
-import functest.core.testcase_base as testcase_base
+from functest.core import testcase_base
+from functest.opnfv_tests.openstack.tempest import conf_utils
+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 os_utils
-import functest.utils.functest_constants as ft_constants
-import opnfv.utils.constants as releng_constants
""" logging configuration """
logger = ft_logger.Logger("Tempest").getLogger()
@@ -31,14 +30,80 @@ logger = ft_logger.Logger("Tempest").getLogger()
class TempestCommon(testcase_base.TestcaseBase):
def __init__(self):
- self.case_name = ""
+ super(TempestCommon, self).__init__()
self.MODE = ""
self.OPTION = ""
self.FLAVOR_ID = None
self.IMAGE_ID = None
- self.DEPLOYMENT_DIR = ft_utils.get_deployment_dir()
-
- def read_file(self, filename):
+ self.VERIFIER_ID = self.get_verifier_id()
+ self.VERIFIER_REPO_DIR = self.get_verifier_repo_dir()
+ self.DEPLOYMENT_ID = self.get_verifier_deployment_id()
+ self.DEPLOYMENT_DIR = self.get_verifier_deployment_dir()
+ self.VERIFICATION_ID = None
+
+ @staticmethod
+ def get_verifier_id():
+ """
+ Returns verifer id for current Tempest
+ """
+ cmd = ("rally verify list-verifiers | awk '/" +
+ CONST.tempest_deployment_name +
+ "/ {print $2}'")
+ p = subprocess.Popen(cmd, shell=True,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ deployment_uuid = p.stdout.readline().rstrip()
+ if deployment_uuid == "":
+ logger.error("Tempest verifier not found.")
+ raise Exception('Error with command:%s' % cmd)
+ return deployment_uuid
+
+ @staticmethod
+ def get_verifier_deployment_id():
+ """
+ Returns deployment id for active Rally deployment
+ """
+ cmd = ("rally deployment list | awk '/" +
+ CONST.rally_deployment_name +
+ "/ {print $2}'")
+ p = subprocess.Popen(cmd, shell=True,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ deployment_uuid = p.stdout.readline().rstrip()
+ if deployment_uuid == "":
+ logger.error("Rally deployment not found.")
+ raise Exception('Error with command:%s' % cmd)
+ return deployment_uuid
+
+ def get_verifier_repo_dir(self):
+ """
+ Returns installed verfier repo directory for Tempest
+ """
+ if not self.VERIFIER_ID:
+ self.VERIFIER_ID = self.get_verifier_id()
+
+ return os.path.join(CONST.dir_rally_inst,
+ 'verification',
+ 'verifier-{}'.format(self.VERIFIER_ID),
+ 'repo')
+
+ def get_verifier_deployment_dir(self):
+ """
+ Returns Rally deployment directory for current verifier
+ """
+ if not self.VERIFIER_ID:
+ self.VERIFIER_ID = self.get_verifier_id()
+
+ if not self.DEPLOYMENT_ID:
+ self.DEPLOYMENT_ID = self.get_verifier_deployment_id()
+
+ return os.path.join(CONST.dir_rally_inst,
+ 'verification',
+ 'verifier-{}'.format(self.VERIFIER_ID),
+ 'for-deployment-{}'.format(self.DEPLOYMENT_ID))
+
+ @staticmethod
+ def read_file(filename):
with open(filename) as src:
return [line.strip() for line in src.readlines()]
@@ -48,53 +113,52 @@ class TempestCommon(testcase_base.TestcaseBase):
logger.debug("Creating tenant and user for Tempest suite")
tenant_id = os_utils.create_tenant(
keystone_client,
- ft_constants.TEMPEST_TENANT_NAME,
- ft_constants.TEMPEST_TENANT_DESCRIPTION)
+ CONST.tempest_identity_tenant_name,
+ CONST.tempest_identity_tenant_description)
if not tenant_id:
logger.error("Error : Failed to create %s tenant"
- % ft_constants.TEMPEST_TENANT_NAME)
+ % CONST.tempest_identity_tenant_name)
user_id = os_utils.create_user(keystone_client,
- ft_constants.TEMPEST_USER_NAME,
- ft_constants.TEMPEST_USER_PASSWORD,
+ CONST.tempest_identity_user_name,
+ CONST.tempest_identity_user_password,
None, tenant_id)
if not user_id:
logger.error("Error : Failed to create %s user" %
- ft_constants.TEMPEST_USER_NAME)
+ CONST.tempest_identity_user_name)
logger.debug("Creating private network for Tempest suite")
- network_dic = \
- os_utils.create_shared_network_full(
- ft_constants.TEMPEST_PRIVATE_NET_NAME,
- ft_constants.TEMPEST_PRIVATE_SUBNET_NAME,
- ft_constants.TEMPEST_ROUTER_NAME,
- ft_constants.TEMPEST_PRIVATE_SUBNET_CIDR)
+ network_dic = os_utils.create_shared_network_full(
+ CONST.tempest_private_net_name,
+ CONST.tempest_private_subnet_name,
+ CONST.tempest_router_name,
+ CONST.tempest_private_subnet_cidr)
if not network_dic:
- return releng_constants.EXIT_RUN_ERROR
+ return testcase_base.TestcaseBase.EX_RUN_ERROR
- if ft_constants.TEMPEST_USE_CUSTOM_IMAGES:
+ if CONST.tempest_use_custom_images:
# adding alternative image should be trivial should we need it
logger.debug("Creating image for Tempest suite")
_, self.IMAGE_ID = os_utils.get_or_create_image(
- ft_constants.GLANCE_IMAGE_NAME, conf_utils.GLANCE_IMAGE_PATH,
- ft_constants.GLANCE_IMAGE_FORMAT)
+ CONST.openstack_image_name, conf_utils.GLANCE_IMAGE_PATH,
+ CONST.openstack_image_disk_format)
if not self.IMAGE_ID:
- return releng_constants.EXIT_RUN_ERROR
+ return testcase_base.TestcaseBase.EX_RUN_ERROR
- if ft_constants.TEMPEST_USE_CUSTOM_FLAVORS:
+ if CONST.tempest_use_custom_flavors:
# adding alternative flavor should be trivial should we need it
logger.debug("Creating flavor for Tempest suite")
_, self.FLAVOR_ID = os_utils.get_or_create_flavor(
- ft_constants.FLAVOR_NAME,
- ft_constants.FLAVOR_RAM,
- ft_constants.FLAVOR_DISK,
- ft_constants.FLAVOR_VCPUS)
+ CONST.openstack_flavor_name,
+ CONST.openstack_flavor_ram,
+ CONST.openstack_flavor_disk,
+ CONST.openstack_flavor_vcpus)
if not self.FLAVOR_ID:
- return releng_constants.EXIT_RUN_ERROR
+ return testcase_base.TestcaseBase.EX_RUN_ERROR
- return releng_constants.EXIT_OK
+ return testcase_base.TestcaseBase.EX_OK
- def generate_test_list(self, DEPLOYMENT_DIR):
+ def generate_test_list(self, verifier_repo_dir):
logger.debug("Generating test case list...")
if self.MODE == 'defcore':
shutil.copyfile(
@@ -106,7 +170,7 @@ class TempestCommon(testcase_base.TestcaseBase):
else:
logger.error("Tempest test list file %s NOT found."
% conf_utils.TEMPEST_CUSTOM)
- return releng_constants.EXIT_RUN_ERROR
+ return testcase_base.TestcaseBase.EX_RUN_ERROR
else:
if self.MODE == 'smoke':
testr_mode = "smoke"
@@ -116,11 +180,14 @@ class TempestCommon(testcase_base.TestcaseBase):
testr_mode = ""
else:
testr_mode = 'tempest.api.' + self.MODE
- cmd = ("cd " + DEPLOYMENT_DIR + ";" + "testr list-tests " +
- testr_mode + ">" + conf_utils.TEMPEST_RAW_LIST + ";cd")
+ cmd = ("cd {0};"
+ "testr list-tests {1} > {2};"
+ "cd -;".format(verifier_repo_dir,
+ testr_mode,
+ conf_utils.TEMPEST_RAW_LIST))
ft_utils.execute_command(cmd)
- return releng_constants.EXIT_OK
+ return testcase_base.TestcaseBase.EX_OK
def apply_tempest_blacklist(self):
logger.debug("Applying tempest blacklist...")
@@ -128,8 +195,8 @@ class TempestCommon(testcase_base.TestcaseBase):
result_file = open(conf_utils.TEMPEST_LIST, 'w')
black_tests = []
try:
- installer_type = ft_constants.CI_INSTALLER_TYPE
- deploy_scenario = ft_constants.CI_SCENARIO
+ installer_type = CONST.INSTALLER_TYPE
+ deploy_scenario = CONST.DEPLOY_SCENARIO
if (bool(installer_type) * bool(deploy_scenario)):
# if INSTALLER_TYPE and DEPLOY_SCENARIO are set we read the
# file
@@ -145,7 +212,7 @@ class TempestCommon(testcase_base.TestcaseBase):
for test in tests:
black_tests.append(test)
break
- except:
+ except Exception:
black_tests = []
logger.debug("Tempest blacklist file does not exist.")
@@ -156,52 +223,35 @@ class TempestCommon(testcase_base.TestcaseBase):
else:
result_file.write(str(cases_line) + '\n')
result_file.close()
- return releng_constants.EXIT_OK
+ return testcase_base.TestcaseBase.EX_OK
- def run(self):
- if not os.path.exists(conf_utils.TEMPEST_RESULTS_DIR):
- os.makedirs(conf_utils.TEMPEST_RESULTS_DIR)
+ def _parse_verification_id(line):
+ first_pos = line.index("UUID=") + len("UUID=")
+ last_pos = line.index(") for deployment")
+ return line[first_pos:last_pos]
- # Pre-configuration
- res = self.create_tempest_resources()
- if res != releng_constants.EXIT_OK:
- return res
+ def run_verifier_tests(self):
+ self.OPTION += (" --load-list {}".format(conf_utils.TEMPEST_LIST))
- res = conf_utils.configure_tempest(logger,
- self.DEPLOYMENT_DIR,
- self.IMAGE_ID,
- self.FLAVOR_ID)
- if res != releng_constants.EXIT_OK:
- return res
-
- res = self.generate_test_list(self.DEPLOYMENT_DIR)
- if res != releng_constants.EXIT_OK:
- return res
-
- res = self.apply_tempest_blacklist()
- if res != releng_constants.EXIT_OK:
- return res
-
- self.OPTION += (" --tests-file %s " % conf_utils.TEMPEST_LIST)
-
- cmd_line = "rally verify start " + self.OPTION + " --system-wide"
+ cmd_line = "rally verify start " + self.OPTION
logger.info("Starting Tempest test suite: '%s'." % cmd_line)
header = ("Tempest environment:\n"
" Installer: %s\n Scenario: %s\n Node: %s\n Date: %s\n" %
- (ft_constants.CI_INSTALLER_TYPE,
- ft_constants.CI_SCENARIO,
- ft_constants.CI_NODE,
+ (CONST.INSTALLER_TYPE,
+ CONST.DEPLOY_SCENARIO,
+ CONST.NODE_NAME,
time.strftime("%a %b %d %H:%M:%S %Z %Y")))
- f_stdout = open(conf_utils.TEMPEST_RESULTS_DIR + "/tempest.log", 'w+')
+ f_stdout = open(
+ os.path.join(conf_utils.TEMPEST_RESULTS_DIR, "tempest.log"), 'w+')
f_stderr = open(
- conf_utils.TEMPEST_RESULTS_DIR + "/tempest-error.log", 'w+')
- f_env = open(conf_utils.TEMPEST_RESULTS_DIR + "/environment.log", 'w+')
+ os.path.join(conf_utils.TEMPEST_RESULTS_DIR,
+ "tempest-error.log"), 'w+')
+ f_env = open(os.path.join(conf_utils.TEMPEST_RESULTS_DIR,
+ "environment.log"), 'w+')
f_env.write(header)
- # subprocess.call(cmd_line, shell=True,
- # stdout=f_stdout, stderr=f_stderr)
p = subprocess.Popen(
cmd_line, shell=True,
stdout=subprocess.PIPE,
@@ -212,6 +262,12 @@ class TempestCommon(testcase_base.TestcaseBase):
for line in iter(p.stdout.readline, b''):
if re.search("\} tempest\.", line):
logger.info(line.replace('\n', ''))
+ elif re.search('Starting verification', line):
+ logger.info(line.replace('\n', ''))
+ first_pos = line.index("UUID=") + len("UUID=")
+ last_pos = line.index(") for deployment")
+ self.VERIFICATION_ID = line[first_pos:last_pos]
+ logger.debug('Verication UUID: %s' % self.VERIFICATION_ID)
f_stdout.write(line)
p.wait()
@@ -219,56 +275,76 @@ class TempestCommon(testcase_base.TestcaseBase):
f_stderr.close()
f_env.close()
- cmd_line = "rally verify show"
- output = ""
+ def parse_verifier_result(self):
+ if not self.VERIFICATION_ID:
+ raise Exception('Verification UUID not found')
+
+ cmd_line = "rally verify show --uuid {}".format(self.VERIFICATION_ID)
+ logger.info("Showing result for a verification: '%s'." % cmd_line)
p = subprocess.Popen(cmd_line,
shell=True,
stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
+ stderr=subprocess.STDOUT)
for line in p.stdout:
- if re.search("Tests\:", line):
+ new_line = line.replace(' ', '').split('|')
+ if 'Tests' in new_line:
break
- output += line
- logger.info(output)
-
- cmd_line = "rally verify list"
- cmd = os.popen(cmd_line)
- output = (((cmd.read()).splitlines()[-2]).replace(" ", "")).split("|")
- # Format:
- # | UUID | Deployment UUID | smoke | tests | failures | Created at |
- # Duration | Status |
- num_tests = output[4]
- num_failures = output[5]
- duration = output[7]
- # Compute duration (lets assume it does not take more than 60 min)
- dur_min = int(duration.split(':')[1])
- dur_sec_float = float(duration.split(':')[2])
- dur_sec_int = int(round(dur_sec_float, 0))
- dur_sec_int = dur_sec_int + 60 * dur_min
+
+ logger.info(line)
+ if 'Testscount' in new_line:
+ num_tests = new_line[2]
+ elif 'Success' in new_line:
+ num_success = new_line[2]
+ elif 'Skipped' in new_line:
+ num_skipped = new_line[2]
try:
- diff = (int(num_tests) - int(num_failures))
- success_rate = 100 * diff / int(num_tests)
- except:
+ num_executed = int(num_tests) - int(num_skipped)
+ success_rate = 100 * int(num_success) / int(num_executed)
+ except Exception:
success_rate = 0
- if 'smoke' in self.MODE:
- self.CASE_NAME = 'tempest_smoke_serial'
- elif 'feature' in self.MODE:
- self.CASE_NAME = self.MODE.replace(
- "feature_", "")
- else:
- self.CASE_NAME = 'tempest_full_parallel'
-
- status = ft_utils.check_success_rate(
- self.CASE_NAME, success_rate)
+ self.criteria = ft_utils.check_success_rate(
+ self.case_name, success_rate)
logger.info("Tempest %s success_rate is %s%%, is marked as %s"
- % (self.CASE_NAME, success_rate, status))
+ % (self.case_name, success_rate, self.criteria))
+
+ def run(self):
+
+ self.start_time = time.time()
+
+ if not os.path.exists(conf_utils.TEMPEST_RESULTS_DIR):
+ os.makedirs(conf_utils.TEMPEST_RESULTS_DIR)
+
+ # Pre-configuration
+ res = self.create_tempest_resources()
+ if res != testcase_base.TestcaseBase.EX_OK:
+ return res
+
+ res = conf_utils.configure_tempest(logger,
+ self.DEPLOYMENT_DIR,
+ self.IMAGE_ID,
+ self.FLAVOR_ID)
+ if res != testcase_base.TestcaseBase.EX_OK:
+ return res
+
+ res = self.generate_test_list(self.VERIFIER_REPO_DIR)
+ if res != testcase_base.TestcaseBase.EX_OK:
+ return res
+
+ res = self.apply_tempest_blacklist()
+ if res != testcase_base.TestcaseBase.EX_OK:
+ return res
+
+ self.run_verifier_tests()
+ self.parse_verifier_result()
+
+ self.stop_time = time.time()
- if status == "PASS":
- return releng_constants.EXIT_OK
+ if self.criteria == "PASS":
+ return testcase_base.TestcaseBase.EX_OK
else:
- return releng_constants.EXIT_RUN_ERROR
+ return testcase_base.TestcaseBase.EX_TESTCASE_FAILED
class TempestSmokeSerial(TempestCommon):
@@ -277,7 +353,7 @@ class TempestSmokeSerial(TempestCommon):
TempestCommon.__init__(self)
self.case_name = "tempest_smoke_serial"
self.MODE = "smoke"
- self.OPTION = "--concur 1"
+ self.OPTION = "--concurrency 1"
class TempestSmokeParallel(TempestCommon):
@@ -303,7 +379,7 @@ class TempestMultisite(TempestCommon):
TempestCommon.__init__(self)
self.case_name = "multisite"
self.MODE = "feature_multisite"
- self.OPTION = "--concur 1"
+ self.OPTION = "--concurrency 1"
conf_utils.configure_tempest_multisite(logger, self.DEPLOYMENT_DIR)
diff --git a/functest/opnfv_tests/openstack/vping/vping_base.py b/functest/opnfv_tests/openstack/vping/vping_base.py
index e467dd9f..8285d93f 100644
--- a/functest/opnfv_tests/openstack/vping/vping_base.py
+++ b/functest/opnfv_tests/openstack/vping/vping_base.py
@@ -12,43 +12,38 @@ import pprint
import time
from datetime import datetime
-import functest.utils.functest_utils as ft_utils
-import functest.utils.functest_constants as ft_constants
-import functest.utils.openstack_utils as os_utils
import functest.core.testcase_base as testcase_base
+import functest.utils.openstack_utils as os_utils
+from functest.utils.constants import CONST
class VPingBase(testcase_base.TestcaseBase):
def __init__(self):
- def get_conf(parameter):
- return ft_utils.get_functest_config(parameter)
-
super(VPingBase, self).__init__()
self.logger = None
- self.functest_repo = ft_constants.FUNCTEST_REPO_DIR
- self.repo = get_conf('general.directories.dir_vping')
- self.vm1_name = get_conf('vping.vm_name_1')
- self.vm2_name = get_conf('vping.vm_name_2')
+ self.functest_repo = CONST.dir_repo_functest
+ self.repo = CONST.dir_vping
+ self.vm1_name = CONST.vping_vm_name_1
+ self.vm2_name = CONST.vping_vm_name_2
self.vm_boot_timeout = 180
self.vm_delete_timeout = 100
- self.ping_timeout = get_conf('vping.ping_timeout')
+ self.ping_timeout = CONST.vping_ping_timeout
- self.image_name = get_conf('vping.image_name')
- self.image_filename = get_conf('general.openstack.image_file_name')
- self.image_format = get_conf('general.openstack.image_disk_format')
- self.image_path = ("%s/%s" %
- (get_conf('general.directories.dir_functest_data'),
- self.image_filename))
+ self.image_name = CONST.vping_image_name
+ self.image_filename = CONST.openstack_image_file_name
+ self.image_format = CONST.openstack_image_disk_format
+ self.image_path = os.path.join(CONST.dir_functest_data,
+ self.image_filename)
- self.flavor_name = get_conf('vping.vm_flavor')
+ self.flavor_name = CONST.vping_vm_flavor
# NEUTRON Private Network parameters
- self.private_net_name = get_conf('vping.vping_private_net_name')
- self.private_subnet_name = get_conf('vping.vping_private_subnet_name')
- self.private_subnet_cidr = get_conf('vping.vping_private_subnet_cidr')
- self.router_name = get_conf('vping.vping_router_name')
- self.sg_name = get_conf('vping.vping_sg_name')
- self.sg_desc = get_conf('vping.vping_sg_descr')
+ self.private_net_name = CONST.vping_private_net_name
+ self.private_subnet_name = CONST.vping_private_subnet_name
+ self.private_subnet_cidr = CONST.vping_private_subnet_cidr
+ self.router_name = CONST.vping_router_name
+ self.sg_name = CONST.vping_sg_name
+ self.sg_desc = CONST.vping_sg_desc
self.neutron_client = os_utils.get_neutron_client()
self.glance_client = os_utils.get_glance_client()
self.nova_client = os_utils.get_nova_client()
@@ -294,6 +289,6 @@ class VPingMain(object):
if result != VPingBase.EX_OK:
return result
if kwargs['report']:
- return self.vping.push_to_db()
+ return self.vping.publish_report()
except Exception:
return VPingBase.EX_RUN_ERROR
diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py
index 0905e55c..339c305e 100755
--- a/functest/opnfv_tests/sdn/odl/odl.py
+++ b/functest/opnfv_tests/sdn/odl/odl.py
@@ -15,7 +15,7 @@ import re
import sys
import urlparse
-from robot.api import ExecutionResult, ResultVisitor
+import robot.api
from robot.errors import RobotError
import robot.run
from robot.utils.robottime import timestamp_to_secs
@@ -25,7 +25,7 @@ import functest.utils.functest_logger as ft_logger
import functest.utils.openstack_utils as op_utils
-class ODLResultVisitor(ResultVisitor):
+class ODLResultVisitor(robot.api.ResultVisitor):
def __init__(self):
self._data = []
@@ -79,7 +79,7 @@ class ODLTests(testcase_base.TestcaseBase):
def parse_results(self):
xml_file = os.path.join(self.res_dir, 'output.xml')
- result = ExecutionResult(xml_file)
+ result = robot.api.ExecutionResult(xml_file)
visitor = ODLResultVisitor()
result.visit(visitor)
self.criteria = result.suite.status
@@ -161,7 +161,8 @@ class ODLTests(testcase_base.TestcaseBase):
kwargs['odlwebport'] = '8282'
elif installer_type == 'apex':
kwargs['odlip'] = os.environ['SDN_CONTROLLER_IP']
- kwargs['odlwebport'] = '8181'
+ kwargs['odlwebport'] = '8081'
+ kwargs['odlrestconfport'] = '8081'
elif installer_type == 'joid':
kwargs['odlip'] = os.environ['SDN_CONTROLLER']
elif installer_type == 'compass':
@@ -180,49 +181,57 @@ class ODLTests(testcase_base.TestcaseBase):
return self.main(**kwargs)
+class ODLParser():
+
+ 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(
+ '-a', '--osusername', help='Username for OpenStack',
+ default='admin')
+ self.parser.add_argument(
+ '-b', '--ostenantname', help='Tenantname for OpenStack',
+ default='admin')
+ self.parser.add_argument(
+ '-c', '--ospassword', help='Password for OpenStack',
+ default='admin')
+ self.parser.add_argument(
+ '-o', '--odlip', help='OpenDaylight IP',
+ default='127.0.0.1')
+ self.parser.add_argument(
+ '-w', '--odlwebport', help='OpenDaylight Web Portal Port',
+ default='8080')
+ self.parser.add_argument(
+ '-r', '--odlrestconfport', help='OpenDaylight RESTConf Port',
+ default='8181')
+ self.parser.add_argument(
+ '-d', '--odlusername', help='Username for ODL',
+ default='admin')
+ self.parser.add_argument(
+ '-e', '--odlpassword', help='Password for ODL',
+ default='admin')
+ self.parser.add_argument(
+ '-p', '--pushtodb', help='Push results to DB',
+ action='store_true')
+
+ def parse_args(self, argv=[]):
+ return vars(self.parser.parse_args(argv))
+
+
if __name__ == '__main__':
- parser = argparse.ArgumentParser()
- parser.add_argument('-k', '--keystoneip',
- help='Keystone IP',
- default='127.0.0.1')
- parser.add_argument('-n', '--neutronip',
- help='Neutron IP',
- default='127.0.0.1')
- parser.add_argument('-a', '--osusername',
- help='Username for OpenStack',
- default='admin')
- parser.add_argument('-b', '--ostenantname',
- help='Tenantname for OpenStack',
- default='admin')
- parser.add_argument('-c', '--ospassword',
- help='Password for OpenStack',
- default='admin')
- parser.add_argument('-o', '--odlip',
- help='OpenDaylight IP',
- default='127.0.0.1')
- parser.add_argument('-w', '--odlwebport',
- help='OpenDaylight Web Portal Port',
- default='8080')
- parser.add_argument('-r', '--odlrestconfport',
- help='OpenDaylight RESTConf Port',
- default='8181')
- parser.add_argument('-d', '--odlusername',
- help='Username for ODL',
- default='admin')
- parser.add_argument('-e', '--odlpassword',
- help='Password for ODL',
- default='admin')
- parser.add_argument('-p', '--pushtodb',
- help='Push results to DB',
- action='store_true')
-
- args = vars(parser.parse_args())
odl = ODLTests()
+ parser = ODLParser()
+ args = parser.parse_args(sys.argv[1:])
try:
result = odl.main(**args)
if result != testcase_base.TestcaseBase.EX_OK:
sys.exit(result)
if args['pushtodb']:
- sys.exit(odl.push_to_db())
+ sys.exit(odl.publish_report())
except Exception:
sys.exit(testcase_base.TestcaseBase.EX_RUN_ERROR)
diff --git a/functest/opnfv_tests/sdn/onos/teston/onos.py b/functest/opnfv_tests/sdn/onos/teston/onos.py
index 300f56d1..213bdb7d 100755
--- a/functest/opnfv_tests/sdn/onos/teston/onos.py
+++ b/functest/opnfv_tests/sdn/onos/teston/onos.py
@@ -18,14 +18,15 @@ 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
-import functest.utils.functest_constants as ft_constants
parser = argparse.ArgumentParser()
@@ -135,9 +136,9 @@ def GetResult():
def SetOnosIp():
- cmd = "openstack catalog show network | grep publicURL"
- cmd_output = os.popen(cmd).read()
- OC1 = re.search(r"\d+\.\d+\.\d+\.\d+", cmd_output).group()
+ # 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)
@@ -180,10 +181,9 @@ def SfcTest():
def GetIp(type):
- cmd = "openstack catalog show " + type + " | grep publicURL"
- cmd_output = os.popen(cmd).read()
- ip = re.search(r"\d+\.\d+\.\d+\.\d+", cmd_output).group()
- return ip
+ # cmd = "openstack catalog show " + type + " | grep publicURL"
+ url = openstack_utils.get_endpoint(service_type=type)
+ return urlparse.urlparse(url).hostname
def Replace(before, after):
diff --git a/functest/opnfv_tests/vnf/aaa/__init__.py b/functest/opnfv_tests/vnf/aaa/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/functest/opnfv_tests/vnf/aaa/__init__.py
diff --git a/functest/opnfv_tests/vnf/aaa/aaa.py b/functest/opnfv_tests/vnf/aaa/aaa.py
new file mode 100644
index 00000000..f1c265f4
--- /dev/null
+++ b/functest/opnfv_tests/vnf/aaa/aaa.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2016 Orange 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 sys
+
+import argparse
+
+import functest.core.testcase_base as testcase_base
+import functest.core.vnf_base as vnf_base
+import functest.utils.functest_logger as ft_logger
+
+
+class AaaVnf(vnf_base.VnfOnBoardingBase):
+
+ logger = ft_logger.Logger("VNF AAA").getLogger()
+
+ def __init__(self):
+ super(AaaVnf, self).__init__(case="aaa")
+
+ def deploy_orchestrator(self):
+ self.logger.info("No VNFM needed to deploy a free radius here")
+ return None
+
+# 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
+
+ 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.criteria is "PASS":
+ return self.EX_OK
+ else:
+ return self.EX_RUN_ERROR
+
+ def run(self):
+ kwargs = {}
+ return self.main(**kwargs)
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser()
+ args = vars(parser.parse_args())
+ aaa_vnf = AaaVnf()
+ try:
+ result = aaa_vnf.main(**args)
+ if result != testcase_base.TestcaseBase.EX_OK:
+ sys.exit(result)
+ if args['pushtodb']:
+ sys.exit(aaa_vnf.push_to_db())
+ except Exception:
+ sys.exit(testcase_base.TestcaseBase.EX_RUN_ERROR)
diff --git a/functest/opnfv_tests/vnf/ims/__init__.py b/functest/opnfv_tests/vnf/ims/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/functest/opnfv_tests/vnf/ims/__init__.py
diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.py b/functest/opnfv_tests/vnf/ims/cloudify_ims.py
new file mode 100644
index 00000000..13a5af4f
--- /dev/null
+++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.py
@@ -0,0 +1,278 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2016 Orange 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 json
+import os
+import requests
+import subprocess
+import time
+
+import functest.core.vnf_base as vnf_base
+import functest.utils.functest_logger as ft_logger
+import functest.utils.functest_utils as ft_utils
+import functest.utils.openstack_utils as os_utils
+
+from clearwater import Clearwater
+from functest.utils.constants import CONST
+from orchestrator_cloudify import Orchestrator
+
+
+class ImsVnf(vnf_base.VnfOnBoardingBase):
+
+ def __init__(self, project='functest', case='cloudify_ims',
+ repo='', cmd=''):
+ super(ImsVnf, self).__init__(project, case, repo, cmd)
+ self.logger = ft_logger.Logger("vIMS").getLogger()
+ self.case_dir = os.path.join(CONST.functest_test, 'vnf/ims/')
+ self.data_dir = CONST.dir_vIMS_data
+ self.test_dir = CONST.dir_repo_vims_test
+
+ self.orchestrator = dict(
+ requirements=CONST.cloudify_requirements,
+ blueprint=CONST.cloudify_blueprint,
+ inputs=CONST.cloudify_inputs
+ )
+
+ self.vnf = dict(
+ blueprint=CONST.clearwater_blueprint,
+ deployment_name=CONST.clearwater_deployment_name,
+ inputs=CONST.clearwater_inputs,
+ requirements=CONST.clearwater_requirements
+ )
+
+ # vIMS Data directory creation
+ if not os.path.exists(self.data_dir):
+ os.makedirs(self.data_dir)
+
+ def deploy_orchestrator(self, **kwargs):
+ public_auth_url = os_utils.get_endpoint('identity')
+
+ cfy = Orchestrator(self.data_dir, self.orchestrator.inputs)
+ self.orchestrator.object = cfy
+
+ if 'tenant_name' in self.creds.keys():
+ tenant_name = self.creds['tenant_name']
+ elif 'project_name' in self.creds.keys():
+ tenant_name = self.creds['project_name']
+
+ cfy.set_credentials(username=self.creds['username'],
+ password=self.creds['password'],
+ tenant_name=tenant_name,
+ auth_url=public_auth_url)
+
+ # orchestrator VM flavor
+ flavor_id = self.get_flavor("m1.large", self.orchestrator.requirements)
+ if not flavor_id:
+ self.logger.info("Available flavors are: ")
+ self.pMsg(self.nova_client.flavor.list())
+ self.step_failure("Failed to find required flavor"
+ "for this deployment")
+ cfy.set_flavor_id(flavor_id)
+
+ # orchestrator VM image
+ if 'os_image' in self.orchestrator.requirements.keys():
+ image_id = os_utils.get_image_id(
+ self.glance_client, self.orchestrator.requirements['os_image'])
+ if image_id == '':
+ 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)
+
+ ext_net = os_utils.get_external_net(self.neutron_client)
+ if not ext_net:
+ self.step_failure("Failed to get external network")
+
+ cfy.set_external_network_name(ext_net)
+
+ ns = ft_utils.get_resolvconf_ns()
+ if ns:
+ cfy.set_nameservers(ns)
+
+ if 'compute' in self.nova_client.client.services_url:
+ cfy.set_nova_url(self.nova_client.client.services_url['compute'])
+ if self.neutron_client.httpclient.endpoint_url is not None:
+ cfy.set_neutron_url(self.neutron_client.httpclient.endpoint_url)
+
+ self.logger.info("Prepare virtualenv for cloudify-cli")
+ cmd = "chmod +x " + self.case_dir + "create_venv.sh"
+ ft_utils.execute_command(cmd)
+ time.sleep(3)
+ cmd = self.case_dir + "create_venv.sh " + self.data_dir
+ ft_utils.execute_command(cmd)
+
+ cfy.download_manager_blueprint(self.orchestrator.blueprint['url'],
+ self.orchestrator.blueprint['branch'])
+
+ cfy.deploy_manager()
+ return {'status': 'PASS', 'result': ''}
+
+ def deploy_vnf(self):
+ cw = Clearwater(self.vnf.inputs, self.orchestrator.object, self.logger)
+ self.vnf.object = cw
+
+ self.logger.info("Collect flavor id for all clearwater vm")
+ flavor_id = self.get_flavor("m1.small", self.vnf.requirements)
+ if not flavor_id:
+ self.logger.info("Available flavors are: ")
+ self.pMsg(self.nova_client.flavor.list())
+ self.step_failure("Failed to find required flavor"
+ " for this deployment")
+
+ cw.set_flavor_id(flavor_id)
+
+ # VMs image
+ 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)
+
+ cw.deploy_vnf()
+ return {'status': 'PASS', 'result': ''}
+
+ def test_vnf(self):
+ script = "source {0}venv_cloudify/bin/activate; "
+ script += "cd {0}; "
+ script += "cfy status | grep -Eo \"([0-9]{{1,3}}\.){{3}}[0-9]{{1,3}}\""
+ cmd = "/bin/bash -c '" + script.format(self.data_dir) + "'"
+
+ try:
+ self.logger.debug("Trying to get clearwater manager IP ... ")
+ mgr_ip = os.popen(cmd).read()
+ mgr_ip = mgr_ip.splitlines()[0]
+ except:
+ self.step_failure("Unable to retrieve the IP of the "
+ "cloudify manager server !")
+
+ api_url = "http://" + mgr_ip + "/api/v2"
+ dep_outputs = requests.get(api_url + "/deployments/" +
+ self.vnf.deployment_name + "/outputs")
+ dns_ip = dep_outputs.json()['outputs']['dns_ip']
+ ellis_ip = dep_outputs.json()['outputs']['ellis_ip']
+
+ ellis_url = "http://" + ellis_ip + "/"
+ url = ellis_url + "accounts"
+
+ params = {"password": "functest",
+ "full_name": "opnfv functest user",
+ "email": "functest@opnfv.fr",
+ "signup_code": "secret"}
+
+ rq = requests.post(url, data=params)
+ i = 20
+ while rq.status_code != 201 and i > 0:
+ rq = requests.post(url, data=params)
+ i = i - 1
+ time.sleep(10)
+
+ if rq.status_code == 201:
+ url = ellis_url + "session"
+ rq = requests.post(url, data=params)
+ cookies = rq.cookies
+
+ url = ellis_url + "accounts/" + params['email'] + "/numbers"
+ if cookies != "":
+ rq = requests.post(url, cookies=cookies)
+ i = 24
+ while rq.status_code != 200 and i > 0:
+ rq = requests.post(url, cookies=cookies)
+ i = i - 1
+ time.sleep(25)
+
+ if rq.status_code != 200:
+ self.step_failure("Unable to create a number: %s"
+ % rq.json()['reason'])
+
+ nameservers = ft_utils.get_resolvconf_ns()
+ resolvconf = ""
+ for ns in nameservers:
+ resolvconf += "\nnameserver " + ns
+
+ if dns_ip != "":
+ script = ('echo -e "nameserver ' + dns_ip + resolvconf +
+ '" > /etc/resolv.conf; ')
+ script += 'source /etc/profile.d/rvm.sh; '
+ script += 'cd {0}; '
+ script += ('rake test[{1}] SIGNUP_CODE="secret"')
+
+ cmd = ("/bin/bash -c '" +
+ script.format(self.data_dir, self.inputs["public_domain"]) +
+ "'")
+ output_file = "output.txt"
+ f = open(output_file, 'w+')
+ subprocess.call(cmd, shell=True, stdout=f,
+ stderr=subprocess.STDOUT)
+ f.close()
+
+ f = open(output_file, 'r')
+ result = f.read()
+ if result != "":
+ self.logger.debug(result)
+
+ vims_test_result = ""
+ tempFile = os.path.join(self.test_dir, "temp.json")
+ try:
+ self.logger.debug("Trying to load test results")
+ with open(tempFile) as f:
+ vims_test_result = json.load(f)
+ f.close()
+ except:
+ self.logger.error("Unable to retrieve test results")
+
+ try:
+ os.remove(tempFile)
+ except:
+ self.logger.error("Deleting file failed")
+
+ if vims_test_result != '':
+ return {'status': 'PASS', 'result': vims_test_result}
+ else:
+ return {'status': 'FAIL', 'result': ''}
+
+ def clean(self):
+ self.vnf.object.undeploy_vnf()
+ self.orchestrator.object.undeploy_manager()
+ super(ImsVnf, self).clean()
+
+ def get_flavor(self, flavor_name, requirements):
+ try:
+ flavor_id = os_utils.get_flavor_id(self.nova_client, flavor_name)
+ if 'ram_min' in requirements.keys():
+ flavor_id = os_utils.get_flavor_id_by_ram_range(
+ self.nova_client, requirements['ram_min'], 7500)
+
+ if flavor_id == '':
+ self.logger.error(
+ "Failed to find %s flavor. "
+ "Try with ram range default requirement !" % flavor_name)
+ flavor_id = os_utils.get_flavor_id_by_ram_range(
+ self.nova_client,
+ 4000, 10000)
+ return flavor_id
+ except:
+ self.logger.error("Flavor '%s' not found." % self.flavor_name)
+ self.logger.info("Available flavors are: ")
+ self.pMsg(self.nova_client.flavor.list())
+ return None
diff --git a/functest/opnfv_tests/vnf/ims/opera_ims.py b/functest/opnfv_tests/vnf/ims/opera_ims.py
new file mode 100644
index 00000000..073a56c3
--- /dev/null
+++ b/functest/opnfv_tests/vnf/ims/opera_ims.py
@@ -0,0 +1,155 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2016 Orange 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 json
+import os
+import requests
+import subprocess
+import time
+
+import functest.core.vnf_base as vnf_base
+import functest.utils.functest_logger as ft_logger
+import functest.utils.functest_utils as ft_utils
+from functest.utils.constants import CONST
+
+
+class ImsVnf(vnf_base.VnfOnBoardingBase):
+
+ def __init__(self, project='functest', case='opera_ims',
+ repo='', cmd=''):
+ super(ImsVnf, self).__init__(project, case, repo, cmd)
+ self.logger = ft_logger.Logger("vIMS").getLogger()
+ self.case_dir = os.path.join(CONST.functest_test, 'vnf/ims/')
+ self.data_dir = CONST.dir_vIMS_data
+ self.test_dir = CONST.dir_repo_vims_test
+
+ # vIMS Data directory creation
+ if not os.path.exists(self.data_dir):
+ os.makedirs(self.data_dir)
+
+ def deploy_orchestrator(self, **kwargs):
+ # TODO
+ # deploy open-O from Functest docker located on the Jumphost
+ # you have admin rights on OpenStack SUT
+ # you can cretae a VM, spawn docker on the jumphost
+ # spawn docker on a VM in the SUT, ..up to you
+ #
+ # note: this step can be ignored
+ # if Open-O is part of the installer
+ self.logger.info("Deploy orchestrator: OK")
+
+ def deploy_vnf(self):
+ # TODO
+ self.logger.info("Deploy VNF: OK")
+
+ def test_vnf(self):
+ # Adaptations probably needed
+ # code used for cloudify_ims
+ # ruby client on jumphost calling the vIMS on the SUT
+ script = "source {0}venv_cloudify/bin/activate; "
+ script += "cd {0}; "
+ script += "cfy status | grep -Eo \"([0-9]{{1,3}}\.){{3}}[0-9]{{1,3}}\""
+ cmd = "/bin/bash -c '" + script.format(self.data_dir) + "'"
+
+ try:
+ self.logger.debug("Trying to get clearwater manager IP ... ")
+ mgr_ip = os.popen(cmd).read()
+ mgr_ip = mgr_ip.splitlines()[0]
+ except:
+ self.step_failure("Unable to retrieve the IP of the "
+ "cloudify manager server !")
+
+ api_url = "http://" + mgr_ip + "/api/v2"
+ dep_outputs = requests.get(api_url + "/deployments/" +
+ self.vnf.deployment_name + "/outputs")
+ dns_ip = dep_outputs.json()['outputs']['dns_ip']
+ ellis_ip = dep_outputs.json()['outputs']['ellis_ip']
+
+ ellis_url = "http://" + ellis_ip + "/"
+ url = ellis_url + "accounts"
+
+ params = {"password": "functest",
+ "full_name": "opnfv functest user",
+ "email": "functest@opnfv.fr",
+ "signup_code": "secret"}
+
+ rq = requests.post(url, data=params)
+ i = 20
+ while rq.status_code != 201 and i > 0:
+ rq = requests.post(url, data=params)
+ i = i - 1
+ time.sleep(10)
+
+ if rq.status_code == 201:
+ url = ellis_url + "session"
+ rq = requests.post(url, data=params)
+ cookies = rq.cookies
+
+ url = ellis_url + "accounts/" + params['email'] + "/numbers"
+ if cookies != "":
+ rq = requests.post(url, cookies=cookies)
+ i = 24
+ while rq.status_code != 200 and i > 0:
+ rq = requests.post(url, cookies=cookies)
+ i = i - 1
+ time.sleep(25)
+
+ if rq.status_code != 200:
+ self.step_failure("Unable to create a number: %s"
+ % rq.json()['reason'])
+
+ nameservers = ft_utils.get_resolvconf_ns()
+ resolvconf = ""
+ for ns in nameservers:
+ resolvconf += "\nnameserver " + ns
+
+ if dns_ip != "":
+ script = ('echo -e "nameserver ' + dns_ip + resolvconf +
+ '" > /etc/resolv.conf; ')
+ script += 'source /etc/profile.d/rvm.sh; '
+ script += 'cd {0}; '
+ script += ('rake test[{1}] SIGNUP_CODE="secret"')
+
+ cmd = ("/bin/bash -c '" +
+ script.format(self.data_dir, self.inputs["public_domain"]) +
+ "'")
+ output_file = "output.txt"
+ f = open(output_file, 'w+')
+ subprocess.call(cmd, shell=True, stdout=f,
+ stderr=subprocess.STDOUT)
+ f.close()
+
+ f = open(output_file, 'r')
+ result = f.read()
+ if result != "":
+ self.logger.debug(result)
+
+ vims_test_result = ""
+ tempFile = os.path.join(self.test_dir, "temp.json")
+ try:
+ self.logger.debug("Trying to load test results")
+ with open(tempFile) as f:
+ vims_test_result = json.load(f)
+ f.close()
+ except:
+ self.logger.error("Unable to retrieve test results")
+
+ try:
+ os.remove(tempFile)
+ except:
+ self.logger.error("Deleting file failed")
+
+ if vims_test_result != '':
+ return {'status': 'PASS', 'result': vims_test_result}
+ else:
+ return {'status': 'FAIL', 'result': ''}
+
+ def clean(self):
+ # TODO
+ super(ImsVnf, self).clean()
diff --git a/functest/opnfv_tests/vnf/ims/orchestra_ims.py b/functest/opnfv_tests/vnf/ims/orchestra_ims.py
new file mode 100644
index 00000000..28f37f05
--- /dev/null
+++ b/functest/opnfv_tests/vnf/ims/orchestra_ims.py
@@ -0,0 +1,157 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2016 Orange 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 json
+import os
+import requests
+import subprocess
+import time
+
+import functest.core.vnf_base as vnf_base
+import functest.utils.functest_logger as ft_logger
+import functest.utils.functest_utils as ft_utils
+from functest.utils.constants import CONST
+
+
+class ImsVnf(vnf_base.VnfOnBoardingBase):
+
+ def __init__(self, project='functest', case='orchestra_ims',
+ repo='', cmd=''):
+ super(ImsVnf, self).__init__(project, case, repo, cmd)
+ self.logger = ft_logger.Logger("vIMS").getLogger()
+ self.case_dir = os.path.join(CONST.functest_test, 'vnf/ims/')
+ self.data_dir = CONST.dir_vIMS_data
+ self.test_dir = CONST.dir_repo_vims_test
+
+ # vIMS Data directory creation
+ if not os.path.exists(self.data_dir):
+ os.makedirs(self.data_dir)
+
+ def deploy_orchestrator(self, **kwargs):
+ # TODO
+ # put your code here to deploy openbaton
+ # from the functest docker located on the jumphost
+ # you have admin rights on OpenStack SUT
+ # you can cretae a VM, spawn docker on the jumphost
+ # spawn docker on a VM in the SUT, ..up to you
+ #
+ # note: this step can be ignored
+ # if OpenBaton is part of the installer
+ self.logger.info("Deploy orchestrator: OK")
+
+ def deploy_vnf(self):
+ # deploy the VNF
+ # call openbaton to deploy the vIMS
+ self.logger.info("Deploy VNF: OK")
+
+ def test_vnf(self):
+ # Adaptations probably needed
+ # code used for cloudify_ims
+ # ruby client on jumphost calling the vIMS on the SUT
+ script = "source {0}venv_cloudify/bin/activate; "
+ script += "cd {0}; "
+ script += "cfy status | grep -Eo \"([0-9]{{1,3}}\.){{3}}[0-9]{{1,3}}\""
+ cmd = "/bin/bash -c '" + script.format(self.data_dir) + "'"
+
+ try:
+ self.logger.debug("Trying to get clearwater manager IP ... ")
+ mgr_ip = os.popen(cmd).read()
+ mgr_ip = mgr_ip.splitlines()[0]
+ except:
+ self.step_failure("Unable to retrieve the IP of the "
+ "cloudify manager server !")
+
+ api_url = "http://" + mgr_ip + "/api/v2"
+ dep_outputs = requests.get(api_url + "/deployments/" +
+ self.vnf.deployment_name + "/outputs")
+ dns_ip = dep_outputs.json()['outputs']['dns_ip']
+ ellis_ip = dep_outputs.json()['outputs']['ellis_ip']
+
+ ellis_url = "http://" + ellis_ip + "/"
+ url = ellis_url + "accounts"
+
+ params = {"password": "functest",
+ "full_name": "opnfv functest user",
+ "email": "functest@opnfv.fr",
+ "signup_code": "secret"}
+
+ rq = requests.post(url, data=params)
+ i = 20
+ while rq.status_code != 201 and i > 0:
+ rq = requests.post(url, data=params)
+ i = i - 1
+ time.sleep(10)
+
+ if rq.status_code == 201:
+ url = ellis_url + "session"
+ rq = requests.post(url, data=params)
+ cookies = rq.cookies
+
+ url = ellis_url + "accounts/" + params['email'] + "/numbers"
+ if cookies != "":
+ rq = requests.post(url, cookies=cookies)
+ i = 24
+ while rq.status_code != 200 and i > 0:
+ rq = requests.post(url, cookies=cookies)
+ i = i - 1
+ time.sleep(25)
+
+ if rq.status_code != 200:
+ self.step_failure("Unable to create a number: %s"
+ % rq.json()['reason'])
+
+ nameservers = ft_utils.get_resolvconf_ns()
+ resolvconf = ""
+ for ns in nameservers:
+ resolvconf += "\nnameserver " + ns
+
+ if dns_ip != "":
+ script = ('echo -e "nameserver ' + dns_ip + resolvconf +
+ '" > /etc/resolv.conf; ')
+ script += 'source /etc/profile.d/rvm.sh; '
+ script += 'cd {0}; '
+ script += ('rake test[{1}] SIGNUP_CODE="secret"')
+
+ cmd = ("/bin/bash -c '" +
+ script.format(self.data_dir, self.inputs["public_domain"]) +
+ "'")
+ output_file = "output.txt"
+ f = open(output_file, 'w+')
+ subprocess.call(cmd, shell=True, stdout=f,
+ stderr=subprocess.STDOUT)
+ f.close()
+
+ f = open(output_file, 'r')
+ result = f.read()
+ if result != "":
+ self.logger.debug(result)
+
+ vims_test_result = ""
+ tempFile = os.path.join(self.test_dir, "temp.json")
+ try:
+ self.logger.debug("Trying to load test results")
+ with open(tempFile) as f:
+ vims_test_result = json.load(f)
+ f.close()
+ except:
+ self.logger.error("Unable to retrieve test results")
+
+ try:
+ os.remove(tempFile)
+ except:
+ self.logger.error("Deleting file failed")
+
+ if vims_test_result != '':
+ return {'status': 'PASS', 'result': vims_test_result}
+ else:
+ return {'status': 'FAIL', 'result': ''}
+
+ def clean(self):
+ # TODO
+ super(ImsVnf, self).clean()
diff --git a/functest/opnfv_tests/vnf/ims/orchestrator.py b/functest/opnfv_tests/vnf/ims/orchestrator_cloudify.py
index f3838f87..f3838f87 100644
--- a/functest/opnfv_tests/vnf/ims/orchestrator.py
+++ b/functest/opnfv_tests/vnf/ims/orchestrator_cloudify.py
diff --git a/functest/opnfv_tests/vnf/ims/vims.py b/functest/opnfv_tests/vnf/ims/vims.py
deleted file mode 100755
index fe888b69..00000000
--- a/functest/opnfv_tests/vnf/ims/vims.py
+++ /dev/null
@@ -1,521 +0,0 @@
-#!/usr/bin/python
-# coding: utf8
-#######################################################################
-#
-# Copyright (c) 2015 Orange
-# valentin.boucher@orange.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 json
-import os
-import pprint
-import subprocess
-import time
-
-import argparse
-import keystoneclient.v2_0.client as ksclient
-import novaclient.client as nvclient
-import requests
-from neutronclient.v2_0 import client as ntclient
-
-import functest.utils.functest_logger as ft_logger
-import functest.utils.functest_utils as ft_utils
-import functest.utils.openstack_utils as os_utils
-from clearwater import Clearwater
-from orchestrator import Orchestrator
-import functest.utils.functest_constants as ft_constants
-
-pp = pprint.PrettyPrinter(indent=4)
-
-
-parser = argparse.ArgumentParser()
-parser.add_argument("-d", "--debug", help="Debug mode", action="store_true")
-parser.add_argument("-r", "--report",
- help="Create json result file",
- action="store_true")
-parser.add_argument("-n", "--noclean",
- help="Don't clean the created resources for this test.",
- action="store_true")
-args = parser.parse_args()
-
-""" logging configuration """
-logger = ft_logger.Logger("vIMS").getLogger()
-
-
-# Cloudify parameters
-VIMS_DIR = os.path.join(ft_constants.FUNCTEST_TEST_DIR, 'vnf/ims/')
-VIMS_DATA_DIR = ft_constants.VIMS_DATA_DIR
-VIMS_TEST_DIR = ft_constants.VIMS_TEST_DIR
-VIMS_TENANT_NAME = ft_constants.VIMS_TENANT_NAME
-VIMS_TENANT_DESCRIPTION = ft_constants.VIMS_TENANT_DESCRIPTION
-VIMS_IMAGES = ft_constants.VIMS_IMAGES
-
-CFY_MANAGER_BLUEPRINT = ft_constants.CFY_MANAGER_BLUEPRINT
-CFY_MANAGER_REQUIERMENTS = ft_constants.CFY_MANAGER_REQUIERMENTS
-CFY_INPUTS = ft_constants.CFY_INPUTS
-
-CW_BLUEPRINT = ft_constants.CW_BLUEPRINT
-CW_DEPLOYMENT_NAME = ft_constants.CW_DEPLOYMENT_NAME
-CW_INPUTS = ft_constants.CW_INPUTS
-CW_REQUIERMENTS = ft_constants.CW_REQUIERMENTS
-
-CFY_DEPLOYMENT_DURATION = 0
-CW_DEPLOYMENT_DURATION = 0
-
-TESTCASE_START_TIME = time.time()
-RESULTS = {'orchestrator': {'duration': 0, 'result': ''},
- 'vIMS': {'duration': 0, 'result': ''},
- 'sig_test': {'duration': 0, 'result': ''}}
-
-
-def download_and_add_image_on_glance(glance, image_name, image_url):
- dest_path = os.path.join(VIMS_DATA_DIR, "tmp/")
- 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):
- logger.error("Failed to download image %s" % file_name)
- return False
-
- image = os_utils.create_glance_image(
- glance, image_name, dest_path + file_name)
- if not image:
- logger.error("Failed to upload image on glance")
- return False
-
- return image
-
-
-def step_failure(step_name, error_msg):
- logger.error(error_msg)
- set_result(step_name, 0, error_msg)
- status = "FAIL"
- # in case of failure starting and stoping time are not correct
- stop_time = time.time()
- if step_name == "sig_test":
- status = "PASS"
- ft_utils.push_results_to_db("functest",
- "vims",
- TESTCASE_START_TIME,
- stop_time,
- status,
- RESULTS)
- exit(-1)
-
-
-def set_result(step_name, duration=0, result=""):
- RESULTS[step_name] = {'duration': duration, 'result': result}
-
-
-def test_clearwater():
- script = "source " + VIMS_DATA_DIR + "venv_cloudify/bin/activate; "
- script += "cd " + VIMS_DATA_DIR + "; "
- script += "cfy status | grep -Eo \"([0-9]{1,3}\.){3}[0-9]{1,3}\""
- cmd = "/bin/bash -c '" + script + "'"
-
- try:
- logger.debug("Trying to get clearwater manager IP ... ")
- mgr_ip = os.popen(cmd).read()
- mgr_ip = mgr_ip.splitlines()[0]
- except:
- step_failure("sig_test", "Unable to retrieve the IP of the "
- "cloudify manager server !")
-
- api_url = "http://" + mgr_ip + "/api/v2"
- dep_outputs = requests.get(api_url + "/deployments/" +
- CW_DEPLOYMENT_NAME + "/outputs")
- dns_ip = dep_outputs.json()['outputs']['dns_ip']
- ellis_ip = dep_outputs.json()['outputs']['ellis_ip']
-
- ellis_url = "http://" + ellis_ip + "/"
- url = ellis_url + "accounts"
-
- params = {"password": "functest",
- "full_name": "opnfv functest user",
- "email": "functest@opnfv.fr",
- "signup_code": "secret"}
-
- rq = requests.post(url, data=params)
- i = 20
- while rq.status_code != 201 and i > 0:
- rq = requests.post(url, data=params)
- i = i - 1
- time.sleep(10)
-
- if rq.status_code == 201:
- url = ellis_url + "session"
- rq = requests.post(url, data=params)
- cookies = rq.cookies
-
- url = ellis_url + "accounts/" + params['email'] + "/numbers"
- if cookies != "":
- rq = requests.post(url, cookies=cookies)
- i = 24
- while rq.status_code != 200 and i > 0:
- rq = requests.post(url, cookies=cookies)
- i = i - 1
- time.sleep(25)
-
- if rq.status_code != 200:
- step_failure("sig_test", "Unable to create a number: %s"
- % rq.json()['reason'])
-
- start_time_ts = time.time()
- end_time_ts = start_time_ts
- logger.info("vIMS functional test Start Time:'%s'" % (
- datetime.datetime.fromtimestamp(start_time_ts).strftime(
- '%Y-%m-%d %H:%M:%S')))
- nameservers = ft_utils.get_resolvconf_ns()
- resolvconf = ""
- for ns in nameservers:
- resolvconf += "\nnameserver " + ns
-
- if dns_ip != "":
- script = ('echo -e "nameserver ' + dns_ip + resolvconf +
- '" > /etc/resolv.conf; ')
- script += 'source /etc/profile.d/rvm.sh; '
- script += 'cd ' + VIMS_TEST_DIR + '; '
- script += ('rake test[' + CW_INPUTS["public_domain"] +
- '] SIGNUP_CODE="secret"')
-
- cmd = "/bin/bash -c '" + script + "'"
- output_file = "output.txt"
- f = open(output_file, 'w+')
- subprocess.call(cmd, shell=True, stdout=f,
- stderr=subprocess.STDOUT)
- f.close()
- end_time_ts = time.time()
- duration = round(end_time_ts - start_time_ts, 1)
- logger.info("vIMS functional test duration:'%s'" % duration)
- f = open(output_file, 'r')
- result = f.read()
- if result != "" and logger:
- logger.debug(result)
-
- vims_test_result = ""
- tempFile = os.path.join(VIMS_TEST_DIR, "temp.json")
- try:
- logger.debug("Trying to load test results")
- with open(tempFile) as f:
- vims_test_result = json.load(f)
- f.close()
- except:
- logger.error("Unable to retrieve test results")
-
- set_result("sig_test", duration, vims_test_result)
-
- # success criteria for vIMS (for Brahmaputra)
- # - orchestrator deployed
- # - VNF deployed
- # TODO use test criteria defined in config file
- status = "FAIL"
- try:
- if (RESULTS['orchestrator']['duration'] > 0 and
- RESULTS['vIMS']['duration'] > 0):
- status = "PASS"
- except:
- logger.error("Unable to set test status")
-
- ft_utils.push_results_to_db("functest",
- "vims",
- TESTCASE_START_TIME,
- end_time_ts,
- status,
- RESULTS)
-
- try:
- os.remove(tempFile)
- except:
- logger.error("Deleting file failed")
-
-
-def main():
-
- # ############### GENERAL INITIALISATION ################
-
- if not os.path.exists(VIMS_DATA_DIR):
- os.makedirs(VIMS_DATA_DIR)
-
- ks_creds = os_utils.get_credentials("keystone")
- nv_creds = os_utils.get_credentials("nova")
- nt_creds = os_utils.get_credentials("neutron")
-
- logger.info("Prepare OpenStack plateform (create tenant and user)")
- keystone = ksclient.Client(**ks_creds)
-
- user_id = os_utils.get_user_id(keystone, ks_creds['username'])
- if user_id == '':
- step_failure("init", "Error : Failed to get id of " +
- ks_creds['username'])
-
- tenant_id = os_utils.create_tenant(
- keystone, VIMS_TENANT_NAME, VIMS_TENANT_DESCRIPTION)
- if not tenant_id:
- step_failure("init", "Error : Failed to create " +
- VIMS_TENANT_NAME + " tenant")
-
- roles_name = ["admin", "Admin"]
- role_id = ''
- for role_name in roles_name:
- if role_id == '':
- role_id = os_utils.get_role_id(keystone, role_name)
-
- if role_id == '':
- logger.error("Error : Failed to get id for %s role" % role_name)
-
- if not os_utils.add_role_user(keystone, user_id, role_id, tenant_id):
- logger.error("Error : Failed to add %s on tenant" %
- ks_creds['username'])
-
- user_id = os_utils.create_user(
- keystone, VIMS_TENANT_NAME, VIMS_TENANT_NAME, None, tenant_id)
- if not user_id:
- logger.error("Error : Failed to create %s user" % VIMS_TENANT_NAME)
-
- logger.info("Update OpenStack creds informations")
- ks_creds.update({
- "username": VIMS_TENANT_NAME,
- "password": VIMS_TENANT_NAME,
- "tenant_name": VIMS_TENANT_NAME,
- })
-
- nt_creds.update({
- "tenant_name": VIMS_TENANT_NAME,
- })
-
- nv_creds.update({
- "project_id": VIMS_TENANT_NAME,
- })
-
- logger.info("Upload some OS images if it doesn't exist")
- glance = os_utils.get_glance_client()
-
- for img in VIMS_IMAGES.keys():
- image_name = VIMS_IMAGES[img]['image_name']
- image_url = VIMS_IMAGES[img]['image_url']
-
- image_id = os_utils.get_image_id(glance, image_name)
-
- if image_id == '':
- 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, image_name, image_url)
-
- if image_id == '':
- step_failure(
- "init",
- "Error : Failed to find or upload required OS "
- "image for this deployment")
-
- nova = nvclient.Client("2", **nv_creds)
-
- logger.info("Update security group quota for this tenant")
- neutron = ntclient.Client(**nt_creds)
- if not os_utils.update_sg_quota(neutron, tenant_id, 50, 100):
- step_failure(
- "init",
- "Failed to update security group quota for tenant " +
- VIMS_TENANT_NAME)
-
- # ############### CLOUDIFY INITIALISATION ################
- public_auth_url = keystone.service_catalog.url_for(
- service_type='identity', endpoint_type='publicURL')
-
- cfy = Orchestrator(VIMS_DATA_DIR, CFY_INPUTS)
-
- cfy.set_credentials(username=ks_creds['username'], password=ks_creds[
- 'password'], tenant_name=ks_creds['tenant_name'],
- auth_url=public_auth_url)
-
- logger.info("Collect flavor id for cloudify manager server")
- nova = nvclient.Client("2", **nv_creds)
-
- flavor_name = "m1.large"
- flavor_id = os_utils.get_flavor_id(nova, flavor_name)
- for requirement in CFY_MANAGER_REQUIERMENTS:
- if requirement == 'ram_min':
- flavor_id = os_utils.get_flavor_id_by_ram_range(
- nova, CFY_MANAGER_REQUIERMENTS['ram_min'], 10000)
-
- if flavor_id == '':
- logger.error(
- "Failed to find %s flavor. "
- "Try with ram range default requirement !" % flavor_name)
- flavor_id = os_utils.get_flavor_id_by_ram_range(nova, 4000, 8196)
-
- if flavor_id == '':
- step_failure("orchestrator",
- "Failed to find required flavor for this deployment")
-
- cfy.set_flavor_id(flavor_id)
-
- image_name = "centos_7"
- image_id = os_utils.get_image_id(glance, image_name)
- for requirement in CFY_MANAGER_REQUIERMENTS:
- if requirement == 'os_image':
- image_id = os_utils.get_image_id(
- glance, CFY_MANAGER_REQUIERMENTS['os_image'])
-
- if image_id == '':
- step_failure(
- "orchestrator",
- "Error : Failed to find required OS image for cloudify manager")
-
- cfy.set_image_id(image_id)
-
- ext_net = os_utils.get_external_net(neutron)
- if not ext_net:
- step_failure("orchestrator", "Failed to get external network")
-
- cfy.set_external_network_name(ext_net)
-
- ns = ft_utils.get_resolvconf_ns()
- if ns:
- cfy.set_nameservers(ns)
-
- if 'compute' in nova.client.services_url:
- cfy.set_nova_url(nova.client.services_url['compute'])
- if neutron.httpclient.endpoint_url is not None:
- cfy.set_neutron_url(neutron.httpclient.endpoint_url)
-
- logger.info("Prepare virtualenv for cloudify-cli")
- cmd = "chmod +x " + VIMS_DIR + "create_venv.sh"
- ft_utils.execute_command(cmd)
- time.sleep(3)
- cmd = VIMS_DIR + "create_venv.sh " + VIMS_DATA_DIR
- ft_utils.execute_command(cmd)
-
- cfy.download_manager_blueprint(
- CFY_MANAGER_BLUEPRINT['url'], CFY_MANAGER_BLUEPRINT['branch'])
-
- # ############### CLOUDIFY DEPLOYMENT ################
- start_time_ts = time.time()
- end_time_ts = start_time_ts
- logger.info("Cloudify deployment Start Time:'%s'" % (
- datetime.datetime.fromtimestamp(start_time_ts).strftime(
- '%Y-%m-%d %H:%M:%S')))
-
- error = cfy.deploy_manager()
- if error:
- step_failure("orchestrator", error)
-
- end_time_ts = time.time()
- duration = round(end_time_ts - start_time_ts, 1)
- logger.info("Cloudify deployment duration:'%s'" % duration)
- set_result("orchestrator", duration, "")
-
- # ############### CLEARWATER INITIALISATION ################
-
- cw = Clearwater(CW_INPUTS, cfy, logger)
-
- logger.info("Collect flavor id for all clearwater vm")
- nova = nvclient.Client("2", **nv_creds)
-
- flavor_name = "m1.small"
- flavor_id = os_utils.get_flavor_id(nova, flavor_name)
- for requirement in CW_REQUIERMENTS:
- if requirement == 'ram_min' and flavor_id == '':
- flavor_id = os_utils.get_flavor_id_by_ram_range(
- nova, CW_REQUIERMENTS['ram_min'], 4500)
-
- if flavor_id == '':
- logger.error(
- "Failed to find %s flavor. Try with ram range "
- "default requirement !" % flavor_name)
- flavor_id = os_utils.get_flavor_id_by_ram_range(nova, 4000, 8196)
-
- if flavor_id == '':
- step_failure(
- "vIMS", "Failed to find required flavor for this deployment")
-
- cw.set_flavor_id(flavor_id)
-
- image_name = "ubuntu_14.04"
- image_id = os_utils.get_image_id(glance, image_name)
- for requirement in CW_REQUIERMENTS:
- if requirement == 'os_image':
- image_id = os_utils.get_image_id(
- glance, CW_REQUIERMENTS['os_image'])
-
- if image_id == '':
- step_failure(
- "vIMS",
- "Error : Failed to find required OS image for cloudify manager")
-
- cw.set_image_id(image_id)
-
- ext_net = os_utils.get_external_net(neutron)
- if not ext_net:
- step_failure("vIMS", "Failed to get external network")
-
- cw.set_external_network_name(ext_net)
-
- # ############### CLEARWATER DEPLOYMENT ################
-
- start_time_ts = time.time()
- end_time_ts = start_time_ts
- logger.info("vIMS VNF deployment Start Time:'%s'" % (
- datetime.datetime.fromtimestamp(start_time_ts).strftime(
- '%Y-%m-%d %H:%M:%S')))
-
- error = cw.deploy_vnf(CW_BLUEPRINT)
- if error:
- step_failure("vIMS", error)
-
- end_time_ts = time.time()
- duration = round(end_time_ts - start_time_ts, 1)
- logger.info("vIMS VNF deployment duration:'%s'" % duration)
- set_result("vIMS", duration, "")
-
- # ############### CLEARWATER TEST ################
-
- test_clearwater()
-
- # ########## CLEARWATER UNDEPLOYMENT ############
-
- cw.undeploy_vnf()
-
- # ########### CLOUDIFY UNDEPLOYMENT #############
-
- cfy.undeploy_manager()
-
- # ############## GENERAL CLEANUP ################
- if args.noclean:
- exit(0)
-
- ks_creds = os_utils.get_credentials("keystone")
-
- keystone = ksclient.Client(**ks_creds)
-
- logger.info("Removing %s tenant .." % CFY_INPUTS['keystone_tenant_name'])
- tenant_id = os_utils.get_tenant_id(
- keystone, CFY_INPUTS['keystone_tenant_name'])
- if tenant_id == '':
- logger.error("Error : Failed to get id of %s tenant" %
- CFY_INPUTS['keystone_tenant_name'])
- else:
- if not os_utils.delete_tenant(keystone, tenant_id):
- logger.error("Error : Failed to remove %s tenant" %
- CFY_INPUTS['keystone_tenant_name'])
-
- logger.info("Removing %s user .." % CFY_INPUTS['keystone_username'])
- user_id = os_utils.get_user_id(
- keystone, CFY_INPUTS['keystone_username'])
- if user_id == '':
- logger.error("Error : Failed to get id of %s user" %
- CFY_INPUTS['keystone_username'])
- else:
- if not os_utils.delete_user(keystone, user_id):
- logger.error("Error : Failed to remove %s user" %
- CFY_INPUTS['keystone_username'])
-
-
-if __name__ == '__main__':
- main()