Make sure registry pull tests verify the images expected
This commit is contained in:
parent
d0dc8fe45d
commit
b0ed930627
1 changed files with 27 additions and 7 deletions
|
@ -272,7 +272,10 @@ class V1RegistryPushMixin(V1RegistryMixin):
|
|||
|
||||
|
||||
class V1RegistryPullMixin(V1RegistryMixin):
|
||||
def do_pull(self, namespace, repository, username=None, password='password', expected_code=200):
|
||||
def do_pull(self, namespace, repository, username=None, password='password', expected_code=200,
|
||||
images=None):
|
||||
images = images or self._get_default_images()
|
||||
|
||||
auth = None
|
||||
if username:
|
||||
auth = (username, password)
|
||||
|
@ -290,7 +293,12 @@ class V1RegistryPullMixin(V1RegistryMixin):
|
|||
# GET /v1/repositories/{namespace}/{repository}/
|
||||
result = json.loads(self.conduct('GET', prefix + 'tags', auth='sig').text)
|
||||
|
||||
for image_id in result.values():
|
||||
self.assertEquals(len(images), len(result.values()))
|
||||
|
||||
for image_data in images:
|
||||
image_id = image_data['id']
|
||||
self.assertIn(image_id, result.values())
|
||||
|
||||
# /v1/images/{imageID}/{ancestry, json, layer}
|
||||
image_prefix = '/v1/images/%s/' % image_id
|
||||
self.conduct('GET', image_prefix + 'ancestry', auth='sig')
|
||||
|
@ -469,7 +477,9 @@ class V2RegistryPushMixin(V2RegistryMixin):
|
|||
|
||||
class V2RegistryPullMixin(V2RegistryMixin):
|
||||
def do_pull(self, namespace, repository, username=None, password='password', expected_code=200,
|
||||
manifest_id=None, expected_manifest_code=200):
|
||||
manifest_id=None, expected_manifest_code=200, images=None):
|
||||
images = images or self._get_default_images()
|
||||
|
||||
# Ping!
|
||||
self.v2_ping()
|
||||
|
||||
|
@ -491,8 +501,8 @@ class V2RegistryPullMixin(V2RegistryMixin):
|
|||
# Ensure the manifest returned by us is valid.
|
||||
validate_schema(manifest_data, V2RegistryMixin.MANIFEST_SCHEMA)
|
||||
|
||||
# Verify the layers.
|
||||
blobs = {}
|
||||
|
||||
for layer in manifest_data['fsLayers']:
|
||||
blob_id = layer['blobSum']
|
||||
result = self.conduct('GET', '/v2/%s/%s/blobs/%s' % (namespace, repository, blob_id),
|
||||
|
@ -500,6 +510,16 @@ class V2RegistryPullMixin(V2RegistryMixin):
|
|||
|
||||
blobs[blob_id] = result.text
|
||||
|
||||
# Verify the V1 metadata is present for each expected image.
|
||||
found_v1_layers = set()
|
||||
history = manifest_data['history']
|
||||
for entry in history:
|
||||
v1_history = json.loads(entry['v1Compatibility'])
|
||||
found_v1_layers.add(v1_history['id'])
|
||||
|
||||
for image in images:
|
||||
self.assertIn(image['id'], found_v1_layers)
|
||||
|
||||
return blobs
|
||||
|
||||
|
||||
|
@ -703,7 +723,7 @@ class V2RegistryTests(V2RegistryPullMixin, V2RegistryPushMixin, RegistryTestsMix
|
|||
self.do_push('devtable', 'newrepo', 'devtable', 'password', images=images)
|
||||
|
||||
# Pull the image back and verify the contents.
|
||||
blobs = self.do_pull('devtable', 'newrepo', 'devtable', 'password')
|
||||
blobs = self.do_pull('devtable', 'newrepo', 'devtable', 'password', images=images)
|
||||
self.assertEquals(len(blobs.items()), 1)
|
||||
self.assertEquals(blobs.items()[0][1], contents)
|
||||
|
||||
|
@ -724,7 +744,7 @@ class V2RegistryTests(V2RegistryPullMixin, V2RegistryPushMixin, RegistryTestsMix
|
|||
self.do_push('devtable', 'newrepo', 'devtable', 'password', images=images)
|
||||
|
||||
# Pull the image back and verify the contents.
|
||||
blobs = self.do_pull('devtable', 'newrepo', 'devtable', 'password')
|
||||
blobs = self.do_pull('devtable', 'newrepo', 'devtable', 'password', images=images)
|
||||
self.assertEquals(len(blobs.items()), 1)
|
||||
self.assertEquals(blobs.items()[0][1], contents)
|
||||
|
||||
|
@ -746,7 +766,7 @@ class V2RegistryTests(V2RegistryPullMixin, V2RegistryPushMixin, RegistryTestsMix
|
|||
self.do_push('devtable', 'newrepo', 'devtable', 'password', images=images)
|
||||
|
||||
# Pull the image back and verify the contents.
|
||||
blobs = self.do_pull('devtable', 'newrepo', 'devtable', 'password')
|
||||
blobs = self.do_pull('devtable', 'newrepo', 'devtable', 'password', images=images)
|
||||
self.assertEquals(len(blobs.items()), 1)
|
||||
self.assertEquals(blobs.items()[0][1], contents)
|
||||
|
||||
|
|
Reference in a new issue