Add additional multi-layer complex squashing test
This commit is contained in:
parent
f252b0b16f
commit
7424a6d73a
3 changed files with 99 additions and 3 deletions
|
@ -930,6 +930,58 @@ def test_squashed_image_disabled_user(pusher, sized_images, liveserver_session,
|
|||
assert response.status_code == 403
|
||||
|
||||
|
||||
@pytest.mark.parametrize('use_estimates', [
|
||||
False,
|
||||
True,
|
||||
])
|
||||
def test_multilayer_squashed_images(use_estimates, pusher, multi_layer_images, liveserver_session,
|
||||
liveserver, registry_server_executor, app_reloader):
|
||||
""" Test: Pulling of multilayer, complex squashed images. """
|
||||
credentials = ('devtable', 'password')
|
||||
|
||||
# Push an image to download.
|
||||
pusher.push(liveserver_session, 'devtable', 'newrepo', 'latest', multi_layer_images,
|
||||
credentials=credentials)
|
||||
|
||||
if use_estimates:
|
||||
# Clear the uncompressed size stored for the images, to ensure that we estimate instead.
|
||||
for image in multi_layer_images:
|
||||
registry_server_executor.on(liveserver).clear_uncompressed_size(image.id)
|
||||
|
||||
# Pull the squashed version.
|
||||
response = liveserver_session.get('/c1/squash/devtable/newrepo/latest', auth=credentials)
|
||||
tar = tarfile.open(fileobj=StringIO(response.content))
|
||||
|
||||
# Verify the squashed image.
|
||||
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
|
||||
|
||||
# Verify the JSON image data.
|
||||
json_data = (tar.extractfile(tar.getmember('%s/json' % expected_image_id)).read())
|
||||
|
||||
# Ensure the JSON loads and parses.
|
||||
result = json.loads(json_data)
|
||||
assert result['id'] == expected_image_id
|
||||
assert result['config']['internal_id'] == 'layer5'
|
||||
|
||||
# Ensure that squashed layer tar can be opened.
|
||||
tar = tarfile.open(fileobj=tar.extractfile(tar.getmember('%s/layer.tar' % expected_image_id)))
|
||||
assert set(tar.getnames()) == {'contents', 'file1', 'file2', 'file3', 'file4'}
|
||||
|
||||
# Check the contents of various files.
|
||||
assert tar.extractfile('contents').read() == 'layer 5 contents'
|
||||
assert tar.extractfile('file1').read() == 'from-layer-3'
|
||||
assert tar.extractfile('file2').read() == 'from-layer-2'
|
||||
assert tar.extractfile('file3').read() == 'from-layer-4'
|
||||
assert tar.extractfile('file4').read() == 'from-layer-5'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('use_estimates', [
|
||||
False,
|
||||
True,
|
||||
|
|
Reference in a new issue