Skip to content

Commit

Permalink
system tests: podman-remote, image tree
Browse files Browse the repository at this point in the history
- new sanity checks for podman-remote:
  - first, confirm that when PODMAN is "-remote",
    we actually talk to a server (validated by
    presence of "Server:" string in "podman version").
  - second, add test for #7212, in which we run
    "podman --remote" (podman with --remote flag,
    not podman-remote command) and make sure --remote
    is allowed both as the first option and also
    with other flag options preceding.

- new test for "podman image tree" (piggybacking on
  top of a "podman build" test, because that gives
  us lots of layers).

Signed-off-by: Ed Santiago <santiago@redhat.com>
  • Loading branch information
edsantiago committed Aug 5, 2020
1 parent a948635 commit c56fb1f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/system/001-basic.bats
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,37 @@ function setup() {
run_podman pull $IMAGE
}

# PR #7212: allow --remote anywhere before subcommand, not just as 1st flag
@test "podman-remote : really is remote, works as --remote option" {
if ! is_remote; then
skip "only applicable on podman-remote"
fi

# First things first: make sure our podman-remote actually is remote!
run_podman version
is "$output" ".*Server:" "the given podman path really contacts a server"

# $PODMAN may be a space-separated string, e.g. if we include a --url.
# Split it into its components; remove "-remote" from the command path;
# and preserve any other args if present.
local -a podman_as_array=($PODMAN)
local podman_path=${podman_as_array[0]}
local podman_non_remote=${podman_path%%-remote}
local -a podman_args=("${podman_as_array[@]:1}")

# This always worked: running "podman --remote ..."
PODMAN="${podman_non_remote} --remote ${podman_args[@]}" run_podman version
is "$output" ".*Server:" "podman --remote: contacts server"

# This was failing: "podman --foo --bar --remote".
PODMAN="${podman_non_remote} --tmpdir /var/tmp --log-level=error ${podman_args[@]} --remote" run_podman version
is "$output" ".*Server:" "podman [flags] --remote: contacts server"

# ...but no matter what, --remote is never allowed after subcommand
PODMAN="${podman_non_remote} ${podman_args[@]}" run_podman 125 version --remote
is "$output" "Error: unknown flag: --remote" "podman version --remote"
}

# This is for development only; it's intended to make sure our timeout
# in run_podman continues to work. This test should never run in production
# because it will, by definition, fail.
Expand Down
17 changes: 17 additions & 0 deletions test/system/070-build.bats
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ EOF
# cd to the dir, so we test relative paths (important for podman-remote)
cd $PODMAN_TMPDIR
run_podman build -t build_test -f build-test/Containerfile build-test
local iid="${lines[-1]}"

# Run without args - should run the above script. Verify its output.
export MYENV2="$s_env2"
Expand Down Expand Up @@ -232,6 +233,22 @@ Labels.$label_name | $label_value
run_podman run --rm build_test stat -c'%u:%g:%N' /a/b/c/myfile
is "$output" "4:5:/a/b/c/myfile" "file in volume is chowned"

# Hey, as long as we have an image with lots of layers, let's
# confirm that 'image tree' works as expected
run_podman image tree build_test
is "${lines[0]}" "Image ID: ${iid:0:12}" \
"image tree: first line"
is "${lines[1]}" "Tags: \[localhost/build_test:latest]" \
"image tree: second line"
is "${lines[2]}" "Size: [0-9.]\+[kM]B" \
"image tree: third line"
is "${lines[3]}" "Image Layers" \
"image tree: fourth line"
is "${lines[4]}" "... ID: [0-9a-f]\{12\} Size: .* Top Layer of: \[$IMAGE]" \
"image tree: first layer line"
is "${lines[-1]}" "... ID: [0-9a-f]\{12\} Size: .* Top Layer of: \[localhost/build_test:latest]" \
"image tree: last layer line"

# Clean up
run_podman rmi -f build_test
}
Expand Down

0 comments on commit c56fb1f

Please sign in to comment.