Skip to content

Commit

Permalink
Workaround the URL formatting issue for product streams
Browse files Browse the repository at this point in the history
When glance-simplestreams-sync charm registers the 'product-streams'
endpoint it uses a trailing slash.  It's not clear whether this is a bug
or not, and the behaviour may have changed in 2021.  The impact is that
the test fails, as it attempts to fetch with two '//' in the URL.  This
patch works around the test issue.  It's not clear whether endpoints
MUST be registered without a trailing slash or not; it would appear that
most are not, but a quick glance at ServerStack show a few with trailing
slashes.
  • Loading branch information
ajkavanagh committed Apr 11, 2022
1 parent 735f948 commit ae3cf12
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions zaza/openstack/charm_tests/glance_simplestreams_sync/tests.py
Expand Up @@ -43,7 +43,13 @@ def get_product_streams(url):
# metadata being written. Use tenacity to avoid this race.
client = requests.session()
json_data = client.get(url, verify=openstack_utils.get_cacert()).text
return json.loads(json_data)
try:
return json.loads(json_data)
except Exception as e:
logging.error("Couldn't decode json, reason: %s, response text to "
"decode:\n%s", str(e), json_data)
raise



class GlanceSimpleStreamsSyncTest(test_utils.OpenStackBaseTest):
Expand Down Expand Up @@ -112,7 +118,13 @@ def _check_local_product_streams(expected_images):
ps_interface = self.keystone_client.service_catalog.url_for(
service_type='product-streams', interface='publicURL'
)
url = "{}/{}".format(ps_interface, uri)
# the product-streams url registered seems to have added a '/' -
# for the test, ensure that the URL is formatted correctly with
# only 1 slash between the ps_interface URL and the uri
if ps_interface.endswith("/"):
url = "{}{}".format(ps_interface, uri)
else:
url = "{}/{}".format(ps_interface, uri)
logging.info('Retrieving product stream information'
' from {}'.format(url))
product_streams = get_product_streams(url)
Expand Down

0 comments on commit ae3cf12

Please sign in to comment.