summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--functest/core/vnf_base.py15
-rw-r--r--functest/opnfv_tests/vnf/ims/cloudify_ims.py12
-rw-r--r--functest/opnfv_tests/vnf/ims/orchestra_ims.py13
-rw-r--r--functest/opnfv_tests/vnf/ims/orchestra_ims.yaml4
-rw-r--r--functest/tests/unit/core/test_vnf_base.py22
-rw-r--r--functest/tests/unit/utils/test_functest_utils.py13
-rw-r--r--functest/utils/functest_utils.py7
7 files changed, 53 insertions, 33 deletions
diff --git a/functest/core/vnf_base.py b/functest/core/vnf_base.py
index 0300dd226..f5e86054f 100644
--- a/functest/core/vnf_base.py
+++ b/functest/core/vnf_base.py
@@ -52,8 +52,13 @@ class VnfOnBoardingBase(base.TestcaseBase):
def execute(self):
self.start_time = time.time()
# Prepare the test (Create Tenant, User, ...)
- self.logger.info("Create VNF Onboarding environment")
- self.prepare()
+ try:
+ self.logger.info("Create VNF Onboarding environment")
+ self.prepare()
+ except Exception:
+ self.logger.error("Error during VNF Onboarding environment" +
+ "creation", exc_info=True)
+ return base.TestcaseBase.EX_TESTCASE_FAILED
# Deploy orchestrator
try:
@@ -179,11 +184,11 @@ class VnfOnBoardingBase(base.TestcaseBase):
# TODO see how to use built-in exception from releng module
def deploy_vnf(self):
self.logger.error("VNF must be deployed")
- return base.TestcaseBase.EX_TESTCASE_FAILED
+ raise Exception("VNF not deployed")
def test_vnf(self):
self.logger.error("VNF must be tested")
- return base.TestcaseBase.EX_TESTCASE_FAILED
+ raise Exception("VNF not tested")
def clean(self):
self.logger.info("test cleaning")
@@ -232,4 +237,4 @@ class VnfOnBoardingBase(base.TestcaseBase):
self.details[part]['status'] = 'FAIL'
self.details[part]['result'] = error_msg
self.logger.error("Step failure:{}".format(error_msg))
- return base.TestcaseBase.EX_TESTCASE_FAILED
+ raise Exception(error_msg)
diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.py b/functest/opnfv_tests/vnf/ims/cloudify_ims.py
index 2ced92e9d..74470add5 100644
--- a/functest/opnfv_tests/vnf/ims/cloudify_ims.py
+++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.py
@@ -261,6 +261,9 @@ class ImsVnf(vnf_base.VnfOnBoardingBase):
dns_ip = dep_outputs.json()['outputs']['dns_ip']
ellis_ip = dep_outputs.json()['outputs']['ellis_ip']
+ self.logger.debug("DNS ip : %s" % dns_ip)
+ self.logger.debug("ELLIS ip : %s" % ellis_ip)
+
ellis_url = "http://" + ellis_ip + "/"
url = ellis_url + "accounts"
@@ -270,9 +273,11 @@ class ImsVnf(vnf_base.VnfOnBoardingBase):
"signup_code": "secret"}
rq = requests.post(url, data=params)
- i = 20
+ i = 30
while rq.status_code != 201 and i > 0:
rq = requests.post(url, data=params)
+ self.logger.debug("Account creation http status code: %s"
+ % rq.status_code)
i = i - 1
time.sleep(10)
@@ -281,8 +286,7 @@ class ImsVnf(vnf_base.VnfOnBoardingBase):
rq = requests.post(url, data=params)
cookies = rq.cookies
else:
- self.step_failure("Unable to create an account for number" +
- " provision: %s" % rq.json()['reason'])
+ self.step_failure("Unable to create an account")
url = ellis_url + "accounts/" + params['email'] + "/numbers"
if cookies != "":
@@ -290,6 +294,8 @@ class ImsVnf(vnf_base.VnfOnBoardingBase):
i = 24
while rq.status_code != 200 and i > 0:
rq = requests.post(url, cookies=cookies)
+ self.logger.debug("Number creation http status code: %s"
+ % rq.status_code)
i = i - 1
time.sleep(25)
diff --git a/functest/opnfv_tests/vnf/ims/orchestra_ims.py b/functest/opnfv_tests/vnf/ims/orchestra_ims.py
index 42b218e62..d13fe8fe8 100644
--- a/functest/opnfv_tests/vnf/ims/orchestra_ims.py
+++ b/functest/opnfv_tests/vnf/ims/orchestra_ims.py
@@ -245,7 +245,7 @@ class ImsVnf(vnf_base.VnfOnBoardingBase):
% (self.imagename, network_id, userdata))
instance = os_utils.create_instance_and_wait_for_active(
- "m1.medium",
+ "orchestra",
os_utils.get_image_id(glance_client, self.imagename),
network_id,
"orchestra-openbaton",
@@ -308,12 +308,15 @@ class ImsVnf(vnf_base.VnfOnBoardingBase):
if self.ob_projectid == "":
self.step_failure("Default project id was not found!")
+ creds = os_utils.get_credentials()
+ self.logger.info("PoP creds: %s" % creds)
+
vim_json = {
"name": "vim-instance",
- "authUrl": os_utils.get_credentials().get("auth_url"),
- "tenant": os_utils.get_credentials().get("tenant_name"),
- "username": os_utils.get_credentials().get("username"),
- "password": os_utils.get_credentials().get("password"),
+ "authUrl": creds.get("auth_url"),
+ "tenant": os.environ.get("OS_PROJECT_ID"),
+ "username": creds.get("username"),
+ "password": creds.get("password"),
"securityGroups": [
"default",
"orchestra-sec-group"
diff --git a/functest/opnfv_tests/vnf/ims/orchestra_ims.yaml b/functest/opnfv_tests/vnf/ims/orchestra_ims.yaml
index 86d6e604a..5923a775a 100644
--- a/functest/opnfv_tests/vnf/ims/orchestra_ims.yaml
+++ b/functest/opnfv_tests/vnf/ims/orchestra_ims.yaml
@@ -2,8 +2,8 @@ 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_link: http://get.openbaton.org/bootstrap
- bootstrap_config_link: http://get.openbaton.org/bootstrap-config-file
+ bootstrap_link: http://get.openbaton.org/bootstraps/bootstrap_3.2.0_opnfv/bootstrap
+ bootstrap_config_link: http://get.openbaton.org/bootstraps/bootstrap_3.2.0_opnfv/bootstrap-config-file
marketplace_link: http://marketplace.openbaton.org:8082/api/v1/nsds/fokus/OpenImsCore/3.2.0/json
imagename: ubuntu_14.04
vIMS:
diff --git a/functest/tests/unit/core/test_vnf_base.py b/functest/tests/unit/core/test_vnf_base.py
index 25a74b7c9..1680f03f5 100644
--- a/functest/tests/unit/core/test_vnf_base.py
+++ b/functest/tests/unit/core/test_vnf_base.py
@@ -8,11 +8,9 @@
# http://www.apache.org/licenses/LICENSE-2.0
import logging
-import mock
import unittest
from functest.core import vnf_base
-from functest.core import testcase_base
class VnfBaseTesting(unittest.TestCase):
@@ -37,17 +35,15 @@ class VnfBaseTesting(unittest.TestCase):
"result": "",
"duration": 5}}
- @mock.patch('logging.Logger.error')
- def test_deploy_vnf_unimplemented(self, mock):
- self.assertEqual(self.test.deploy_vnf(),
- testcase_base.TestcaseBase.EX_TESTCASE_FAILED)
- mock.assert_called_with('VNF must be deployed')
-
- @mock.patch('logging.Logger.error')
- def test_test_vnf_unimplemented(self, mock):
- self.assertEqual(self.test.test_vnf(),
- testcase_base.TestcaseBase.EX_TESTCASE_FAILED)
- mock.assert_called_with('VNF must be tested')
+ def test_deploy_vnf_unimplemented(self):
+ with self.assertRaises(Exception) as context:
+ self.test.deploy_vnf()
+ self.assertTrue('VNF not deployed' in context.exception)
+
+ def test_test_vnf_unimplemented(self):
+ with self.assertRaises(Exception) as context:
+ self.test.test_vnf()()
+ self.assertTrue('VNF not tested' in context.exception)
def test_parse_results(self):
self.assertNotEqual(self.test.parse_results(), 0)
diff --git a/functest/tests/unit/utils/test_functest_utils.py b/functest/tests/unit/utils/test_functest_utils.py
index 8bfdb5e49..e5bae62f6 100644
--- a/functest/tests/unit/utils/test_functest_utils.py
+++ b/functest/tests/unit/utils/test_functest_utils.py
@@ -33,6 +33,7 @@ class FunctestUtilsTesting(unittest.TestCase):
self.installer = 'test_installer'
self.scenario = 'test_scenario'
self.build_tag = 'jenkins-functest-fuel-opnfv-jump-2-daily-master-190'
+ self.build_tag_week = 'jenkins-functest-fuel-baremetal-weekly-master-8'
self.version = 'master'
self.node_name = 'test_node_name'
self.project = 'test_project'
@@ -152,11 +153,21 @@ class FunctestUtilsTesting(unittest.TestCase):
self.scenario)
@mock.patch('functest.utils.functest_utils.get_build_tag')
- def test_get_version_default(self, mock_get_build_tag):
+ def test_get_version_daily_job(self, mock_get_build_tag):
mock_get_build_tag.return_value = self.build_tag
self.assertEqual(functest_utils.get_version(), self.version)
@mock.patch('functest.utils.functest_utils.get_build_tag')
+ def test_get_version_weekly_job(self, mock_get_build_tag):
+ mock_get_build_tag.return_value = self.build_tag_week
+ self.assertEqual(functest_utils.get_version(), self.version)
+
+ @mock.patch('functest.utils.functest_utils.get_build_tag')
+ def test_get_version_with_dummy_build_tag(self, mock_get_build_tag):
+ mock_get_build_tag.return_value = 'whatever'
+ self.assertEqual(functest_utils.get_version(), 'unknown')
+
+ @mock.patch('functest.utils.functest_utils.get_build_tag')
def test_get_version_unknown(self, mock_get_build_tag):
mock_get_build_tag.return_value = "unknown_build_tag"
self.assertEqual(functest_utils.get_version(), "unknown")
diff --git a/functest/utils/functest_utils.py b/functest/utils/functest_utils.py
index e5e755d7f..9e13ffe90 100644
--- a/functest/utils/functest_utils.py
+++ b/functest/utils/functest_utils.py
@@ -111,12 +111,13 @@ def get_version():
# if launched through CI the build tag has the following format
# jenkins-<project>-<installer>-<pod>-<job>-<branch>-<id>
# e.g. jenkins-functest-fuel-opnfv-jump-2-daily-master-190
+ # jenkins-functest-fuel-baremetal-weekly-master-8
# use regex to match branch info
- rule = "daily-(.+?)-[0-9]*"
+ rule = "(dai|week)ly-(.+?)-[0-9]*"
build_tag = get_build_tag()
m = re.search(rule, build_tag)
if m:
- return m.group(1)
+ return m.group(2)
else:
return "unknown"
@@ -156,8 +157,6 @@ def get_db_url():
# if TEST_DB_URL declared in env variable, use it!
db_url = os.environ['TEST_DB_URL']
except KeyError:
- logger.info("DB URL not declared as env variable,"
- "use local configuration")
db_url = get_functest_config('results.test_db_url')
return db_url