Skip to content

Commit

Permalink
trying page_size patch (#239)
Browse files Browse the repository at this point in the history
(cherry picked from commit 33c2eb7)
  • Loading branch information
dericcrago authored and Patchback committed Apr 9, 2021
1 parent 16b5707 commit c15e290
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/utils/shippable/collection_versions_page_size.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@@ -21,7 +21,7 @@
from ansible.galaxy.user_agent import user_agent
from ansible.module_utils.six import string_types
from ansible.module_utils.six.moves.urllib.error import HTTPError
-from ansible.module_utils.six.moves.urllib.parse import quote as urlquote, urlencode, urlparse
+from ansible.module_utils.six.moves.urllib.parse import quote as urlquote, urlencode, urlparse, parse_qs
from ansible.module_utils._text import to_bytes, to_native, to_text
from ansible.module_utils.urls import open_url, prepare_multipart
from ansible.utils.display import Display
@@ -312,6 +312,7 @@
def _call_galaxy(self, url, args=None, headers=None, method=None, auth_required=False, error_context_msg=None,
cache=False):
url_info = urlparse(url)
+ query = parse_qs(url_info.query)
cache_id = get_cache_id(url)
if cache and self._cache:
server_cache = self._cache.setdefault(cache_id, {})
@@ -342,7 +343,7 @@

return res

- elif not url_info.query:
+ elif 'page' not in query:
# The cache entry had expired or does not exist, start a new blank entry to be filled later.
expires = datetime.datetime.utcnow()
expires += datetime.timedelta(days=1)
@@ -781,7 +782,7 @@
api_path = self.available_api_versions['v2']
pagination_path = ['next']

- versions_url = _urljoin(self.api_server, api_path, 'collections', namespace, name, 'versions', '/')
+ versions_url = _urljoin(self.api_server, api_path, 'collections', namespace, name, 'versions', '?page_size=100')
versions_url_info = urlparse(versions_url)

# We should only rely on the cache if the collection has not changed. This may slow things down but it ensures
6 changes: 6 additions & 0 deletions tests/utils/shippable/shippable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ else
export ANSIBLE_COLLECTIONS_PATHS="${PWD}/../../../"
fi

# START: page_size patch
sudo apt update && sudo apt -y install patch
ANSIBLE_DIR=$(ansible --version | grep 'ansible python module location' | sed 's/^.*= //g')
patch --forward "${ANSIBLE_DIR}"/galaxy/api.py tests/utils/shippable/collection_versions_page_size.patch || true
# END: page_size patch

# START: HACK install dependencies
retry ansible-galaxy -vvv collection install ansible.netcommon

Expand Down

0 comments on commit c15e290

Please sign in to comment.