Skip to content

Commit

Permalink
Merge branch 'test-vagrant-images' into '1.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
remram44 committed Nov 26, 2024
2 parents 2ae8fd9 + e1ae284 commit 64c7436
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions tests/check_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
logger = logging.getLogger(__name__)


def _vagrant_req(method, url, json):
def _vagrant_req(method, url, json=False):
headers = {'User-Agent': 'reprozip testsuite'}
if json:
headers['Accept'] = 'application/json'
Expand Down Expand Up @@ -52,12 +52,14 @@ 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(
'GET',
url,
True,
json=True,
)
if metadata.status_code != 200:
logger.error(
Expand Down Expand Up @@ -85,10 +87,18 @@ def check_vagrant():
res = _vagrant_req(
'HEAD',
url,
False,
)
# 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,
Expand All @@ -110,6 +120,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")
Expand Down Expand Up @@ -177,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:
Expand Down

0 comments on commit 64c7436

Please sign in to comment.