mirror of https://github.com/containers/podman.git
Merge pull request #22826 from Luap99/fast-system-test-2
test/system: make some tests faster part 2
This commit is contained in:
commit
846d717c0b
|
@ -127,10 +127,7 @@ echo $rand | 0 | $rand
|
|||
@test "podman run --name" {
|
||||
randomname=$(random_string 30)
|
||||
|
||||
# Assume that 4 seconds gives us enough time for 3 quick tests (or at
|
||||
# least for the 'ps'; the 'container exists' should pass even in the
|
||||
# unlikely case that the container exits before we get to them)
|
||||
run_podman run -d --name $randomname $IMAGE sleep 4
|
||||
run_podman run -d --name $randomname $IMAGE sleep inf
|
||||
cid=$output
|
||||
|
||||
run_podman ps --format '{{.Names}}--{{.ID}}'
|
||||
|
@ -140,7 +137,7 @@ echo $rand | 0 | $rand
|
|||
run_podman container exists $cid
|
||||
|
||||
# Done with live-container tests; now let's test after container finishes
|
||||
run_podman wait $cid
|
||||
run_podman stop -t0 $cid
|
||||
|
||||
# Container still exists even after stopping:
|
||||
run_podman container exists $randomname
|
||||
|
@ -1143,16 +1140,19 @@ EOF
|
|||
|
||||
CONTAINERS_CONF_OVERRIDE="$containersconf" run_podman 1 run --rm $IMAGE touch /testro
|
||||
CONTAINERS_CONF_OVERRIDE="$containersconf" run_podman run --rm --read-only=false $IMAGE touch /testrw
|
||||
CONTAINERS_CONF_OVERRIDE="$containersconf" run_podman run --rm $IMAGE touch /tmp/testrw
|
||||
for dir in /tmp /var/tmp /dev /dev/shm /run; do
|
||||
CONTAINERS_CONF_OVERRIDE="$containersconf" run_podman run --rm $IMAGE touch $dir/testro
|
||||
CONTAINERS_CONF_OVERRIDE="$containersconf" run_podman run --rm --read-only=false $IMAGE touch $dir/testro
|
||||
CONTAINERS_CONF_OVERRIDE="$containersconf" run_podman run --rm --read-only=false --read-only-tmpfs=true $IMAGE touch $dir/testro
|
||||
CONTAINERS_CONF_OVERRIDE="$containersconf" run_podman run --rm --read-only-tmpfs=true $IMAGE touch $dir/testro
|
||||
|
||||
CONTAINERS_CONF_OVERRIDE="$containersconf" run_podman 1 run --rm --read-only-tmpfs=false $IMAGE touch $dir/testro
|
||||
assert "$output" =~ "touch: $dir/testro: Read-only file system"
|
||||
done
|
||||
files="/tmp/a /var/tmp/b /dev/c /dev/shm/d /run/e"
|
||||
CONTAINERS_CONF_OVERRIDE="$containersconf" run_podman run --rm $IMAGE touch $files
|
||||
CONTAINERS_CONF_OVERRIDE="$containersconf" run_podman run --rm --read-only=false $IMAGE touch $files
|
||||
CONTAINERS_CONF_OVERRIDE="$containersconf" run_podman run --rm --read-only=false --read-only-tmpfs=true $IMAGE touch $files
|
||||
CONTAINERS_CONF_OVERRIDE="$containersconf" run_podman run --rm --read-only-tmpfs=true $IMAGE touch $files
|
||||
|
||||
CONTAINERS_CONF_OVERRIDE="$containersconf" run_podman 1 run --rm --read-only-tmpfs=false $IMAGE touch $files
|
||||
assert "$output" == "touch: /tmp/a: Read-only file system
|
||||
touch: /var/tmp/b: Read-only file system
|
||||
touch: /dev/c: Read-only file system
|
||||
touch: /dev/shm/d: Read-only file system
|
||||
touch: /run/e: Read-only file system"
|
||||
}
|
||||
|
||||
@test "podman run ulimit from containers.conf" {
|
||||
|
|
|
@ -89,36 +89,30 @@ function _log_test_multi() {
|
|||
|
||||
skip_if_remote "logs does not support multiple containers when run remotely"
|
||||
|
||||
# Under k8s file, 'podman logs' returns just the facts, Ma'am.
|
||||
# Under journald, there may be other cruft (e.g. container removals)
|
||||
local etc=
|
||||
if [[ $driver =~ journal ]]; then
|
||||
etc='.*'
|
||||
fi
|
||||
|
||||
local events_backend=$(_additional_events_backend $driver)
|
||||
|
||||
# Simple helper to make the container starts, below, easier to read
|
||||
local -a cid
|
||||
doit() {
|
||||
run_podman ${events_backend} run --log-driver=$driver --rm -d --name "$1" $IMAGE sh -c "$2";
|
||||
run_podman ${events_backend} run --log-driver=$driver -d \
|
||||
--name "$1" $IMAGE sh -c "$2";
|
||||
cid+=($(echo "${output:0:12}"))
|
||||
}
|
||||
|
||||
# Not really a guarantee that we'll get a-b-c-d in order, but it's
|
||||
# the best we can do. The trailing 'sleep' in each container
|
||||
# minimizes the chance of a race condition in which the container
|
||||
# is removed before 'podman logs' has a chance to wake up and read
|
||||
# the final output.
|
||||
doit c1 "echo a;sleep 10;echo d;sleep 3"
|
||||
doit c2 "sleep 1;echo b;sleep 2;echo c;sleep 3"
|
||||
doit c1 "echo a1; echo a2"
|
||||
doit c2 "echo b1; echo b2"
|
||||
|
||||
# Reading logs only guarantees the order for a single container,
|
||||
# when using multiple containers the line order between them can vary.
|
||||
run_podman ${events_backend} logs -f c1 c2
|
||||
assert "$output" =~ \
|
||||
"${cid[0]} a$etc
|
||||
${cid[1]} b$etc
|
||||
${cid[1]} c$etc
|
||||
${cid[0]} d" "Sequential output from logs"
|
||||
".*^${cid[0]} a1\$.*
|
||||
${cid[0]} a2" "Sequential output from c1"
|
||||
assert "$output" =~ \
|
||||
".*^${cid[1]} b1\$.*
|
||||
${cid[1]} b2" "Sequential output from c2"
|
||||
|
||||
run_podman rm -f -t0 ${cid[0]} ${cid[1]}
|
||||
}
|
||||
|
||||
@test "podman logs - multi k8s-file" {
|
||||
|
|
|
@ -24,8 +24,8 @@ load helpers
|
|||
"${cid:0:12} \+$IMAGE \+sleep [0-9]\+ .*second.* $cname"\
|
||||
"output from podman ps"
|
||||
|
||||
# OK. Wait for sleep to finish...
|
||||
run_podman wait $cid
|
||||
# OK. Stop container now.
|
||||
run_podman stop -t0 $cid
|
||||
|
||||
# ...then make sure container shows up as stopped
|
||||
run_podman ps -a
|
||||
|
|
|
@ -124,10 +124,10 @@ function __run_healthcheck_container() {
|
|||
run_podman run -d --name $1 \
|
||||
--health-cmd /bin/false \
|
||||
--health-interval 1s \
|
||||
--health-retries 2 \
|
||||
--health-retries 1 \
|
||||
--health-timeout 1s \
|
||||
--health-on-failure=stop \
|
||||
--stop-timeout=2 \
|
||||
--stop-timeout=1 \
|
||||
--health-start-period 0 \
|
||||
--stop-signal SIGTERM \
|
||||
$IMAGE sleep infinity
|
||||
|
@ -156,7 +156,7 @@ function __run_healthcheck_container() {
|
|||
assert "$output" =~ "Error: cannot remove container $cid as it is .* - running or paused containers cannot be removed without force: container state improper" \
|
||||
"Expected error message from podman rm"
|
||||
rm_failures=$((rm_failures + 1))
|
||||
sleep 1
|
||||
sleep 0.5
|
||||
done
|
||||
|
||||
# At this point, container should be gone
|
||||
|
|
|
@ -7,35 +7,18 @@ load helpers
|
|||
|
||||
# bats test_tags=distro-integration
|
||||
@test "podman kill - test signal handling in containers" {
|
||||
|
||||
# Prepare for 'logs -f'
|
||||
run_podman info --format '{{.Host.LogDriver}}'
|
||||
log_driver=$output
|
||||
run_podman info --format '{{.Host.EventLogger}}'
|
||||
event_logger=$output
|
||||
opt_log_driver=
|
||||
if [ $log_driver = "journald" ] && [ $event_logger != "journald" ]; then
|
||||
# Since PR#10431, 'logs -f' with journald driver is only supported with journald events backend.
|
||||
# Set '--log driver' temporally because remote doesn't support '--events-backend'.
|
||||
opt_log_driver="--log-driver k8s-file"
|
||||
fi
|
||||
local cname=c-$(random_string 10)
|
||||
local fifo=${PODMAN_TMPDIR}/podman-kill-fifo.$(random_string 10)
|
||||
mkfifo $fifo
|
||||
|
||||
# Start a container that will handle all signals by emitting 'got: N'
|
||||
local -a signals=(1 2 3 4 5 6 8 10 12 13 14 15 16 20 21 22 23 24 25 26 64)
|
||||
run_podman run -d ${opt_log_driver} $IMAGE sh -c \
|
||||
$PODMAN run --name $cname $IMAGE sh -c \
|
||||
"for i in ${signals[*]}; do trap \"echo got: \$i\" \$i; done;
|
||||
echo READY;
|
||||
while ! test -e /stop; do sleep 0.1; done;
|
||||
echo DONE"
|
||||
cid="$output"
|
||||
|
||||
# Run 'logs -f' on that container, but run it in the background with
|
||||
# redirection to a named pipe from which we (foreground job) read
|
||||
# and confirm that signals are received. We can't use run_podman here.
|
||||
local fifo=${PODMAN_TMPDIR}/podman-kill-fifo.$(random_string 10)
|
||||
mkfifo $fifo
|
||||
$PODMAN logs -f $cid >$fifo </dev/null &
|
||||
podman_log_pid=$!
|
||||
echo DONE" &>$fifo </dev/null &
|
||||
podman_run_pid=$!
|
||||
|
||||
# Open the FIFO for reading, and keep it open. This prevents a race
|
||||
# condition in which the container can exit (e.g. if for some reason
|
||||
|
@ -54,7 +37,7 @@ load helpers
|
|||
local signal=$1
|
||||
local signum=${2:-$1} # e.g. if signal=HUP, we expect to see '1'
|
||||
|
||||
run_podman kill -s $signal $cid
|
||||
run_podman kill -s $signal $cname
|
||||
read -t 60 -u 5 actual || die "Timed out: no ACK for kill -s $signal"
|
||||
is "$actual" "got: $signum" "Signal $signal handled by container"
|
||||
}
|
||||
|
@ -74,14 +57,13 @@ load helpers
|
|||
# Done. Tell the container to stop, and wait for final DONE.
|
||||
# The '-d' is because container exit is racy: the exec process itself
|
||||
# could get caught and killed by cleanup, causing this step to exit 137
|
||||
run_podman exec -d $cid touch /stop
|
||||
run_podman exec -d $cname touch /stop
|
||||
read -t 5 -u 5 done || die "Timed out waiting for DONE from container"
|
||||
is "$done" "DONE" "final log message from container"
|
||||
|
||||
# Clean up
|
||||
run_podman wait $cid
|
||||
run_podman rm $cid
|
||||
wait $podman_log_pid
|
||||
run_podman rm -f -t0 $cname
|
||||
wait $podman_run_pid || die "wait for podman run failed"
|
||||
}
|
||||
|
||||
@test "podman kill - rejects invalid args" {
|
||||
|
|
|
@ -213,8 +213,8 @@ function check_shell_completion() {
|
|||
|
||||
i=$(($i + 1))
|
||||
# If the argument ends with ...] than we accept 0...n args
|
||||
# Loop three times to make sure we are not only completing the first arg
|
||||
if [[ ! ${arg} =~ "..." ]] || [[ i -gt 3 ]]; then
|
||||
# Loop two times to make sure we are not only completing the first arg
|
||||
if [[ ! ${arg} =~ "..." ]] || [[ i -gt 1 ]]; then
|
||||
break
|
||||
fi
|
||||
|
||||
|
|
|
@ -31,8 +31,7 @@ metadata:
|
|||
spec:
|
||||
containers:
|
||||
- command:
|
||||
- sleep
|
||||
- \"100\"
|
||||
- /home/podman/pause
|
||||
env:
|
||||
- name: PATH
|
||||
value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
@ -811,15 +810,12 @@ EOF
|
|||
}
|
||||
|
||||
@test "podman kube generate tmpfs on /tmp" {
|
||||
KUBE=$PODMAN_TMPDIR/kube.yaml
|
||||
run_podman create --name test $IMAGE sleep 100
|
||||
run_podman kube generate test -f $KUBE
|
||||
run_podman kube play $KUBE
|
||||
run_podman exec test-pod-test sh -c "mount | grep /tmp"
|
||||
local yaml=$PODMAN_TMPDIR/test.yaml
|
||||
_write_test_yaml command=/home/podman/pause
|
||||
run_podman kube play $yaml
|
||||
run_podman exec test_pod-test sh -c "mount | grep /tmp"
|
||||
assert "$output" !~ "noexec" "mounts on /tmp should not be noexec"
|
||||
run_podman kube down $KUBE
|
||||
run_podman pod rm -a -f -t 0
|
||||
run_podman rm -a -f -t 0
|
||||
run_podman kube down $yaml
|
||||
}
|
||||
|
||||
@test "podman kube play - pull policy" {
|
||||
|
|
Loading…
Reference in New Issue