Skip to content

Commit

Permalink
Merge pull request containers#23907 from edsantiago/safename-020
Browse files Browse the repository at this point in the history
CI: make 020-tag parallel-safe
  • Loading branch information
openshift-merge-bot[bot] authored Sep 10, 2024
2 parents ff0f6eb + 18932e0 commit c38c197
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions test/system/020-tag.bats
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,34 @@ function _tag_and_check() {
run_podman 1 image exists $check_as
}

# bats test_tags=ci:parallel
@test "podman tag/untag" {
registry="bogusregistry.nxdomain"
imgname=i-$(safename)

# Test a fully-qualified image reference.
_tag_and_check registry.com/image:latest registry.com/image:latest
_tag_and_check "$registry/$imgname:latest" "$registry/$imgname:latest"

# Test a reference without tag and make sure ":latest" is appended.
_tag_and_check registry.com/image registry.com/image:latest
_tag_and_check "$registry/$imgname" "$registry/$imgname:latest"

# Test a tagged short image and make sure "localhost/" is prepended.
_tag_and_check image:latest localhost/image:latest
_tag_and_check "$imgname:latest" "localhost/$imgname:latest"

# Test a short image without tag and make sure "localhost/" is
# prepended and ":latest" is appended.
_tag_and_check image localhost/image:latest
_tag_and_check "$imgname" "localhost/$imgname:latest"

# The order is intentionally wrong here to check the sorting
# /~https://github.com/containers/podman/issues/23803
local image1="registry.com/image:1"
local image1="$registry/$imgname-x:1"
run_podman tag $IMAGE $image1
local image3="registry.com/image:3"
local image3="$registry/$imgname-x:3"
run_podman tag $IMAGE $image3
local image2="registry.com/image:2"
local image2="$registry/$imgname-x:2"
run_podman tag $IMAGE $image2

local imageA="registry.com/aaa:a"
local imageA="$registry/$imgname-a:a"
run_podman tag $IMAGE $imageA

local nl="
Expand All @@ -47,17 +51,24 @@ function _tag_and_check() {
run_podman untag $IMAGE $imageA $image1 $image2 $image3

# Test error case.
run_podman 125 untag $IMAGE registry.com/foo:bar
is "$output" "Error: registry.com/foo:bar: tag not known"
run_podman 125 untag $IMAGE "$registry/foo:bar"
is "$output" "Error: $registry/foo:bar: tag not known"
}

# CANNOT BE PARALLELIZED: temporarily removes $IMAGE
@test "podman untag all" {
# First get the image ID
run_podman inspect --format '{{.ID}}' $IMAGE
iid=$output

registry="bogusregistry.nxdomain"
imgname=i-$(safename)

# Add a couple of tags
run_podman tag $IMAGE registry.com/1:latest registry.com/2:latest registry.com/3:latest
run_podman tag $IMAGE \
"$registry/$imgname-1:latest" \
"$registry/$imgname-2:latest" \
"$registry/$imgname-3:latest"

# Untag with arguments to for all tags to be removed
run_podman untag $iid
Expand All @@ -66,6 +77,8 @@ function _tag_and_check() {
run_podman image inspect $iid --format "{{.RepoTags}}"
is "$output" "\[\]" "untag by ID leaves empty set of tags"

run_podman 1 image exists $IMAGE

# Restore image
run_podman tag $iid $IMAGE
}
Expand Down

0 comments on commit c38c197

Please sign in to comment.