From 012e08c07714b08ccc7a38675392fbcc269542d4 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Mon, 27 Jan 2020 09:32:06 +0000 Subject: [PATCH 1/2] Add setup method for swift GR to check regions Add setup method for swift GR to check region count. This ensures the environment is ready before running GR tests. --- zaza/openstack/charm_tests/swift/setup.py | 38 +++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 zaza/openstack/charm_tests/swift/setup.py diff --git a/zaza/openstack/charm_tests/swift/setup.py b/zaza/openstack/charm_tests/swift/setup.py new file mode 100644 index 0000000..06dfb63 --- /dev/null +++ b/zaza/openstack/charm_tests/swift/setup.py @@ -0,0 +1,38 @@ +# Copyright 2020 Canonical Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Code for configuring octavia.""" + +import logging +import tenacity + +import zaza.openstack.utilities.openstack as openstack + + +@tenacity.retry(wait=tenacity.wait_exponential(multiplier=10, max=300), + reraise=True, stop=tenacity.stop_after_attempt(10), + retry=tenacity.retry_if_exception_type(AssertionError)) +def wait_for_region2(): + """Ensure two regions are present.""" + keystone_session = openstack.get_overcloud_keystone_session() + keystone_client = ( + openstack.get_keystone_session_client( + keystone_session, + client_api_version='3')) + swift_svc_id = keystone_client.services.find(name='swift').id + regions = set([ep.region + for ep in keystone_client.endpoints.list(swift_svc_id)]) + logging.info('Checking there are 2 regions. Current count is {}'.format( + len(regions))) + assert len(set(regions)) == 2, "Incorrect number of regions" From 4b9773bb5ecd94120083df1c86fd37e0d31d03d3 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Mon, 27 Jan 2020 10:10:43 +0000 Subject: [PATCH 2/2] Fix copy/pasta error --- zaza/openstack/charm_tests/swift/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zaza/openstack/charm_tests/swift/setup.py b/zaza/openstack/charm_tests/swift/setup.py index 06dfb63..eb98806 100644 --- a/zaza/openstack/charm_tests/swift/setup.py +++ b/zaza/openstack/charm_tests/swift/setup.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Code for configuring octavia.""" +"""Code for configuring swift.""" import logging import tenacity