Fix ACI conversion and add a registry test for it

This commit is contained in:
Joseph Schorr 2018-09-13 14:12:23 -04:00
parent a4f1475de4
commit 3bd1b21ca9
4 changed files with 74 additions and 7 deletions

View file

@ -33,7 +33,7 @@ def sized_images():
Image(id='parentid', bytes=parent_bytes, parent_id=None, size=len(parent_bytes),
config={'foo': 'bar'}),
Image(id='someid', bytes=image_bytes, parent_id='parentid', size=len(image_bytes),
config={'foo': 'childbar'}),
config={'foo': 'childbar', 'Entrypoint': ['hello']}),
]

View file

@ -950,6 +950,8 @@ def test_multilayer_squashed_images(use_estimates, pusher, multi_layer_images, l
# Pull the squashed version.
response = liveserver_session.get('/c1/squash/devtable/newrepo/latest', auth=credentials)
assert response.status_code == 200
tar = tarfile.open(fileobj=StringIO(response.content))
# Verify the squashed image.
@ -1002,6 +1004,8 @@ def test_squashed_images(use_estimates, pusher, sized_images, liveserver_session
# Pull the squashed version.
response = liveserver_session.get('/c1/squash/devtable/newrepo/latest', auth=credentials)
assert response.status_code == 200
tar = tarfile.open(fileobj=StringIO(response.content))
# Verify the squashed image.
@ -1030,6 +1034,60 @@ def test_squashed_images(use_estimates, pusher, sized_images, liveserver_session
assert tar.extractfile('contents').read() == 'some contents'
EXPECTED_ACI_MANIFEST = {
"acKind": "ImageManifest",
"app": {
"environment": [],
"mountPoints": [],
"group": "root",
"user": "root",
"workingDirectory": "/",
"exec": [u'/bin/sh', u'-c', u'""hello""'],
"isolators": [],
"eventHandlers": [],
"ports": [],
"annotations": [
{"name": "created", "value": ""},
{"name": "homepage", "value": "http://localhost:5000/devtable/newrepo:latest"},
{"name": "quay.io/derived-image",
"value": "035333848582cdb72d2bac4a0809bc7eed9d88004cfb3463562013fce53c2499"},
]
},
"labels": [
{"name": "version", "value": "latest"},
{"name": "arch", "value": "amd64"},
{"name": "os", "value": "linux"}
],
"acVersion": "0.6.1",
"name": "localhost/devtable/newrepo",
}
def test_aci_conversion(pusher, sized_images, liveserver_session,
liveserver, registry_server_executor, app_reloader):
""" Test: Pulling of ACI converted images. """
credentials = ('devtable', 'password')
# Push an image to download.
pusher.push(liveserver_session, 'devtable', 'newrepo', 'latest', sized_images,
credentials=credentials)
# Pull the ACI version.
response = liveserver_session.get('/c1/aci/server_name/devtable/newrepo/latest/aci/linux/amd64',
auth=credentials)
assert response.status_code == 200
tar = tarfile.open(fileobj=StringIO(response.content))
assert set(tar.getnames()) == {'manifest', 'rootfs', 'rootfs/contents'}
assert tar.extractfile('rootfs/contents').read() == 'some contents'
assert json.loads(tar.extractfile('manifest').read()) == EXPECTED_ACI_MANIFEST
# Pull the ACI signature.
response = liveserver_session.get('/c1/aci/server_name/devtable/newrepo/latest/aci.asc/linux/amd64',
auth=credentials)
assert response.status_code == 200
@pytest.mark.parametrize('push_user, push_namespace, push_repo, mount_repo_name, expected_failure', [
# Successful mount, same namespace.
('devtable', 'devtable', 'baserepo', 'devtable/baserepo', None),