Fix pulling of squashed versions of the legacy image in a manifest lists
This commit is contained in:
parent
001768c043
commit
1f03fdb27e
10 changed files with 198 additions and 31 deletions
|
@ -1560,3 +1560,72 @@ def test_push_pull_manifest_list_duplicate_manifest(v22_protocol, basic_images,
|
|||
# Pull and verify the manifest list.
|
||||
v22_protocol.pull_list(liveserver_session, 'devtable', 'newrepo', 'latest', manifestlist,
|
||||
credentials=credentials, options=options)
|
||||
|
||||
|
||||
def test_squashed_image_unsupported(v22_protocol, basic_images, liveserver_session, liveserver,
|
||||
app_reloader, data_model):
|
||||
""" Test: Attempting to pull a squashed image for a manifest list without an amd64+linux entry.
|
||||
"""
|
||||
credentials = ('devtable', 'password')
|
||||
if data_model != 'oci_model':
|
||||
return
|
||||
|
||||
credentials = ('devtable', 'password')
|
||||
options = ProtocolOptions()
|
||||
|
||||
# Build the manifest that will go in the list.
|
||||
blobs = {}
|
||||
manifest = v22_protocol.build_schema2(basic_images, blobs, options)
|
||||
|
||||
# Create and push the manifest list.
|
||||
builder = DockerSchema2ManifestListBuilder()
|
||||
builder.add_manifest(manifest, 'foobar', 'someos')
|
||||
manifestlist = builder.build()
|
||||
|
||||
v22_protocol.push_list(liveserver_session, 'devtable', 'newrepo', 'latest', manifestlist,
|
||||
[manifest], blobs,
|
||||
credentials=credentials, options=options)
|
||||
|
||||
# Attempt to pull the squashed version.
|
||||
response = liveserver_session.get('/c1/squash/devtable/newrepo/latest', auth=credentials)
|
||||
assert response.status_code == 404
|
||||
|
||||
|
||||
def test_squashed_image_manifest_list(v22_protocol, basic_images, liveserver_session, liveserver,
|
||||
app_reloader, data_model):
|
||||
""" Test: Pull a squashed image for a manifest list with an amd64+linux entry.
|
||||
"""
|
||||
credentials = ('devtable', 'password')
|
||||
if data_model != 'oci_model':
|
||||
return
|
||||
|
||||
credentials = ('devtable', 'password')
|
||||
options = ProtocolOptions()
|
||||
|
||||
# Build the manifest that will go in the list.
|
||||
blobs = {}
|
||||
manifest = v22_protocol.build_schema2(basic_images, blobs, options)
|
||||
|
||||
# Create and push the manifest list.
|
||||
builder = DockerSchema2ManifestListBuilder()
|
||||
builder.add_manifest(manifest, 'amd64', 'linux')
|
||||
manifestlist = builder.build()
|
||||
|
||||
v22_protocol.push_list(liveserver_session, 'devtable', 'newrepo', 'latest', manifestlist,
|
||||
[manifest], blobs,
|
||||
credentials=credentials, options=options)
|
||||
|
||||
# Pull the squashed version.
|
||||
response = liveserver_session.get('/c1/squash/devtable/newrepo/latest', auth=credentials)
|
||||
assert response.status_code == 200
|
||||
|
||||
# Verify the squashed image.
|
||||
tar = tarfile.open(fileobj=StringIO(response.content))
|
||||
expected_image_id = 'cdc6d6c0d07d2cbacfc579e49ce0c256c5084b9b2b16c1b1b0c45f26a12a4ba5'
|
||||
expected_names = ['repositories',
|
||||
expected_image_id,
|
||||
'%s/json' % expected_image_id,
|
||||
'%s/VERSION' % expected_image_id,
|
||||
'%s/layer.tar' % expected_image_id]
|
||||
|
||||
assert tar.getnames() == expected_names
|
||||
|
|
Reference in a new issue