aboutsummaryrefslogtreecommitdiffstats
path: root/functest/ci
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2018-01-21 01:02:20 +0100
committerCédric Ollivier <cedric.ollivier@orange.com>2018-01-21 14:53:47 +0100
commit2030e14451a072844e750318de0d5efc47d4500c (patch)
tree47e79f3244d233d6edbe11e30150185ed12a59e0 /functest/ci
parenta6df43da7ab4de653eecbc9b6380d5fc7ce7bc14 (diff)
Fully test and cover functest/ci/tier_*
It also fixes check_deployment.py and ci unit tests which were wrong when testing exceptions. Now ci modules are rated 10/10 and fully covered. Change-Id: I30dca491b44cc54aa1abc0d0433c00b4dcabfdc4 Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest/ci')
-rw-r--r--functest/ci/check_deployment.py29
-rw-r--r--functest/ci/tier_builder.py23
2 files changed, 27 insertions, 25 deletions
diff --git a/functest/ci/check_deployment.py b/functest/ci/check_deployment.py
index 9453c6d4..81607dff 100644
--- a/functest/ci/check_deployment.py
+++ b/functest/ci/check_deployment.py
@@ -18,18 +18,18 @@ Verifies that:
import logging
import logging.config
import os
-import pkg_resources
-from six.moves import urllib
import socket
-from functest.opnfv_tests.openstack.snaps import snaps_utils
-
+import pkg_resources
+from six.moves import urllib
from snaps.openstack.tests import openstack_tests
from snaps.openstack.utils import glance_utils
from snaps.openstack.utils import keystone_utils
from snaps.openstack.utils import neutron_utils
from snaps.openstack.utils import nova_utils
+from functest.opnfv_tests.openstack.snaps import snaps_utils
+
__author__ = "Jose Lausuch <jose.lausuch@ericsson.com>"
LOGGER = logging.getLogger(__name__)
@@ -37,18 +37,21 @@ LOGGER = logging.getLogger(__name__)
def verify_connectivity(endpoint):
""" Returns true if an hostname/port is reachable"""
- connection = socket.socket()
- connection.settimeout(10)
- hostname = urllib.parse.urlparse(endpoint).hostname
- port = urllib.parse.urlparse(endpoint).port
- if not port:
- port = 443 if urllib.parse.urlparse(endpoint).scheme == "https" else 80
try:
- connection.connect((hostname, port))
- LOGGER.debug('%s:%s is reachable!', hostname, port)
+ connection = socket.socket()
+ connection.settimeout(10)
+ url = urllib.parse.urlparse(endpoint)
+ port = url.port
+ if not port:
+ port = 443 if url.scheme == "https" else 80
+ connection.connect(url.hostname, port)
+ LOGGER.debug('%s:%s is reachable!', url.hostname, port)
return True
except socket.error:
- LOGGER.exception('%s:%s is not reachable.', hostname, port)
+ LOGGER.error('%s:%s is not reachable.', url.hostname, port)
+ except Exception: # pylint: disable=broad-except
+ LOGGER.exception(
+ 'Errors when verifying connectivity to %s:%s', url.hostname, port)
return False
diff --git a/functest/ci/tier_builder.py b/functest/ci/tier_builder.py
index 9e92599d..370ab94d 100644
--- a/functest/ci/tier_builder.py
+++ b/functest/ci/tier_builder.py
@@ -40,24 +40,23 @@ class TierBuilder(object):
del self.tier_objects[:]
for dic_tier in self.dic_tier_array:
- tier = th.Tier(name=dic_tier['name'],
- order=dic_tier['order'],
- ci_loop=dic_tier['ci_loop'],
- description=dic_tier['description'])
+ tier = th.Tier(
+ name=dic_tier['name'], order=dic_tier['order'],
+ ci_loop=dic_tier['ci_loop'],
+ description=dic_tier['description'])
for dic_testcase in dic_tier['testcases']:
installer = dic_testcase['dependencies']['installer']
scenario = dic_testcase['dependencies']['scenario']
dep = th.Dependency(installer, scenario)
- testcase = th.TestCase(name=dic_testcase['case_name'],
- enabled=dic_testcase.get(
- 'enabled', True),
- dependency=dep,
- criteria=dic_testcase['criteria'],
- blocking=dic_testcase['blocking'],
- description=dic_testcase['description'],
- project=dic_testcase['project_name'])
+ testcase = th.TestCase(
+ name=dic_testcase['case_name'],
+ enabled=dic_testcase.get('enabled', True),
+ dependency=dep, criteria=dic_testcase['criteria'],
+ blocking=dic_testcase['blocking'],
+ description=dic_testcase['description'],
+ project=dic_testcase['project_name'])
if (testcase.is_compatible(self.ci_installer,
self.ci_scenario) and
testcase.is_enabled()):