From 0eb84f807775c18ae3e4b06488317faab59c70d5 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 26 Nov 2018 12:48:20 +0200 Subject: [PATCH] Add a squashing test for images with empty layers --- test/registry/registry_tests.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/registry/registry_tests.py b/test/registry/registry_tests.py index 24aaedadd..e31836c51 100644 --- a/test/registry/registry_tests.py +++ b/test/registry/registry_tests.py @@ -1575,6 +1575,32 @@ def test_push_pull_manifest_list_duplicate_manifest(v22_protocol, basic_images, credentials=credentials, options=options) +def test_squashed_images_empty_layer(pusher, images_with_empty_layer, liveserver_session, + liveserver, registry_server_executor, app_reloader): + """ Test: Pulling of squashed images for a manifest with empty layers. """ + credentials = ('devtable', 'password') + + # Push an image to download. + pusher.push(liveserver_session, 'devtable', 'newrepo', 'latest', images_with_empty_layer, + credentials=credentials) + + # 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. + 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 + + 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.