From 7a8432451e95639e586a7531edfdde833417ec29 Mon Sep 17 00:00:00 2001 From: Guillaume Boutry Date: Mon, 27 Jan 2025 09:27:50 +0100 Subject: [PATCH] Allow passing service_codes to wait_for_all_endpoints Some projects will return specific failed code when up because of templating in URL. In some other case, due to the nature of the test, the service will never go up but be present in keystone. Allow the caller to override which service returns a specific code. Signed-off-by: Guillaume Boutry --- zaza/openstack/charm_tests/keystone/setup.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/zaza/openstack/charm_tests/keystone/setup.py b/zaza/openstack/charm_tests/keystone/setup.py index 6134cdb..7f01425 100644 --- a/zaza/openstack/charm_tests/keystone/setup.py +++ b/zaza/openstack/charm_tests/keystone/setup.py @@ -170,22 +170,25 @@ def add_tempest_roles(): _add_additional_roles(TEMPEST_ROLES) -def wait_for_all_endpoints(interface='public'): +def wait_for_all_endpoints(interface='public', service_codes=None): """Check all endpoints are returning an acceptable return code. :param interface: Endpoint type to check. public, admin or internal :type interface: str + :param service_codes: Dict of service names and acceptable return codes + :type service_codes: Optional[dict] :raises: AssertionError """ + if service_codes is None: + service_codes = {} keystone_client = openstack_utils.get_keystone_overcloud_session_client() for service in keystone_client.services.list(): for ep in keystone_client.endpoints.list(service=service, interface=interface): openstack_utils.wait_for_url( ep.url, - # Heat cloudformation and orchestration return 400 and 401 [ requests.codes.ok, requests.codes.multiple_choices, - requests.codes.bad_request, - requests.codes.unauthorized]) + requests.codes.unauthorized, + ] + service_codes.get(service.name, []))