Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System tests: cleanup, make more robust #8149

Merged
merged 1 commit into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 36 additions & 17 deletions test/system/030-run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -473,34 +473,53 @@ json-file | f

# run with --runtime should preserve the named runtime
@test "podman run : full path to --runtime is preserved" {
skip_if_cgroupsv1
skip_if_remote
run_podman run -d --runtime '/usr/bin/crun' $IMAGE sleep 60
skip_if_remote "podman-remote does not support --runtime option"

# Get configured runtime
run_podman info --format '{{.Host.OCIRuntime.Path}}'
runtime="$output"

# Assumes that /var/tmp is not mounted noexec; this is usually safe
new_runtime="/var/tmp/myruntime$(random_string 12)"
cp --preserve $runtime $new_runtime

run_podman run -d --runtime "$new_runtime" $IMAGE sleep 60
cid="$output"

run_podman inspect --format '{{.OCIRuntime}}' $cid
is "$output" "/usr/bin/crun"

is "$output" "$new_runtime" "podman inspect shows configured runtime"
run_podman kill $cid
run_podman rm $cid
rm -f $new_runtime
}

# Regression test for issue #8082
@test "podman run : look up correct image name" {
# Create a 2nd tag for the local image.
local name="localhost/foo/bar"
run_podman tag $IMAGE $name
# Create a 2nd tag for the local image. Force to lower case, and apply it.
local newtag="localhost/$(random_string 10)/$(random_string 8)"
newtag=${newtag,,}
run_podman tag $IMAGE $newtag

# Create a container with the 2nd tag and make sure that it's being
# used. #8082 always inaccurately used the 1st tag.
run_podman create $newtag
cid="$output"

# Create a container with the 2nd tag and make sure that it's being
# used. #8082 always inaccurately used the 1st tag.
run_podman create $name
cid="$output"
run_podman inspect --format "{{.ImageName}}" $cid
is "$output" "$newtag" "container .ImageName is the container-create name"

run_podman inspect --format "{{.ImageName}}" $cid
is "$output" "$name"
# Same thing, but now with a :tag, and making sure it works with --name
newtag2="${newtag}:$(random_string 6|tr A-Z a-z)"
run_podman tag $IMAGE $newtag2

# Clean up.
run_podman rm $cid
run_podman untag $IMAGE $name
cname="$(random_string 14|tr A-Z a-z)"
run_podman create --name $cname $newtag2
run_podman inspect --format "{{.ImageName}}" $cname
is "$output" "$newtag2" "container .ImageName is the container-create name"

# Clean up.
run_podman rm $cid $cname
run_podman untag $IMAGE $newtag $newtag2
}

# vim: filetype=sh
23 changes: 18 additions & 5 deletions test/system/090-events.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,22 @@
load helpers

@test "events with a filter by label" {
skip_if_remote "Need to talk to Ed on why this is failing on remote"
rand=$(random_string 30)
run_podman 0 run --label foo=bar --name test-$rand --rm $IMAGE ls
run_podman 0 events --filter type=container --filter container=test-$rand --filter label=foo=bar --filter event=start --stream=false
is "$output" ".*foo=bar" "check for label event on container with label"
skip_if_remote "FIXME: -remote does not include labels in event output"
cname=test-$(random_string 30 | tr A-Z a-z)
labelname=$(random_string 10)
labelvalue=$(random_string 15)

run_podman run --label $labelname=$labelvalue --name $cname --rm $IMAGE ls

expect=".* container start [0-9a-f]\+ (image=$IMAGE, name=$cname,.* ${labelname}=${labelvalue}"
run_podman events --filter type=container --filter container=$cname --filter label=${labelname}=${labelvalue} --filter event=start --stream=false
is "$output" "$expect" "filtering by container name and label"

# Same thing, but without the container-name filter
run_podman events --filter type=container --filter label=${labelname}=${labelvalue} --filter event=start --stream=false
is "$output" "$expect" "filtering just by label"

# Now filter just by container name, no label
run_podman events --filter type=container --filter container=$cname --filter event=start --stream=false
is "$output" "$expect" "filtering just by label"
}