diff options
Diffstat (limited to 'test/system')
-rw-r--r-- | test/system/015-help.bats | 21 | ||||
-rw-r--r-- | test/system/030-run.bats | 2 | ||||
-rw-r--r-- | test/system/055-rm.bats | 2 | ||||
-rw-r--r-- | test/system/070-build.bats | 97 | ||||
-rw-r--r-- | test/system/130-kill.bats | 2 | ||||
-rw-r--r-- | test/system/200-pod.bats | 8 | ||||
-rw-r--r-- | test/system/500-networking.bats | 2 | ||||
-rw-r--r-- | test/system/TODO.md | 2 | ||||
-rw-r--r-- | test/system/helpers.bash | 10 | ||||
-rwxr-xr-x | test/system/helpers.t | 2 |
10 files changed, 121 insertions, 27 deletions
diff --git a/test/system/015-help.bats b/test/system/015-help.bats index 3d05b44fe..76d29d22c 100644 --- a/test/system/015-help.bats +++ b/test/system/015-help.bats @@ -78,7 +78,8 @@ function check_help() { if ! expr "$usage" : '.*[A-Z]' >/dev/null; then if [ "$cmd" != "help" ]; then dprint "$command_string invalid-arg" - run_podman 125 "$@" $cmd invalid-arg + run_podman '?' "$@" $cmd invalid-arg + is "$status" 125 "'$command_string invalid-arg' - exit status" is "$output" "Error: .* takes no arguments" \ "'$command_string' with extra (invalid) arguments" fi @@ -104,7 +105,8 @@ function check_help() { # The </dev/null protects us from 'podman login' which will # try to read username/password from stdin. dprint "$command_string (without required args)" - run_podman 125 "$@" $cmd </dev/null + run_podman '?' "$@" $cmd </dev/null + is "$status" 125 "'$command_string' with no arguments - exit status" is "$output" "Error:.* \(require\|specif\|must\|provide\|need\|choose\|accepts\)" \ "'$command_string' without required arg" @@ -126,7 +128,8 @@ function check_help() { local rhs=$(sed -e 's/^[^A-Z]\+[A-Z]/X/' -e 's/ | /-or-/g' <<<"$usage") local n_args=$(wc -w <<<"$rhs") - run_podman 125 "$@" $cmd $(seq --format='x%g' 0 $n_args) + run_podman '?' "$@" $cmd $(seq --format='x%g' 0 $n_args) + is "$status" 125 "'$command_string' with >$n_args arguments - exit status" is "$output" "Error:.* \(takes no arguments\|requires exactly $n_args arg\|accepts at most\|too many arguments\|accepts $n_args arg(s), received\|accepts between .* and .* arg(s), received \)" \ "'$command_string' with >$n_args arguments" @@ -140,13 +143,17 @@ function check_help() { # Any command that takes subcommands, must throw error if called # without one. dprint "podman $@" - run_podman 125 "$@" - is "$output" "Error: missing command .*$@ COMMAND" + run_podman '?' "$@" + is "$status" 125 "'podman $*' without any subcommand - exit status" + is "$output" "Error: missing command .*$@ COMMAND" \ + "'podman $*' without any subcommand - expected error message" # Assume that 'NoSuchCommand' is not a command dprint "podman $@ NoSuchCommand" - run_podman 125 "$@" NoSuchCommand - is "$output" "Error: unrecognized command .*$@ NoSuchCommand" + run_podman '?' "$@" NoSuchCommand + is "$status" 125 "'podman $* NoSuchCommand' - exit status" + is "$output" "Error: unrecognized command .*$@ NoSuchCommand" \ + "'podman $* NoSuchCommand' - expected error message" # This can happen if the output of --help changes, such as between # the old command parser and cobra. diff --git a/test/system/030-run.bats b/test/system/030-run.bats index 13fec20ad..04d1e4eac 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -87,7 +87,7 @@ echo $rand | 0 | $rand } # 'run --rm' goes through different code paths and may lose exit status. -# See https://github.com/containers/libpod/issues/3795 +# See https://github.com/containers/podman/issues/3795 @test "podman run --rm" { run_podman 0 run --rm $IMAGE /bin/true diff --git a/test/system/055-rm.bats b/test/system/055-rm.bats index 6a381a187..c8475c3e9 100644 --- a/test/system/055-rm.bats +++ b/test/system/055-rm.bats @@ -42,7 +42,7 @@ load helpers # so what we do is start the 'rm' beforehand and monitor the exit status # of the 'sleep' container. # -# See https://github.com/containers/libpod/issues/3795 +# See https://github.com/containers/podman/issues/3795 @test "podman rm -f" { rand=$(random_string 30) ( sleep 3; run_podman rm -f $rand ) & diff --git a/test/system/070-build.bats b/test/system/070-build.bats index 793c2e5a0..627b9caa6 100644 --- a/test/system/070-build.bats +++ b/test/system/070-build.bats @@ -86,7 +86,7 @@ EOF cat >$tmpdir/Dockerfile <<EOF FROM $IMAGE -ADD https://github.com/containers/libpod/blob/master/README.md /tmp/ +ADD https://github.com/containers/podman/blob/master/README.md /tmp/ EOF run_podman build -t add_url $tmpdir run_podman run --rm add_url stat /tmp/README.md @@ -109,6 +109,7 @@ EOF s_env1=$(random_string 20) s_env2=$(random_string 25) s_env3=$(random_string 30) + s_env4=$(random_string 40) # Label name: make sure it begins with a letter! jq barfs if you # try to ask it for '.foo.<N>xyz', i.e. any string beginning with digit @@ -118,11 +119,17 @@ EOF # Command to run on container startup with no args cat >$tmpdir/mycmd <<EOF #!/bin/sh +PATH=/usr/bin:/bin pwd echo "\$1" -echo "\$MYENV1" -echo "\$MYENV2" -echo "\$MYENV3" +printenv | grep MYENV | sort | sed -e 's/^MYENV.=//' +EOF + + # For overridding with --env-file + cat >$PODMAN_TMPDIR/env-file <<EOF +MYENV3=$s_env3 +http_proxy=http-proxy-in-env-file +https_proxy=https-proxy-in-env-file EOF cat >$tmpdir/Containerfile <<EOF @@ -130,11 +137,25 @@ FROM $IMAGE LABEL $label_name=$label_value RUN mkdir $workdir WORKDIR $workdir + +# Test for #7094 - chowning of invalid symlinks +RUN mkdir -p /a/b/c +RUN ln -s /no/such/nonesuch /a/b/c/badsymlink +RUN ln -s /bin/mydefaultcmd /a/b/c/goodsymlink +RUN touch /a/b/c/myfile +RUN chown -h 1:2 /a/b/c/badsymlink /a/b/c/goodsymlink /a/b/c/myfile +VOLUME /a/b/c + +# Test for environment passing and override ENV MYENV1=$s_env1 -ENV MYENV2 $s_env2 -ENV MYENV3 this-should-be-overridden +ENV MYENV2 this-should-be-overridden-by-env-host +ENV MYENV3 this-should-be-overridden-by-env-file +ENV MYENV4 this-should-be-overridden-by-cmdline +ENV http_proxy http-proxy-in-image +ENV ftp_proxy ftp-proxy-in-image ADD mycmd /bin/mydefaultcmd RUN chmod 755 /bin/mydefaultcmd +RUN chown 2:3 /bin/mydefaultcmd CMD ["/bin/mydefaultcmd","$s_echo"] EOF @@ -143,12 +164,28 @@ EOF run_podman build -t build_test -f build-test/Containerfile build-test # Run without args - should run the above script. Verify its output. - run_podman run --rm -e MYENV3="$s_env3" build_test + export MYENV2="$s_env2" + export MYENV3="env-file-should-override-env-host!" + run_podman run --rm \ + --env-file=$PODMAN_TMPDIR/env-file \ + --env-host \ + -e MYENV4="$s_env4" \ + build_test is "${lines[0]}" "$workdir" "container default command: pwd" is "${lines[1]}" "$s_echo" "container default command: output from echo" is "${lines[2]}" "$s_env1" "container default command: env1" is "${lines[3]}" "$s_env2" "container default command: env2" - is "${lines[4]}" "$s_env3" "container default command: env3 (from cmdline)" + is "${lines[4]}" "$s_env3" "container default command: env3 (from envfile)" + is "${lines[5]}" "$s_env4" "container default command: env4 (from cmdline)" + + # Proxies - environment should override container, but not env-file + http_proxy=http-proxy-from-env ftp_proxy=ftp-proxy-from-env \ + run_podman run --rm --env-file=$PODMAN_TMPDIR/env-file \ + build_test \ + printenv http_proxy https_proxy ftp_proxy + is "${lines[0]}" "http-proxy-in-env-file" "env-file overrides env" + is "${lines[1]}" "https-proxy-in-env-file" "env-file sets proxy var" + is "${lines[2]}" "ftp-proxy-from-env" "ftp-proxy is passed through" # test that workdir is set for command-line commands also run_podman run --rm build_test pwd @@ -159,8 +196,9 @@ EOF run_podman image inspect build_test tests=" Env[1] | MYENV1=$s_env1 -Env[2] | MYENV2=$s_env2 -Env[3] | MYENV3=this-should-be-overridden +Env[2] | MYENV2=this-should-be-overridden-by-env-host +Env[3] | MYENV3=this-should-be-overridden-by-env-file +Env[4] | MYENV4=this-should-be-overridden-by-cmdline Cmd[0] | /bin/mydefaultcmd Cmd[1] | $s_echo WorkingDir | $workdir @@ -173,10 +211,49 @@ Labels.$label_name | $label_value is "$actual" "$expect" "jq .Config.$field" done + # Bad symlink in volume. Prior to #7094, well, we wouldn't actually + # get here because any 'podman run' on a volume that had symlinks, + # be they dangling or valid, would barf with + # Error: chown <mountpath>/_data/symlink: ENOENT + run_podman run --rm build_test stat -c'%u:%g:%N' /a/b/c/badsymlink + is "$output" "0:0:'/a/b/c/badsymlink' -> '/no/such/nonesuch'" \ + "bad symlink to nonexistent file is chowned and preserved" + + run_podman run --rm build_test stat -c'%u:%g:%N' /a/b/c/goodsymlink + is "$output" "0:0:'/a/b/c/goodsymlink' -> '/bin/mydefaultcmd'" \ + "good symlink to existing file is chowned and preserved" + + run_podman run --rm build_test stat -c'%u:%g' /bin/mydefaultcmd + is "$output" "2:3" "target of symlink is not chowned" + + run_podman run --rm build_test stat -c'%u:%g:%N' /a/b/c/myfile + is "$output" "0:0:/a/b/c/myfile" "file in volume is chowned to root" + # Clean up run_podman rmi -f build_test } +@test "podman build - stdin test" { + if is_remote && is_rootless; then + skip "unreliable with podman-remote and rootless; #2972" + fi + + # Random workdir, and multiple random strings to verify command & env + workdir=/$(random_string 10) + PODMAN_TIMEOUT=240 run_podman build -t build_test - << EOF +FROM $IMAGE +RUN mkdir $workdir +WORKDIR $workdir +RUN /bin/echo 'Test' +EOF + is "$output" ".*STEP 5: COMMIT" "COMMIT seen in log" + + run_podman run --rm build_test pwd + is "$output" "$workdir" "pwd command in container" + + run_podman rmi -f build_test +} + function teardown() { # A timeout or other error in 'build' can leave behind stale images # that podman can't even see and which will cascade into subsequent diff --git a/test/system/130-kill.bats b/test/system/130-kill.bats index 7c2b9bed8..c16e64c58 100644 --- a/test/system/130-kill.bats +++ b/test/system/130-kill.bats @@ -11,7 +11,7 @@ load helpers # Workaround: run 'env --default-signal sh' instead of just 'sh' in # the container. Since env on our regular alpine image doesn't support # that flag, we need to pull fedora-minimal. See: - # https://github.com/containers/libpod/issues/5004 + # https://github.com/containers/podman/issues/5004 # FIXME: remove this kludge once we get rid of podman-remote local _image=$IMAGE local _sh_cmd="sh" diff --git a/test/system/200-pod.bats b/test/system/200-pod.bats index 0e9d9132e..0ad555305 100644 --- a/test/system/200-pod.bats +++ b/test/system/200-pod.bats @@ -165,9 +165,13 @@ function random_ip() { # Create a pod with all the desired options # FIXME: --ip=$ip fails: # Error adding network: failed to allocate all requested IPs + local mac_option="--mac-address=$mac" + if is_rootless; then + mac_option= + fi run_podman pod create --name=mypod \ --pod-id-file=$pod_id_file \ - --mac-address=$mac \ + $mac_option \ --hostname=$hostname \ --add-host "$add_host_n:$add_host_ip" \ --dns "$dns_server" \ @@ -181,7 +185,7 @@ function random_ip() { is "$(<$pod_id_file)" "$pod_id" "contents of pod-id-file" # Check each of the options - if ! is_rootless; then + if [ -n "$mac_option" ]; then run_podman run --rm --pod mypod $IMAGE ip link show # 'ip' outputs hex in lower-case, ${expr,,} converts UC to lc is "$output" ".* link/ether ${mac,,} " "requested MAC address was set" diff --git a/test/system/500-networking.bats b/test/system/500-networking.bats index c9d1984d0..234bc1187 100644 --- a/test/system/500-networking.bats +++ b/test/system/500-networking.bats @@ -5,7 +5,7 @@ load helpers -# Copied from tsweeney's https://github.com/containers/libpod/issues/4827 +# Copied from tsweeney's https://github.com/containers/podman/issues/4827 @test "podman networking: port on localhost" { skip_if_remote random_1=$(random_string 30) diff --git a/test/system/TODO.md b/test/system/TODO.md index f0d311626..e47292f26 100644 --- a/test/system/TODO.md +++ b/test/system/TODO.md @@ -15,7 +15,7 @@ CI configuration file.](../../.cirrus.yml) # Execution -When working from a clone of [the libpod repository](https://github.com/containers/libpod), +When working from a clone of [the libpod repository](https://github.com/containers/podman), the main entry-point for humans and automation is `make localsystem`. When operating from a packaged version of the system-tests, the entry-point may vary as appropriate. Running the packaged system-tests assumes the version of Podman matches the test diff --git a/test/system/helpers.bash b/test/system/helpers.bash index 4239ef876..abca91739 100644 --- a/test/system/helpers.bash +++ b/test/system/helpers.bash @@ -404,7 +404,13 @@ function find_exec_pid_files() { # # This obviously screws us up when we look at output results. # -# This function removes the warning from $output and $lines +# This function removes the warning from $output and $lines. We don't +# do a full string match because there's another variant of that message: +# +# WARNING: Creating device "/dev/null" with same type, major and minor as existing "/dev/foodevdir/null". +# +# (We should never again see that precise error ever again, but we could +# see variants of it). # function remove_same_dev_warning() { # No input arguments. We operate in-place on $output and $lines @@ -412,7 +418,7 @@ function remove_same_dev_warning() { local i=0 local -a new_lines=() while [[ $i -lt ${#lines[@]} ]]; do - if expr "${lines[$i]}" : 'WARNING: .* same type, major.* multiple' >/dev/null; then + if expr "${lines[$i]}" : 'WARNING: .* same type, major' >/dev/null; then : else new_lines+=("${lines[$i]}") diff --git a/test/system/helpers.t b/test/system/helpers.t index a022f11c4..bee09505c 100755 --- a/test/system/helpers.t +++ b/test/system/helpers.t @@ -6,7 +6,7 @@ # anything if we have to mess with them. # -source $(dirname $0)/helpers.bash +source "$(dirname $0)"/helpers.bash die() { echo "$(basename $0): $*" >&2 |