[stable-2.9] Don't remove trailing / on galaxy api URLS (#63294)

This causes multiple unneeded http redirects.
Since each http redirect takes a few hundred
milliseconds, handling the redirects starts to
take up a significant amount of wall time.

Fixes: #63281
(cherry picked from commit d1c39b9068)

Co-authored-by: Adrian Likins <alikins@redhat.com>
pull/66383/head
Adrian Likins 5 years ago committed by Matt Clay
parent 67302136bf
commit 43cf40ffe0

@ -523,7 +523,7 @@ class GalaxyAPI:
:return: CollectionVersionMetadata about the collection at the version requested.
"""
api_path = self.available_api_versions.get('v3', self.available_api_versions.get('v2'))
url_paths = [self.api_server, api_path, 'collections', namespace, name, 'versions', version]
url_paths = [self.api_server, api_path, 'collections', namespace, name, 'versions', version, '/']
n_collection_url = _urljoin(*url_paths)
error_context_msg = 'Error when getting collection version metadata for %s.%s:%s from %s (%s)' \
@ -552,7 +552,7 @@ class GalaxyAPI:
results_key = 'results'
pagination_path = ['next']
n_url = _urljoin(self.api_server, api_path, 'collections', namespace, name, 'versions')
n_url = _urljoin(self.api_server, api_path, 'collections', namespace, name, 'versions', '/')
error_context_msg = 'Error when getting available collection versions for %s.%s from %s (%s)' \
% (namespace, name, self.name, self.api_server)

@ -670,7 +670,7 @@ def test_get_collection_version_metadata_no_version(api_version, token_type, ver
assert actual.dependencies == {}
assert mock_open.call_count == 1
assert mock_open.mock_calls[0][1][0] == '%s%s/collections/namespace/collection/versions/%s' \
assert mock_open.mock_calls[0][1][0] == '%s%s/collections/namespace/collection/versions/%s/' \
% (api.api_server, api_version, version)
# v2 calls dont need auth, so no authz header or token_type
@ -730,7 +730,7 @@ def test_get_collection_versions(api_version, token_type, token_ins, response, m
assert mock_open.call_count == 1
assert mock_open.mock_calls[0][1][0] == 'https://galaxy.server.com/api/%s/collections/namespace/collection/' \
'versions' % api_version
'versions/' % api_version
if token_ins:
assert mock_open.mock_calls[0][2]['headers']['Authorization'] == '%s my token' % token_type
@ -854,7 +854,7 @@ def test_get_collection_versions_pagination(api_version, token_type, token_ins,
assert mock_open.call_count == 3
assert mock_open.mock_calls[0][1][0] == 'https://galaxy.server.com/api/%s/collections/namespace/collection/' \
'versions' % api_version
'versions/' % api_version
assert mock_open.mock_calls[1][1][0] == 'https://galaxy.server.com/api/%s/collections/namespace/collection/' \
'versions/?page=2' % api_version
assert mock_open.mock_calls[2][1][0] == 'https://galaxy.server.com/api/%s/collections/namespace/collection/' \

Loading…
Cancel
Save