aboutsummaryrefslogtreecommitdiffstats
path: root/functest/ci/check_deployment.py
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/check_deployment.py
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/check_deployment.py')
-rw-r--r--functest/ci/check_deployment.py29
1 files changed, 16 insertions, 13 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