Fix pushing of manifests whose layers share blobs

If a blob was repeated previously, we would get a constraint error from the ManifestBlob table
This commit is contained in:
Joseph Schorr 2018-08-07 13:06:30 -04:00
parent 92743ca57b
commit 9669320df2
2 changed files with 39 additions and 8 deletions

View file

@ -1104,3 +1104,25 @@ def test_login_scopes(username, password, scopes, expected_access, expect_succes
{'SERVER_HOSTNAME': 'localhost:5000'})
assert payload is not None
assert payload['access'] == expected_access
def test_push_pull_same_blobs(pusher, puller, liveserver_session, app_reloader):
""" Test: Push and pull of an image to a new repository where a blob is shared between layers. """
credentials = ('devtable', 'password')
layer_bytes = layer_bytes_for_contents('some contents')
images = [
Image(id='parentid', bytes=layer_bytes, parent_id=None),
Image(id='someid', bytes=layer_bytes, parent_id='parentid'),
]
options = ProtocolOptions()
options.skip_head_checks = True # Since the blob will already exist.
# Push a new repository.
pusher.push(liveserver_session, 'devtable', 'newrepo', 'latest', images,
credentials=credentials, options=options)
# Pull the repository to verify.
puller.pull(liveserver_session, 'devtable', 'newrepo', 'latest', images,
credentials=credentials, options=options)