From e8a4a1fcd4d28482d6dfae81fb7c8690805f02de Mon Sep 17 00:00:00 2001 From: Remi Rampin Date: Mon, 25 Nov 2024 16:55:14 -0500 Subject: [PATCH 1/3] tests: Don't send HEAD requests to Vagrant vagrantcloud now returns 501 (unsupported) for HEAD requests. --- tests/check_images.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/check_images.py b/tests/check_images.py index f6a7dd594..92da2e783 100644 --- a/tests/check_images.py +++ b/tests/check_images.py @@ -20,7 +20,7 @@ logger = logging.getLogger(__name__) -def _vagrant_req(method, url, json): +def _vagrant_req(method, url, *, json=False, stream=False): headers = {'User-Agent': 'reprozip testsuite'} if json: headers['Accept'] = 'application/json' @@ -30,6 +30,7 @@ def _vagrant_req(method, url, json): url, headers=headers, allow_redirects=True, + stream=stream, ) if res.status_code == 429: logger.info("(got 429, sleeping)") @@ -57,7 +58,7 @@ def check_vagrant(): metadata = _vagrant_req( 'GET', url, - True, + json=True, ) if metadata.status_code != 200: logger.error( @@ -83,9 +84,9 @@ def check_vagrant(): for provider in max_version['providers']: url = provider['url'] res = _vagrant_req( - 'HEAD', + 'GET', # HEAD no longer works url, - False, + stream=True, ) # Status should be 200 if res.status_code != 200: @@ -110,6 +111,7 @@ def check_vagrant(): error = True else: logger.info("Vagrant box ok: %s (%s)", box, provider['name']) + res.close() if error: raise AssertionError("Missing Vagrant boxes") From 3f72dc5e73bf8c1134267063bc19325f75831ff5 Mon Sep 17 00:00:00 2001 From: Remi Rampin Date: Tue, 26 Nov 2024 13:29:11 -0500 Subject: [PATCH 2/3] tests: Use HEAD but ignore 501 from vagrantup.com Sending many GET requests runs into rate limit. --- tests/check_images.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/check_images.py b/tests/check_images.py index 92da2e783..6377512a6 100644 --- a/tests/check_images.py +++ b/tests/check_images.py @@ -20,7 +20,7 @@ logger = logging.getLogger(__name__) -def _vagrant_req(method, url, *, json=False, stream=False): +def _vagrant_req(method, url, *, json=False): headers = {'User-Agent': 'reprozip testsuite'} if json: headers['Accept'] = 'application/json' @@ -30,7 +30,6 @@ def _vagrant_req(method, url, *, json=False, stream=False): url, headers=headers, allow_redirects=True, - stream=stream, ) if res.status_code == 429: logger.info("(got 429, sleeping)") @@ -84,12 +83,20 @@ def check_vagrant(): for provider in max_version['providers']: url = provider['url'] res = _vagrant_req( - 'GET', # HEAD no longer works + 'HEAD', url, - stream=True, ) + # Special case: Vagrant disallow HEAD, but let's assume the box is + # up if we got redirected to it + if ( + res.status_code == 501 + and res.history + and res.url.startswith('https://app.vagrantup.com/') + and res.url.endswith('.box') + ): + pass # Status should be 200 - if res.status_code != 200: + elif res.status_code != 200: logger.error( "Got %d getting Vagrant box %s: %s", res.status_code, box, url, From 945a96955d041dae3a956889e31d5487769c691e Mon Sep 17 00:00:00 2001 From: Remi Rampin Date: Tue, 26 Nov 2024 13:32:00 -0500 Subject: [PATCH 3/3] tests: More logging during image checks --- tests/check_images.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/check_images.py b/tests/check_images.py index 6377512a6..a6d407652 100644 --- a/tests/check_images.py +++ b/tests/check_images.py @@ -52,6 +52,8 @@ def check_vagrant(): # Check that they exist for box in boxes: + logger.info("Checking Vagrant box %s...", box) + # Get metadata url = 'https://vagrantcloud.com/' + box metadata = _vagrant_req( @@ -186,6 +188,7 @@ def check_docker(): # Check that each repository has the required tags for repository, tags in iteritems(repositories): + logger.info("Checking Docker repository %s...", '/'.join(repository)) try: actual_tags = list_docker_tags(repository) except requests.HTTPError as e: