mirror of
https://github.com/containers/podman
synced 2024-10-20 17:23:30 +00:00
a4fcf09b7a
podman-remote is in better shape now. Let's see what needs to be done to reenable remote system tests. - logs test: skip multilog, it doesn't work remote - diff test: use -l only when local, not with remote - many other tests: skip_if_remote, with 'FIXME: pending #xxxx' where xxxx is a filed issue. Unrelated: added new helper to skip_if_remote and _if_rootless, where we check if the source message includes "remote"/"rootless" and insert it if missing. This is a minor usability enhancement to make it easier to understand at-a-glance why a skip triggers. Signed-off-by: Ed Santiago <santiago@redhat.com>
71 lines
2.2 KiB
Bash
71 lines
2.2 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load helpers
|
|
|
|
# Very simple test
|
|
@test "podman stop - basic test" {
|
|
run_podman run -d $IMAGE sleep 60
|
|
cid="$output"
|
|
|
|
# Run 'stop'. Time how long it takes.
|
|
t0=$SECONDS
|
|
run_podman stop $cid
|
|
t1=$SECONDS
|
|
|
|
# Confirm that container is stopped. Podman-remote unfortunately
|
|
# cannot tell the difference between "stopped" and "exited", and
|
|
# spits them out interchangeably, so we need to recognize either.
|
|
run_podman inspect --format '{{.State.Status}} {{.State.ExitCode}}' $cid
|
|
is "$output" "\\(stopped\|exited\\) \+137" \
|
|
"Status and exit code of stopped container"
|
|
|
|
# The initial SIGTERM is ignored, so this operation should take
|
|
# exactly 10 seconds. Give it some leeway.
|
|
delta_t=$(( $t1 - $t0 ))
|
|
[ $delta_t -gt 8 ] ||\
|
|
die "podman stop: ran too quickly! ($delta_t seconds; expected >= 10)"
|
|
[ $delta_t -le 14 ] ||\
|
|
die "podman stop: took too long ($delta_t seconds; expected ~10)"
|
|
|
|
run_podman rm $cid
|
|
}
|
|
|
|
|
|
# Test fallback
|
|
|
|
|
|
# Regression test for #2472
|
|
@test "podman stop - can trap signal" {
|
|
# Because the --time and --timeout options can be wonky, try three
|
|
# different variations of this test.
|
|
for t_opt in '' '--time=5' '--timeout=5'; do
|
|
# Run a simple container that logs output on SIGTERM
|
|
run_podman run -d $IMAGE sh -c \
|
|
"trap 'echo Received SIGTERM, finishing; exit' SIGTERM; echo READY; while :; do sleep 1; done"
|
|
cid="$output"
|
|
wait_for_ready $cid
|
|
|
|
# Run 'stop' against it...
|
|
t0=$SECONDS
|
|
run_podman stop $t_opt $cid
|
|
t1=$SECONDS
|
|
|
|
# ...the container should trap the signal, log it, and exit.
|
|
run_podman logs $cid
|
|
is "$output" ".*READY.*Received SIGTERM, finishing" "podman stop $t_opt"
|
|
|
|
# Exit code should be 0, because container did its own exit
|
|
run_podman inspect --format '{{.State.ExitCode}}' $cid
|
|
is "$output" "0" "Exit code of stopped container"
|
|
|
|
# The 'stop' command should return almost instantaneously
|
|
delta_t=$(( $t1 - $t0 ))
|
|
[ $delta_t -le 2 ] ||\
|
|
die "podman stop: took too long ($delta_t seconds; expected <= 2)"
|
|
|
|
run_podman rm $cid
|
|
done
|
|
}
|
|
|
|
# vim: filetype=sh
|