verification: set timeout for requests.get when testing for Horizon
The default timeout for requests.get is None. Because of that the requests.get call will hang forever if no Horizion dashboard is available. Change-Id: Ibbe7ff1ada234b6b733be2c29c278f0f0711219d Closes-bug: #1501696
This commit is contained in:
parent
0a312c2be9
commit
8a27449820
@ -223,9 +223,11 @@ class TempestConfig(object):
|
||||
horizon_url = ("http://" +
|
||||
parse.urlparse(self.endpoint["auth_url"]).hostname)
|
||||
try:
|
||||
horizon_req = requests.get(horizon_url)
|
||||
except requests.RequestException:
|
||||
LOG.debug("Horizon is unavailable!")
|
||||
horizon_req = requests.get(
|
||||
horizon_url,
|
||||
timeout=CONF.openstack_client_http_timeout)
|
||||
except requests.RequestException as e:
|
||||
LOG.debug("Failed to connect to Horizon: %s" % e)
|
||||
horizon_availability = False
|
||||
else:
|
||||
horizon_availability = (horizon_req.status_code == 200)
|
||||
|
@ -243,6 +243,11 @@ class ConfigTestCase(test.TestCase):
|
||||
available_services = ("nova", "cinder", "glance", "sahara")
|
||||
self.conf_generator.available_services = available_services
|
||||
self.conf_generator._configure_service_available()
|
||||
expected_horizon_url = "http://test"
|
||||
expected_timeout = CONF.openstack_client_http_timeout
|
||||
mock_requests.get.assert_called_once_with(
|
||||
expected_horizon_url,
|
||||
timeout=expected_timeout)
|
||||
expected = (("neutron", "False"), ("heat", "False"),
|
||||
("ceilometer", "False"), ("swift", "False"),
|
||||
("cinder", "True"), ("nova", "True"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user