mirror of https://github.com/containers/podman.git
Merge pull request #22821 from Luap99/fast-system-test
test/system: make some tests faster part 1
This commit is contained in:
commit
aca5a7b036
|
@ -778,7 +778,7 @@ json-file | f
|
||||||
@test "podman run --timeout - basic test" {
|
@test "podman run --timeout - basic test" {
|
||||||
cid=timeouttest
|
cid=timeouttest
|
||||||
t0=$SECONDS
|
t0=$SECONDS
|
||||||
run_podman 255 run --name $cid --timeout 10 $IMAGE sleep 60
|
run_podman 255 run --name $cid --timeout 2 $IMAGE sleep 60
|
||||||
t1=$SECONDS
|
t1=$SECONDS
|
||||||
# Confirm that container is stopped. Podman-remote unfortunately
|
# Confirm that container is stopped. Podman-remote unfortunately
|
||||||
# cannot tell the difference between "stopped" and "exited", and
|
# cannot tell the difference between "stopped" and "exited", and
|
||||||
|
@ -790,8 +790,8 @@ json-file | f
|
||||||
# This operation should take
|
# This operation should take
|
||||||
# exactly 10 seconds. Give it some leeway.
|
# exactly 10 seconds. Give it some leeway.
|
||||||
delta_t=$(( $t1 - $t0 ))
|
delta_t=$(( $t1 - $t0 ))
|
||||||
assert "$delta_t" -gt 8 "podman stop: ran too quickly!"
|
assert "$delta_t" -gt 1 "podman stop: ran too quickly!"
|
||||||
assert "$delta_t" -le 14 "podman stop: took too long"
|
assert "$delta_t" -le 6 "podman stop: took too long"
|
||||||
|
|
||||||
run_podman rm $cid
|
run_podman rm $cid
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,20 +136,6 @@ load helpers
|
||||||
run_podman rm -t 0 -f $cid
|
run_podman rm -t 0 -f $cid
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "podman exec --wait" {
|
|
||||||
skip_if_remote "test is meaningless over remote"
|
|
||||||
|
|
||||||
# wait on bogus container
|
|
||||||
run_podman 125 exec --wait 5 "bogus_container" echo hello
|
|
||||||
assert "$output" = "Error: timed out waiting for container: bogus_container"
|
|
||||||
|
|
||||||
run_podman create --name "wait_container" $IMAGE top
|
|
||||||
run_podman 255 exec --wait 5 "wait_container" echo hello
|
|
||||||
assert "$output" = "Error: can only create exec sessions on running containers: container state improper"
|
|
||||||
|
|
||||||
run_podman rm -f wait_container
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "podman run umask" {
|
@test "podman run umask" {
|
||||||
umask="0724"
|
umask="0724"
|
||||||
run_podman run --rm -q $IMAGE grep Umask /proc/self/status
|
run_podman run --rm -q $IMAGE grep Umask /proc/self/status
|
||||||
|
|
|
@ -7,41 +7,34 @@ load helpers
|
||||||
load helpers.network
|
load helpers.network
|
||||||
|
|
||||||
# bats test_tags=distro-integration
|
# bats test_tags=distro-integration
|
||||||
@test "events with a filter by label" {
|
@test "events with a filter by label and --no-trunc option" {
|
||||||
cname=test-$(random_string 30 | tr A-Z a-z)
|
cname=test-$(random_string 30 | tr A-Z a-z)
|
||||||
labelname=$(random_string 10)
|
labelname=$(random_string 10)
|
||||||
labelvalue=$(random_string 15)
|
labelvalue=$(random_string 15)
|
||||||
|
|
||||||
run_podman run --label $labelname=$labelvalue --name $cname --rm $IMAGE ls
|
before=$(date --iso-8601=seconds)
|
||||||
|
run_podman run -d --label $labelname=$labelvalue --name $cname --rm $IMAGE true
|
||||||
|
id="$output"
|
||||||
|
|
||||||
expect=".* container start [0-9a-f]\+ (image=$IMAGE, name=$cname,.* ${labelname}=${labelvalue}"
|
expect=".* container start $id (image=$IMAGE, name=$cname,.* ${labelname}=${labelvalue}"
|
||||||
run_podman events --filter type=container -f container=$cname --filter label=${labelname}=${labelvalue} --filter event=start --stream=false
|
run_podman events --since "$before" --filter type=container -f container=$cname --filter label=${labelname}=${labelvalue} --filter event=start --stream=false
|
||||||
is "$output" "$expect" "filtering by container name and label"
|
is "$output" "$expect" "filtering by container name and label"
|
||||||
|
|
||||||
# Same thing, but without the container-name filter
|
# Same thing, but without the container-name filter
|
||||||
run_podman system events -f type=container --filter label=${labelname}=${labelvalue} --filter event=start --stream=false
|
run_podman system events --since "$before" -f type=container --filter label=${labelname}=${labelvalue} --filter event=start --stream=false
|
||||||
is "$output" "$expect" "filtering just by label"
|
is "$output" "$expect" "filtering just by label"
|
||||||
|
|
||||||
# Now filter just by container name, no label
|
# Now filter just by container name, no label
|
||||||
run_podman events --filter type=container --filter container=$cname --filter event=start --stream=false
|
run_podman events --since "$before" --filter type=container --filter container=$cname --filter event=start --stream=false
|
||||||
is "$output" "$expect" "filtering just by container"
|
is "$output" "$expect" "filtering just by container"
|
||||||
}
|
|
||||||
|
|
||||||
@test "truncate events" {
|
|
||||||
cname=test-$(random_string 30 | tr A-Z a-z)
|
|
||||||
|
|
||||||
run_podman run -d --name=$cname --rm $IMAGE echo hi
|
|
||||||
id="$output"
|
|
||||||
|
|
||||||
run_podman events --filter container=$cname --filter event=start --stream=false
|
|
||||||
is "$output" ".* $id " "filtering by container name full id"
|
|
||||||
|
|
||||||
|
# check --no-trunc=false
|
||||||
truncID=${id:0:12}
|
truncID=${id:0:12}
|
||||||
run_podman events --filter container=$cname --filter event=start --stream=false --no-trunc=false
|
run_podman events --since "$before" --filter container=$cname --filter event=start --stream=false --no-trunc=false
|
||||||
is "$output" ".* $truncID " "filtering by container name trunc id"
|
is "$output" ".* $truncID " "filtering by container name trunc id"
|
||||||
|
|
||||||
# --no-trunc does not affect --format; we always get the full ID
|
# --no-trunc does not affect --format; we always get the full ID
|
||||||
run_podman events --filter container=$cname --filter event=died --stream=false --format='{{.ID}}--{{.Image}}' --no-trunc=false
|
run_podman events --since "$before" --filter container=$cname --filter event=died --stream=false --format='{{.ID}}--{{.Image}}' --no-trunc=false
|
||||||
assert "$output" = "${id}--${IMAGE}"
|
assert "$output" = "${id}--${IMAGE}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,14 +142,16 @@ function service_cleanup() {
|
||||||
@test "podman generate systemd - envar" {
|
@test "podman generate systemd - envar" {
|
||||||
cname=$(random_string)
|
cname=$(random_string)
|
||||||
FOO=value BAR=%s run_podman create --name $cname --env FOO -e BAR --env MYVAR=myval \
|
FOO=value BAR=%s run_podman create --name $cname --env FOO -e BAR --env MYVAR=myval \
|
||||||
$IMAGE sh -c 'printenv && sleep 100'
|
$IMAGE sh -c 'printenv && echo READY; trap 'exit' SIGTERM; while :; do sleep 0.1; done'
|
||||||
|
|
||||||
# Start systemd service to run this container
|
# Start systemd service to run this container
|
||||||
service_setup
|
service_setup
|
||||||
|
|
||||||
# Give container time to start; make sure output looks top-like
|
# Give container time to start and print output
|
||||||
sleep 2
|
# wait_for_ready returns directly if the logs matches and preserves $output
|
||||||
run_podman logs $cname
|
# for us so we do not have to call podman logs again here if we match the env below.
|
||||||
|
wait_for_ready $cname
|
||||||
|
|
||||||
is "$output" ".*FOO=value.*" "FOO environment variable set"
|
is "$output" ".*FOO=value.*" "FOO environment variable set"
|
||||||
is "$output" ".*BAR=%s.*" "BAR environment variable set"
|
is "$output" ".*BAR=%s.*" "BAR environment variable set"
|
||||||
is "$output" ".*MYVAR=myval.*" "MYVAL environment variable set"
|
is "$output" ".*MYVAR=myval.*" "MYVAL environment variable set"
|
||||||
|
@ -397,13 +399,13 @@ spec:
|
||||||
- command:
|
- command:
|
||||||
- sh
|
- sh
|
||||||
- -c
|
- -c
|
||||||
- echo a stdout; echo a stderr 1>&2; sleep inf
|
- echo a stdout; echo a stderr 1>&2; trap 'exit' SIGTERM; while :; do sleep 0.1; done
|
||||||
image: $IMAGE
|
image: $IMAGE
|
||||||
name: a
|
name: a
|
||||||
- command:
|
- command:
|
||||||
- sh
|
- sh
|
||||||
- -c
|
- -c
|
||||||
- echo b stdout; echo b stderr 1>&2; sleep inf
|
- echo b stdout; echo b stderr 1>&2; trap 'exit' SIGTERM; while :; do sleep 0.1; done
|
||||||
image: $IMAGE
|
image: $IMAGE
|
||||||
name: b
|
name: b
|
||||||
EOF
|
EOF
|
||||||
|
|
|
@ -132,7 +132,6 @@ function _confirm_update() {
|
||||||
# Image has already been pulled, so this shouldn't take too long
|
# Image has already been pulled, so this shouldn't take too long
|
||||||
local timeout=10
|
local timeout=10
|
||||||
while [[ $timeout -gt 0 ]]; do
|
while [[ $timeout -gt 0 ]]; do
|
||||||
sleep 1
|
|
||||||
run_podman '?' inspect --format "{{.Image}}" $cname
|
run_podman '?' inspect --format "{{.Image}}" $cname
|
||||||
if [[ $status != 0 ]]; then
|
if [[ $status != 0 ]]; then
|
||||||
if [[ $output =~ (no such object|does not exist in database): ]]; then
|
if [[ $output =~ (no such object|does not exist in database): ]]; then
|
||||||
|
@ -144,6 +143,7 @@ function _confirm_update() {
|
||||||
elif [[ $output != $old_iid ]]; then
|
elif [[ $output != $old_iid ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
sleep 1
|
||||||
timeout=$((timeout - 1))
|
timeout=$((timeout - 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -417,7 +417,7 @@ EOF
|
||||||
Description=Podman auto-update testing timer
|
Description=Podman auto-update testing timer
|
||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
OnCalendar=*-*-* *:*:0/2
|
OnActiveSec=0s
|
||||||
Persistent=true
|
Persistent=true
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
|
|
@ -475,31 +475,41 @@ none | true | false | 0
|
||||||
none | false | false | 0
|
none | false | false | 0
|
||||||
"
|
"
|
||||||
|
|
||||||
# I am sorry, this is a long test as we need to test the upper matrix
|
# In each iteration we switch between the sdnotify policy ignore and conmon.
|
||||||
# twice. The first run is using the default sdnotify policy of "ignore".
|
# We could run them in a loop for each case but the test is slow so let's
|
||||||
|
# just switch between them as it should cover both policies sufficiently.
|
||||||
|
# Note because of this make sure to have at least two exit code cases directly
|
||||||
|
# after each other above so both polices will get at least once the error case.
|
||||||
|
# The first run is using the default sdnotify policy of "ignore".
|
||||||
# In this case, the service container serves as the main PID of the service
|
# In this case, the service container serves as the main PID of the service
|
||||||
# to have a minimal resource footprint. The second run is using the
|
# to have a minimal resource footprint. The second run is using the
|
||||||
# "conmon" sdnotify policy in which case Podman needs to serve as the main
|
# "conmon" sdnotify policy in which case Podman needs to serve as the main
|
||||||
# PID to act as an sdnotify proxy; there Podman will wait for the service
|
# PID to act as an sdnotify proxy; there Podman will wait for the service
|
||||||
# container to exit and reflects its exit code.
|
# container to exit and reflects its exit code.
|
||||||
|
sdnotify_policy=ignore
|
||||||
while read exit_code_prop cmd1 cmd2 exit_code; do
|
while read exit_code_prop cmd1 cmd2 exit_code; do
|
||||||
for sdnotify_policy in ignore conmon; do
|
generate_exit_code_yaml $fname $cmd1 $cmd2 $sdnotify_policy
|
||||||
generate_exit_code_yaml $fname $cmd1 $cmd2 $sdnotify_policy
|
yaml_sha=$(sha256sum $fname)
|
||||||
yaml_sha=$(sha256sum $fname)
|
service_container="${yaml_sha:0:12}-service"
|
||||||
service_container="${yaml_sha:0:12}-service"
|
podman_exit=$exit_code
|
||||||
podman_exit=$exit_code
|
if [[ $sdnotify_policy == "ignore" ]];then
|
||||||
if [[ $sdnotify_policy == "ignore" ]];then
|
podman_exit=0
|
||||||
podman_exit=0
|
fi
|
||||||
fi
|
run_podman $podman_exit kube play --service-exit-code-propagation="$exit_code_prop" --service-container $fname
|
||||||
run_podman $podman_exit kube play --service-exit-code-propagation="$exit_code_prop" --service-container $fname
|
# Make sure that there are no error logs (e.g., #19715)
|
||||||
# Make sure that there are no error logs (e.g., #19715)
|
assert "$output" !~ "error msg="
|
||||||
assert "$output" !~ "error msg="
|
run_podman container inspect --format '{{.KubeExitCodePropagation}}' $service_container
|
||||||
run_podman container inspect --format '{{.KubeExitCodePropagation}}' $service_container
|
is "$output" "$exit_code_prop" "service container has the expected policy set in its annotations"
|
||||||
is "$output" "$exit_code_prop" "service container has the expected policy set in its annotations"
|
run_podman wait $service_container
|
||||||
run_podman wait $service_container
|
is "$output" "$exit_code" "service container exit code (propagation: $exit_code_prop, policy: $sdnotify_policy, cmds: $cmd1 + $cmd2)"
|
||||||
is "$output" "$exit_code" "service container exit code (propagation: $exit_code_prop, policy: $service_policy, cmds: $cmd1 + $cmd2)"
|
run_podman kube down $fname
|
||||||
run_podman kube down $fname
|
|
||||||
done
|
# in each iteration switch between conmon/ignore policy to get coverage for both
|
||||||
|
if [[ $sdnotify_policy == "ignore" ]]; then
|
||||||
|
sdnotify_policy=conmon
|
||||||
|
else
|
||||||
|
sdnotify_policy=ignore
|
||||||
|
fi
|
||||||
done < <(parse_table "$exit_tests")
|
done < <(parse_table "$exit_tests")
|
||||||
|
|
||||||
# A final smoke test to make sure bogus policies lead to an error
|
# A final smoke test to make sure bogus policies lead to an error
|
||||||
|
|
|
@ -633,21 +633,33 @@ EOF
|
||||||
# kube play --wait=true, where we clear up the created containers, pods, and volumes when a kill or sigterm is triggered
|
# kube play --wait=true, where we clear up the created containers, pods, and volumes when a kill or sigterm is triggered
|
||||||
@test "podman kube play --wait with siginterrupt" {
|
@test "podman kube play --wait with siginterrupt" {
|
||||||
cname=c$(random_string 15)
|
cname=c$(random_string 15)
|
||||||
fname="/tmp/play_kube_wait_$(random_string 6).yaml"
|
fname="$PODMAN_TMPDIR/play_kube_wait_$(random_string 6).yaml"
|
||||||
run_podman container create --name $cname $IMAGE top
|
echo "
|
||||||
run_podman kube generate -f $fname $cname
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
# delete the container we generated from
|
metadata:
|
||||||
run_podman rm -f $cname
|
labels:
|
||||||
|
app: test
|
||||||
|
name: test_pod
|
||||||
|
spec:
|
||||||
|
restartPolicy: Never
|
||||||
|
containers:
|
||||||
|
- name: server
|
||||||
|
image: $IMAGE
|
||||||
|
command:
|
||||||
|
- top
|
||||||
|
" > $fname
|
||||||
|
|
||||||
# force a timeout to happen so that the kube play command is killed
|
# force a timeout to happen so that the kube play command is killed
|
||||||
# and expect the timeout code 124 to happen so that we can clean up
|
# and expect the timeout code 124 to happen so that we can clean up
|
||||||
local t0=$SECONDS
|
local t0=$SECONDS
|
||||||
PODMAN_TIMEOUT=15 run_podman 124 kube play --wait $fname
|
PODMAN_TIMEOUT=2 run_podman 124 kube play --wait $fname
|
||||||
local t1=$SECONDS
|
local t1=$SECONDS
|
||||||
local delta_t=$((t1 - t0))
|
local delta_t=$((t1 - t0))
|
||||||
assert $delta_t -le 20 \
|
assert $delta_t -le 3 \
|
||||||
"podman kube play did not get killed within 10 seconds"
|
"podman kube play did not get killed within 3 seconds"
|
||||||
|
# Make sure we actually got SIGTERM and podman printed its message.
|
||||||
|
assert "$output" =~ "Cleaning up containers, pods, and volumes" "kube play printed sigterm message"
|
||||||
|
|
||||||
# there should be no containers running or created
|
# there should be no containers running or created
|
||||||
run_podman ps -aq
|
run_podman ps -aq
|
||||||
|
@ -656,7 +668,7 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "podman kube play --wait - wait for pod to exit" {
|
@test "podman kube play --wait - wait for pod to exit" {
|
||||||
fname="/tmp/play_kube_wait_$(random_string 6).yaml"
|
fname="$PODMAN_TMPDIR/play_kube_wait_$(random_string 6).yaml"
|
||||||
echo "
|
echo "
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Pod
|
kind: Pod
|
||||||
|
@ -881,8 +893,7 @@ spec:
|
||||||
done
|
done
|
||||||
assert $output == "2-healthy" "After 3 seconds"
|
assert $output == "2-healthy" "After 3 seconds"
|
||||||
|
|
||||||
run_podman kube down $fname
|
run_podman pod rm -fa -t0
|
||||||
run_podman pod rm -a
|
|
||||||
run_podman rm -a
|
run_podman rm -a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -934,8 +945,7 @@ spec:
|
||||||
done
|
done
|
||||||
assert $output == "2-unhealthy" "After 3 seconds"
|
assert $output == "2-unhealthy" "After 3 seconds"
|
||||||
|
|
||||||
run_podman kube down $fname
|
run_podman pod rm -fa -t0
|
||||||
run_podman pod rm -a
|
|
||||||
run_podman rm -a
|
run_podman rm -a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue