Skip to content

Commit

Permalink
Merge pull request #5153 from flouthoc/bump-c-image
Browse files Browse the repository at this point in the history
blobcacheinfo,test: blobs must be resued when pushing across registry
  • Loading branch information
openshift-merge-bot[bot] authored Nov 17, 2023
2 parents 8dc66bb + 3c61dfd commit 6622a7b
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/blobcache.bats
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,41 @@ function _check_matches() {
expect_output --from="$unmatched" "$5" "$6 should not match"
}

# Integration test for https://github.com/containers/image/pull/1645
@test "blobcache: blobs must be reused when pushing across registry" {
start_registry
run_buildah login --tls-verify=false --authfile ${TEST_SCRATCH_DIR}/test.auth --username testuser --password testpassword localhost:${REGISTRY_PORT}
outputdir=${TEST_SCRATCH_DIR}/outputdir
mkdir -p ${outputdir}
run podman run --rm --mount type=bind,src=${TEST_SCRATCH_DIR}/test.auth,target=/test.auth,Z --mount type=bind,src=${outputdir},target=/output,Z --net host quay.io/skopeo/stable copy --preserve-digests --authfile=/test.auth --tls-verify=false docker://registry.fedoraproject.org/fedora-minimal dir:/output

run_buildah rmi --all -f
run_buildah pull dir:${outputdir}
run_buildah images -a --format '{{.ID}}'
cid=$output
run_buildah --log-level debug push --tls-verify=false --authfile ${TEST_SCRATCH_DIR}/test.auth $cid docker://localhost:${REGISTRY_PORT}/test
# must not contain "Skipping blob" since push must happen
assert "$output" !~ "Skipping blob"

# Clear local image and c/image's blob-info-cache
run_buildah rmi --all -f
if is_rootless;
then
run rm $HOME/.local/share/containers/cache/blob-info-cache-v1.sqlite
assert "$status" -eq 0 "status of `run rm $HOME/.local/share/containers/cache/blob-info-cache-v1.sqlite` must be 0"
else
run rm /var/lib/containers/cache/blob-info-cache-v1.sqlite
assert "$status" -eq 0 "status of `run rm /var/lib/containers/cache/blob-info-cache-v1.sqlite` must be 0"
fi

# In first push blob must be skipped after vendoring https://github.com/containers/image/pull/1645
run_buildah pull dir:${outputdir}
run_buildah images -a --format '{{.ID}}'
cid=$output
run_buildah --log-level debug push --tls-verify=false --authfile ${TEST_SCRATCH_DIR}/test.auth $cid docker://localhost:${REGISTRY_PORT}/test
expect_output --substring "Skipping blob"
}

@test "blobcache-commit" {
blobcachedir=${TEST_SCRATCH_DIR}/cache
mkdir -p ${blobcachedir}
Expand Down

0 comments on commit 6622a7b

Please sign in to comment.