forked from containers/podman
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BATS: new tests, and improvements to existing ones
New: - podman exec - podman load (requires containers#2674) - CLI parsing (regression test for containers#2574) Improved: - help: test "podman NoSuchCommand", and subcommands - help: test "podman cmd" without required args - pod: start with --infra=false; this allows running rootless - log: also run 'logs' after container is run - log: test -f with two containers Also, use helpful descriptions for skip_if_rootless Tested on f29, root and rootless. As soon as podman-remote supports rm, I'll start testing that too. Signed-off-by: Ed Santiago <[email protected]>
- Loading branch information
1 parent
07e10d9
commit 58d2e58
Showing
8 changed files
with
198 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env bats -*- bats -*- | ||
# | ||
# Tests for podman exec | ||
# | ||
|
||
load helpers | ||
|
||
@test "podman exec - basic test" { | ||
rand_filename=$(random_string 20) | ||
rand_content=$(random_string 50) | ||
|
||
# Start a container. Write random content to random file, then stay | ||
# alive as long as file exists. (This test will remove that file soon.) | ||
run_podman run -d $IMAGE sh -c \ | ||
"echo $rand_content >/$rand_filename;echo READY;while [ -f /$rand_filename ]; do sleep 1; done" | ||
cid="$output" | ||
wait_for_ready $cid | ||
|
||
run_podman exec $cid sh -c "cat /$rand_filename" | ||
is "$output" "$rand_content" "Can exec and see file in running container" | ||
|
||
run_podman exec $cid rm -f /$rand_filename | ||
|
||
run_podman wait $cid | ||
is "$output" "0" "output from podman wait (container exit code)" | ||
|
||
run_podman rm $cid | ||
} | ||
|
||
# vim: filetype=sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/usr/bin/env bats -*- bats -*- | ||
# | ||
# tests for podman load | ||
# | ||
|
||
load helpers | ||
|
||
# Custom helpers for this test only. These just save us having to duplicate | ||
# the same thing four times (two tests, each with -i and stdin). | ||
# | ||
# initialize, read image ID and name | ||
get_iid_and_name() { | ||
run_podman images --format '{{.ID}} {{.Repository}}:{{.Tag}}' | ||
read iid img_name < <(echo "$output") | ||
|
||
archive=$PODMAN_TMPDIR/myimage-$(random_string 8).tar | ||
} | ||
|
||
# Simple verification of image ID and name | ||
verify_iid_and_name() { | ||
run_podman images --format '{{.ID}} {{.Repository}}:{{.Tag}}' | ||
read new_iid new_img_name < <(echo "$output") | ||
|
||
# Verify | ||
is "$new_iid" "$iid" "Image ID of loaded image == original" | ||
is "$new_img_name" "$1" "Name & tag of restored image" | ||
} | ||
|
||
|
||
@test "podman load - by image ID" { | ||
# FIXME: how to build a simple archive instead? | ||
get_iid_and_name | ||
|
||
# Save image by ID, and remove it. | ||
run_podman save $iid -o $archive | ||
run_podman rmi $iid | ||
|
||
# Load using -i; IID should be preserved, but name is not. | ||
run_podman load -i $archive | ||
verify_iid_and_name "<none>:<none>" | ||
|
||
# Same as above, using stdin | ||
run_podman rmi $iid | ||
run_podman load < $archive | ||
verify_iid_and_name "<none>:<none>" | ||
|
||
# Cleanup: since load-by-iid doesn't preserve name, re-tag it; | ||
# otherwise our global teardown will rmi and re-pull our standard image. | ||
run_podman tag $iid $img_name | ||
} | ||
|
||
@test "podman load - by image name" { | ||
get_iid_and_name | ||
run_podman save $img_name -o $archive | ||
run_podman rmi $iid | ||
|
||
# Load using -i; this time the image should be tagged. | ||
run_podman load -i $archive | ||
verify_iid_and_name $img_name | ||
|
||
# Same as above, using stdin | ||
run_podman rmi $iid | ||
run_podman load < $archive | ||
verify_iid_and_name $img_name | ||
} | ||
|
||
@test "podman load - NAME and NAME:TAG arguments work (requires: #2674)" { | ||
get_iid_and_name | ||
run_podman save $iid -o $archive | ||
run_podman rmi $iid | ||
|
||
# Load with just a name (note: names must be lower-case) | ||
random_name=$(random_string 20 | tr A-Z a-z) | ||
run_podman load -i $archive $random_name | ||
verify_iid_and_name "localhost/$random_name:latest" | ||
|
||
# Load with NAME:TAG arg | ||
run_podman rmi $iid | ||
random_tag=$(random_string 10 | tr A-Z a-z) | ||
run_podman load -i $archive $random_name:$random_tag | ||
verify_iid_and_name "localhost/$random_name:$random_tag" | ||
|
||
# Cleanup: restore desired image name | ||
run_podman tag $iid $img_name | ||
run_podman rmi "$random_name:$random_tag" | ||
} | ||
|
||
|
||
@test "podman load - will not read from tty" { | ||
run_podman 125 load | ||
is "$output" \ | ||
"Error: cannot read from terminal. Use command-line redirection" \ | ||
"Diagnostic from 'podman load' without redirection or -i" | ||
} | ||
|
||
# vim: filetype=sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env bats -*- bats -*- | ||
# | ||
# Various command-line parsing regression tests that don't fit in elsewhere | ||
# | ||
|
||
load helpers | ||
|
||
@test "podman cli parsing - quoted args - #2574" { | ||
# 1.1.2 fails with: | ||
# Error: invalid argument "true=\"false\"" for "-l, --label" \ | ||
# flag: parse error on line 1, column 5: bare " in non-quoted-field | ||
run_podman run --rm --label 'true="false"' $IMAGE true | ||
} | ||
|
||
# vim: filetype=sh |