diff options
Diffstat (limited to 'test/system/030-run.bats')
-rw-r--r-- | test/system/030-run.bats | 78 |
1 files changed, 67 insertions, 11 deletions
diff --git a/test/system/030-run.bats b/test/system/030-run.bats index 518d902a7..b3599cc17 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -14,7 +14,7 @@ load helpers # ...but check the configured runtime engine, and switch to crun as needed run_podman info --format '{{ .Host.OCIRuntime.Path }}' if expr "$output" : ".*/crun"; then - err_no_such_cmd="Error: executable file not found in \$PATH: No such file or directory: OCI runtime command not found error" + err_no_such_cmd="Error: executable file.* not found in \$PATH: No such file or directory: OCI runtime command not found error" err_no_exec_dir="Error: open executable: Operation not permitted: OCI runtime permission denied error" fi @@ -61,8 +61,8 @@ echo $rand | 0 | $rand is "$tests_run" "$(grep . <<<$tests | wc -l)" "Ran the full set of tests" } -@test "podman run - globle runtime option" { - skip_if_remote "runtime flag is not passing over remote" +@test "podman run - global runtime option" { + skip_if_remote "runtime flag is not passed over remote" run_podman 126 --runtime-flag invalidflag run --rm $IMAGE is "$output" ".*invalidflag" "failed when passing undefined flags to the runtime" } @@ -132,8 +132,6 @@ echo $rand | 0 | $rand } @test "podman run --pull" { - skip_if_remote "podman-remote does not emit 'Trying to pull' msgs" - run_podman run --pull=missing $IMAGE true is "$output" "" "--pull=missing [present]: no output" @@ -267,8 +265,6 @@ echo $rand | 0 | $rand # symptom only manifests on a fedora container image -- we have no # reproducer on alpine. Checking directory ownership is good enough. @test "podman run : user namespace preserved root ownership" { - skip_if_remote "FIXME: pending #7195" - for priv in "" "--privileged"; do for user in "--user=0" "--user=100"; do for keepid in "" "--userns=keep-id"; do @@ -286,8 +282,6 @@ echo $rand | 0 | $rand # #6829 : add username to /etc/passwd inside container if --userns=keep-id @test "podman run : add username to /etc/passwd if --userns=keep-id" { - skip_if_remote "FIXME: pending #7195" - # Default: always run as root run_podman run --rm $IMAGE id -un is "$output" "root" "id -un on regular container" @@ -310,8 +304,6 @@ echo $rand | 0 | $rand # #6991 : /etc/passwd is modifiable @test "podman run : --userns=keep-id: passwd file is modifiable" { - skip_if_remote "FIXME: pending #7195" - run_podman run -d --userns=keep-id $IMAGE sh -c 'while ! test -e /stop; do sleep 0.1; done' cid="$output" @@ -337,4 +329,68 @@ echo $rand | 0 | $rand run_podman wait $cid } +# For #7754: json-file was equating to 'none' +@test "podman run --log-driver" { + # '-' means that LogPath will be blank and there's no easy way to test + tests=" +none | - +journald | - +k8s-file | y +json-file | f +" + while read driver do_check; do + msg=$(random_string 15) + run_podman run --name myctr --log-driver $driver $IMAGE echo $msg + + # Simple output check + # Special case: 'json-file' emits a warning, the rest do not + # ...but with podman-remote the warning is on the server only + if [[ $do_check == 'f' ]] && ! is_remote; then # 'f' for 'fallback' + is "${lines[0]}" ".* level=error msg=\"json-file logging specified but not supported. Choosing k8s-file logging instead\"" \ + "Fallback warning emitted" + is "${lines[1]}" "$msg" "basic output sanity check (driver=$driver)" + else + is "$output" "$msg" "basic output sanity check (driver=$driver)" + fi + + # Simply confirm that podman preserved our argument as-is + run_podman inspect --format '{{.HostConfig.LogConfig.Type}}' myctr + is "$output" "$driver" "podman inspect: driver" + + # If LogPath is non-null, check that it exists and has a valid log + run_podman inspect --format '{{.LogPath}}' myctr + if [[ $do_check != '-' ]]; then + is "$output" "/.*" "LogPath (driver=$driver)" + if ! test -e "$output"; then + die "LogPath (driver=$driver) does not exist: $output" + fi + # eg 2020-09-23T13:34:58.644824420-06:00 stdout F 7aiYtvrqFGJWpak + is "$(< $output)" "[0-9T:.+-]\+ stdout F $msg" \ + "LogPath contents (driver=$driver)" + else + is "$output" "" "LogPath (driver=$driver)" + fi + run_podman rm myctr + done < <(parse_table "$tests") + + # Invalid log-driver argument + run_podman 125 run --log-driver=InvalidDriver $IMAGE true + is "$output" "Error: error running container create option: invalid log driver: invalid argument" \ + "--log-driver InvalidDriver" +} + +@test "podman run --log-driver journald" { + skip_if_remote "We cannot read journalctl over remote." + + msg=$(random_string 20) + pidfile="${PODMAN_TMPDIR}/$(random_string 20)" + + run_podman run --name myctr --log-driver journald --conmon-pidfile $pidfile $IMAGE echo $msg + + journalctl --output cat _PID=$(cat $pidfile) + is "$output" "$msg" "check that journalctl output equals the container output" + + run_podman rm myctr +} + # vim: filetype=sh |