diff --git a/test/registry_tests.py b/test/registry_tests.py index 632644542..0f7309640 100644 --- a/test/registry_tests.py +++ b/test/registry_tests.py @@ -1434,6 +1434,82 @@ class TorrentV2PushTests(RegistryTestCaseMixin, TorrentTestMixin, V2RegistryPush pass +class ACIConversionTests(RegistryTestCaseMixin, V1RegistryPushMixin, LiveServerTestCase): + """ Tests for registry ACI conversion. """ + + def get_converted_image(self): + response = self.conduct('GET', '/c1/aci/localhost:5000/devtable/newrepo/latest/aci/linux/amd64', auth='sig') + tar = tarfile.open(fileobj=StringIO(response.content)) + return tar, response.content + + def test_basic_conversion(self): + initial_images = [ + { + 'id': 'initialid', + 'contents': 'the initial image', + }, + ] + + # Create the repo. + self.do_push('devtable', 'newrepo', 'devtable', 'password', images=initial_images) + + # Pull the squashed version of the tag. + tar, _ = self.get_converted_image() + self.assertEquals(['manifest', 'rootfs', 'rootfs/contents'], tar.getnames()) + + manifest = json.loads(tar.extractfile(tar.getmember('manifest')).read()) + expected_manifest = { + "acKind": "ImageManifest", + "app": { + "environment": [], + "mountPoints": [], + "group": "root", + "user": "root", + "workingDirectory": "/", + "exec": [], + "isolators": [], + "eventHandlers": [], + "ports": [], + "annotations": [ + {"name": "created", "value": ""}, + {"name": "homepage", "value": "http://localhost:5000/devtable/newrepo:latest"}, + {"name": "quay.io/derived-image", "value": "fa916d5ca4da5348628dfffcfc943288a0cca521cd21a6d2981a85ec1d7f7a3a"} + ] + }, + "labels": [ + {"name": "version", "value": "latest"}, + {"name": "arch", "value": "amd64"}, + {"name": "os", "value": "linux"} + ], + "acVersion": "0.6.1", + "name": "localhost/devtable/newrepo" + } + + self.assertEquals(manifest, expected_manifest) + self.assertEquals('the initial image', tar.extractfile(tar.getmember('rootfs/contents')).read()) + + def test_multilayer_conversion(self): + images = [ + { + 'id': 'latestid', + 'contents': 'the latest image', + 'parent': 'baseid', + }, + { + 'id': 'baseid', + 'contents': 'The base image', + } + ] + + # Create the repo. + self.do_push('devtable', 'newrepo', 'devtable', 'password', images=images) + + # Pull the squashed version of the tag. + tar, _ = self.get_converted_image() + self.assertEquals(['manifest', 'rootfs', 'rootfs/contents'], tar.getnames()) + self.assertEquals('the latest image', tar.extractfile(tar.getmember('rootfs/contents')).read()) + + class SquashingTests(RegistryTestCaseMixin, V1RegistryPushMixin, LiveServerTestCase): """ Tests for registry squashing. """