mirror of
https://github.com/containers/podman.git
synced 2025-09-18 15:54:49 +08:00
systests: tighter checks for unwanted warnings
Part of RUN-1906. Followup to #19878 (check stderr in system tests): allow_warnings() and require_warning() functions to make sure no unexpected messages fall through the cracks. Signed-off-by: Ed Santiago <santiago@redhat.com>
This commit is contained in:
@ -36,7 +36,7 @@ function setup() {
|
|||||||
is "$output" "podman.*version \+" "'Version line' in output"
|
is "$output" "podman.*version \+" "'Version line' in output"
|
||||||
|
|
||||||
run_podman 0+w --config foobar version
|
run_podman 0+w --config foobar version
|
||||||
is "$output" ".*The --config flag is ignored by Podman. Exists for Docker compatibility\+" "verify warning for --config option"
|
require_warning "The --config flag is ignored by Podman. Exists for Docker compatibility"
|
||||||
}
|
}
|
||||||
|
|
||||||
# bats test_tags=distro-integration
|
# bats test_tags=distro-integration
|
||||||
|
@ -387,9 +387,9 @@ EOF
|
|||||||
tries=100
|
tries=100
|
||||||
while [[ ${#lines[*]} -gt 1 ]] && [[ $tries -gt 0 ]]; do
|
while [[ ${#lines[*]} -gt 1 ]] && [[ $tries -gt 0 ]]; do
|
||||||
# Prior to #18980, 'podman images' during rmi could fail with 'image not known'
|
# Prior to #18980, 'podman images' during rmi could fail with 'image not known'
|
||||||
# '0+w' reflects that we may see "Top layer not found" warnings.
|
# '0+w' because we sometimes get warnings.
|
||||||
# FIXME FIXME: find a way to check for any other warnings
|
|
||||||
run_podman 0+w images --format "{{.ID}} {{.Names}}"
|
run_podman 0+w images --format "{{.ID}} {{.Names}}"
|
||||||
|
allow_warnings "Top layer .* of image .* not found in layer tree"
|
||||||
tries=$((tries - 1))
|
tries=$((tries - 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -182,7 +182,8 @@ echo $rand | 0 | $rand
|
|||||||
|
|
||||||
# Now try running with --rmi : it should succeed, but not remove the image
|
# Now try running with --rmi : it should succeed, but not remove the image
|
||||||
run_podman 0+w run --rmi --rm $NONLOCAL_IMAGE /bin/true
|
run_podman 0+w run --rmi --rm $NONLOCAL_IMAGE /bin/true
|
||||||
is "$output" ".*image is in use by a container" "--rmi should warn that the image was not removed"
|
require_warning "image is in use by a container" \
|
||||||
|
"--rmi should warn that the image was not removed"
|
||||||
run_podman image exists $NONLOCAL_IMAGE
|
run_podman image exists $NONLOCAL_IMAGE
|
||||||
|
|
||||||
# Remove the stray container, and run one more time with --rmi.
|
# Remove the stray container, and run one more time with --rmi.
|
||||||
@ -947,7 +948,7 @@ EOF
|
|||||||
skip "the current oom-score-adj is already -1000"
|
skip "the current oom-score-adj is already -1000"
|
||||||
fi
|
fi
|
||||||
run_podman 0+w run --oom-score-adj=-1000 --rm $IMAGE true
|
run_podman 0+w run --oom-score-adj=-1000 --rm $IMAGE true
|
||||||
is "$output" ".*Requested oom_score_adj=.* is lower than the current one, changing to .*"
|
require_warning "Requested oom_score_adj=.* is lower than the current one, changing to "
|
||||||
}
|
}
|
||||||
|
|
||||||
# CVE-2022-1227 : podman top joins container mount NS and uses nsenter from image
|
# CVE-2022-1227 : podman top joins container mount NS and uses nsenter from image
|
||||||
@ -1061,7 +1062,8 @@ $IMAGE--c_ok" \
|
|||||||
# FIXME: do we really really mean to say FFFFFFFFFFFFFFFF here???
|
# FIXME: do we really really mean to say FFFFFFFFFFFFFFFF here???
|
||||||
run_podman 0+w stop -t -1 $cid
|
run_podman 0+w stop -t -1 $cid
|
||||||
if ! is_remote; then
|
if ! is_remote; then
|
||||||
assert "$output" =~ "StopSignal \(37\) failed to stop container .* in 18446744073709551615 seconds, resorting to SIGKILL" "stop -t -1 (negative one) issues warning"
|
require_warning "StopSignal \(37\) failed to stop container .* in 18446744073709551615 seconds, resorting to SIGKILL" \
|
||||||
|
"stop -t -1 (negative 1) issues warning"
|
||||||
fi
|
fi
|
||||||
run_podman rm -t -1 -f $cid
|
run_podman rm -t -1 -f $cid
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ load helpers
|
|||||||
run_podman rm $cid_none_implicit $cid_none_explicit $cid_on_failure
|
run_podman rm $cid_none_implicit $cid_none_explicit $cid_on_failure
|
||||||
run_podman 0+w stop -t 1 $cid_always
|
run_podman 0+w stop -t 1 $cid_always
|
||||||
if ! is_remote; then
|
if ! is_remote; then
|
||||||
assert "$output" =~ "StopSignal SIGTERM failed to stop container .*, resorting to SIGKILL"
|
require_warning "StopSignal SIGTERM failed to stop container .*, resorting to SIGKILL"
|
||||||
fi
|
fi
|
||||||
run_podman rm $cid_always
|
run_podman rm $cid_always
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,16 @@ load helpers
|
|||||||
run_podman run -d $IMAGE sleep 60
|
run_podman run -d $IMAGE sleep 60
|
||||||
cid="$output"
|
cid="$output"
|
||||||
|
|
||||||
# Run 'stop'. Time how long it takes.
|
# Run 'stop'. Time how long it takes. If local, require a warning.
|
||||||
|
local plusw="+w"
|
||||||
|
if is_remote; then
|
||||||
|
plusw=
|
||||||
|
fi
|
||||||
t0=$SECONDS
|
t0=$SECONDS
|
||||||
run_podman 0+w stop $cid
|
run_podman 0$plusw stop $cid
|
||||||
t1=$SECONDS
|
t1=$SECONDS
|
||||||
if ! is_remote; then
|
if [[ -n "$plusw" ]]; then
|
||||||
assert "$output" =~ "StopSignal SIGTERM failed to stop container .*, resorting to SIGKILL"
|
require_warning "StopSignal SIGTERM failed to stop container .*, resorting to SIGKILL"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Confirm that container is stopped. Podman-remote unfortunately
|
# Confirm that container is stopped. Podman-remote unfortunately
|
||||||
@ -46,10 +50,14 @@ load helpers
|
|||||||
is "${lines[1]}" "c2--Up.*" "podman ps shows running container (2)"
|
is "${lines[1]}" "c2--Up.*" "podman ps shows running container (2)"
|
||||||
is "${lines[2]}" "c3--Up.*" "podman ps shows running container (3)"
|
is "${lines[2]}" "c3--Up.*" "podman ps shows running container (3)"
|
||||||
|
|
||||||
# Stop -a
|
# Stop -a. Local podman issues a warning, check for it.
|
||||||
run_podman 0+w stop -a -t 1
|
local plusw="+w"
|
||||||
if ! is_remote; then
|
if is_remote; then
|
||||||
assert "$output" =~ "StopSignal SIGTERM failed to stop container .*, resorting to SIGKILL"
|
plusw=
|
||||||
|
fi
|
||||||
|
run_podman 0$plusw stop -a -t 1
|
||||||
|
if [[ -n "$plusw" ]]; then
|
||||||
|
require_warning "StopSignal SIGTERM failed to stop container .*, resorting to SIGKILL"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Now podman ps (without -a) should show nothing.
|
# Now podman ps (without -a) should show nothing.
|
||||||
@ -191,9 +199,14 @@ load helpers
|
|||||||
@test "podman stop -t 1 Generate warning" {
|
@test "podman stop -t 1 Generate warning" {
|
||||||
skip_if_remote "warning only happens on server side"
|
skip_if_remote "warning only happens on server side"
|
||||||
run_podman run --rm --name stopme -d $IMAGE sleep 100
|
run_podman run --rm --name stopme -d $IMAGE sleep 100
|
||||||
run_podman 0+w stop -t 1 stopme
|
|
||||||
if ! is_remote; then
|
local plusw="+w"
|
||||||
is "$output" ".*StopSignal SIGTERM failed to stop container stopme in 1 seconds, resorting to SIGKILL" "stopping container should print warning"
|
if is_remote; then
|
||||||
|
plusw=
|
||||||
|
fi
|
||||||
|
run_podman 0$plusw stop -t 1 stopme
|
||||||
|
if [[ -n "$plusw" ]]; then
|
||||||
|
require_warning ".*StopSignal SIGTERM failed to stop container stopme in 1 seconds, resorting to SIGKILL"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,8 @@ function service_cleanup() {
|
|||||||
run_podman create --restart=always $IMAGE
|
run_podman create --restart=always $IMAGE
|
||||||
cid="$output"
|
cid="$output"
|
||||||
run_podman 0+w generate systemd $cid
|
run_podman 0+w generate systemd $cid
|
||||||
is "$output" ".*Container $cid has restart policy .*always.* which can lead to issues on shutdown.*" "generate systemd emits warning"
|
require_warning "Container $cid has restart policy .*always.* which can lead to issues on shutdown" \
|
||||||
|
"generate systemd emits warning"
|
||||||
run_podman rm -f $cid
|
run_podman rm -f $cid
|
||||||
|
|
||||||
cname=$(random_string)
|
cname=$(random_string)
|
||||||
|
@ -76,10 +76,14 @@ function _corrupt_image_test() {
|
|||||||
run_podman 125 images
|
run_podman 125 images
|
||||||
is "$output" "Error: locating item named \".*\" for image with ID \"$id\" (consider removing the image to resolve the issue): file does not exist.*"
|
is "$output" "Error: locating item named \".*\" for image with ID \"$id\" (consider removing the image to resolve the issue): file does not exist.*"
|
||||||
|
|
||||||
# Run the requested command. Confirm it succeeds, with suitable warnings
|
# Run the requested command. Confirm it succeeds, with suitable warnings.
|
||||||
run_podman 0+w $*
|
run_podman 0+w $*
|
||||||
is "$output" ".*Failed to determine parent of image.*ignoring the error" \
|
# There are three different variations on the warnings, allow each...
|
||||||
"$* with missing $what_to_rm"
|
allow_warnings "Failed to determine parent of image: .*, ignoring the error" \
|
||||||
|
"Failed to determine if an image is a parent: .*, ignoring the error" \
|
||||||
|
"Failed to determine if an image is a manifest list: .*, ignoring the error"
|
||||||
|
# ...but make sure we get at least one
|
||||||
|
require_warning "Failed to determine (parent|if an image is) .*, ignoring the error"
|
||||||
|
|
||||||
run_podman images -a --noheading
|
run_podman images -a --noheading
|
||||||
is "$output" "" "podman images -a, after $*, is empty"
|
is "$output" "" "podman images -a, after $*, is empty"
|
||||||
|
@ -82,7 +82,7 @@ function teardown() {
|
|||||||
|
|
||||||
@test "podman run --tty -i failure with no tty" {
|
@test "podman run --tty -i failure with no tty" {
|
||||||
run_podman 0+w run --tty -i --rm $IMAGE echo hello < /dev/null
|
run_podman 0+w run --tty -i --rm $IMAGE echo hello < /dev/null
|
||||||
is "$output" ".*The input device is not a TTY.*" "-it _without_ a tty"
|
require_warning "The input device is not a TTY.*" "-it _without_ a tty"
|
||||||
|
|
||||||
CR=$'\r'
|
CR=$'\r'
|
||||||
run_podman run --tty -i --rm $IMAGE echo hello <$PODMAN_TEST_PTY
|
run_podman run --tty -i --rm $IMAGE echo hello <$PODMAN_TEST_PTY
|
||||||
|
@ -631,7 +631,8 @@ load helpers.network
|
|||||||
|
|
||||||
run_podman 0+w restart $cid
|
run_podman 0+w restart $cid
|
||||||
if ! is_remote; then
|
if ! is_remote; then
|
||||||
assert "$output" =~ "StopSignal SIGTERM failed to stop container .* in 10 seconds, resorting to SIGKILL" "podman restart issues warning"
|
require_warning "StopSignal SIGTERM failed to stop container .* in 10 seconds, resorting to SIGKILL" \
|
||||||
|
"podman restart issues warning"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Verify http contents again: curl from localhost
|
# Verify http contents again: curl from localhost
|
||||||
|
@ -913,6 +913,38 @@ function is() {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
####################
|
||||||
|
# allow_warnings # check cmd output for warning messages other than these
|
||||||
|
####################
|
||||||
|
#
|
||||||
|
# HEADS UP: Operates on '$lines' array, so, must be invoked after run_podman
|
||||||
|
#
|
||||||
|
function allow_warnings() {
|
||||||
|
for line in "${lines[@]}"; do
|
||||||
|
if [[ "$line" =~ level=[we] ]]; then
|
||||||
|
local ok=
|
||||||
|
for pattern in "$@"; do
|
||||||
|
if [[ "$line" =~ $pattern ]]; then
|
||||||
|
ok=ok
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [[ -z "$ok" ]]; then
|
||||||
|
die "Unexpected warning/error in command results: $line"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
#####################
|
||||||
|
# require_warning # Require the given message, but disallow any others
|
||||||
|
#####################
|
||||||
|
# Optional 2nd argument is a message to display if warning is missing
|
||||||
|
function require_warning() {
|
||||||
|
local expect="$1"
|
||||||
|
local msg="${2:-Did not find expected warning/error message}"
|
||||||
|
assert "$output" =~ "$expect" "$msg"
|
||||||
|
allow_warnings "$expect"
|
||||||
|
}
|
||||||
|
|
||||||
############
|
############
|
||||||
# dprint # conditional debug message
|
# dprint # conditional debug message
|
||||||
|
Reference in New Issue
Block a user