Catch connection errors
This commit is contained in:
@@ -18,12 +18,15 @@ import tenacity
|
||||
import contextlib
|
||||
from keystoneauth1.exceptions.http import NotFound as http_NotFound
|
||||
import logging
|
||||
from requests.exceptions import ConnectionError
|
||||
import zaza.openstack.charm_tests.keystone.tests as ks_tests
|
||||
import zaza.openstack.charm_tests.tempest.tests as tempest_tests
|
||||
import zaza.charm_lifecycle.utils as lifecycle_utils
|
||||
import zaza.model
|
||||
import subprocess
|
||||
|
||||
class KeystoneLookupError(Exception):
|
||||
pass
|
||||
|
||||
class LdapExplicitCharmConfigTestsK8S(ks_tests.LdapExplicitCharmConfigTests):
|
||||
"""Keystone LDAP tests for K8s deployment."""
|
||||
@@ -105,23 +108,23 @@ class LdapExplicitCharmConfigTestsK8S(ks_tests.LdapExplicitCharmConfigTests):
|
||||
|
||||
@tenacity.retry(wait=tenacity.wait_exponential(multiplier=2, max=60),
|
||||
reraise=True, stop=tenacity.stop_after_attempt(5),
|
||||
retry=tenacity.retry_if_exception_type(http_NotFound))
|
||||
retry=tenacity.retry_if_exception_type(KeystoneLookupError))
|
||||
def _find_keystone_v3_group(self, group, domain):
|
||||
logging.info('Looking for group: {}'.format(group))
|
||||
try:
|
||||
return super()._find_keystone_v3_group(group, domain)
|
||||
except AttributeError:
|
||||
raise http_NotFound
|
||||
except (AttributeError, http_NotFound, ConnectionError) as error:
|
||||
raise KeystoneLookupError
|
||||
|
||||
@tenacity.retry(wait=tenacity.wait_exponential(multiplier=2, max=60),
|
||||
reraise=True, stop=tenacity.stop_after_attempt(5),
|
||||
retry=tenacity.retry_if_exception_type(http_NotFound))
|
||||
retry=tenacity.retry_if_exception_type(KeystoneLookupError))
|
||||
def _find_keystone_v3_user(self, username, domain, group=None):
|
||||
logging.info('Looking for user: {}'.format(username))
|
||||
try:
|
||||
return super()._find_keystone_v3_user(username, domain, group=group)
|
||||
except AttributeError:
|
||||
raise http_NotFound
|
||||
except (AttributeError, http_NotFound, ConnectionError) as error:
|
||||
raise KeystoneLookupError
|
||||
|
||||
|
||||
class KeystoneTempestTestK8S(tempest_tests.TempestTestScaleK8SBase):
|
||||
|
||||
Reference in New Issue
Block a user