Add test for verb pulling when the tag has changed images

This commit is contained in:
Joseph Schorr 2015-11-24 11:18:56 -05:00
parent 1eb019cd16
commit 8d05d40cf7

View file

@ -926,6 +926,43 @@ class V1PullV2PushRegistryTests(V1RegistryPullMixin, V2RegistryPushMixin, Regist
class VerbTests(RegistryTestCaseMixin, V1RegistryPushMixin, LiveServerTestCase):
""" Tests for registry verbs. """
def get_squashed_image(self):
response = self.conduct('GET', '/c1/squash/devtable/newrepo/latest', auth='sig')
tar = tarfile.open(fileobj=StringIO(response.content))
return tar
def test_squashed_changes(self):
initial_images = [
{
'id': 'initialid',
'contents': 'the initial image',
},
]
# Create the repo.
self.do_push('devtable', 'newrepo', 'devtable', 'password', images=initial_images)
initial_image_id = '91081df45b58dc62dd207441785eef2b895f0383fbe601c99a3cf643c79957dc'
# Pull the squashed version of the tag.
tar = self.get_squashed_image()
self.assertTrue(initial_image_id in tar.getnames())
# Change the images.
updated_images = [
{
'id': 'updatedid',
'contents': 'the updated image',
},
]
self.do_push('devtable', 'newrepo', 'devtable', 'password', images=updated_images)
updated_image_id = '38df4bd4cdffc6b7d656dbd2813c73e864f2d362ad887c999ac315224ad281ac'
# Pull the squashed version of the tag and ensure it has changed.
tar = self.get_squashed_image()
self.assertTrue(updated_image_id in tar.getnames())
def test_multilayer_squashing(self):
images = [
{
@ -943,9 +980,6 @@ class VerbTests(RegistryTestCaseMixin, V1RegistryPushMixin, LiveServerTestCase):
self.do_push('devtable', 'newrepo', 'devtable', 'password', images=images)
# Pull the squashed version of the tag.
response = self.conduct('GET', '/c1/squash/devtable/newrepo/latest', auth='sig')
tar = tarfile.open(fileobj=StringIO(response.content))
expected_image_id = 'bd590ae79fba5ebc6550aaf016c0bd0f49b1d78178e0f83e0ca1c56c2bb7e7bf'
expected_names = ['repositories',
@ -954,6 +988,7 @@ class VerbTests(RegistryTestCaseMixin, V1RegistryPushMixin, LiveServerTestCase):
'%s/VERSION' % expected_image_id,
'%s/layer.tar' % expected_image_id]
tar = self.get_squashed_image()
self.assertEquals(expected_names, tar.getnames())
self.assertEquals('1.0', tar.extractfile(tar.getmember('%s/VERSION' % expected_image_id)).read())