mirror of
https://github.com/containers/podman.git
synced 2025-06-21 17:38:12 +08:00
Merge pull request #8720 from edsantiago/bats
system tests: the catch-up game
This commit is contained in:
@ -548,27 +548,33 @@ json-file | f
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test "Verify /run/.containerenv exist" {
|
@test "Verify /run/.containerenv exist" {
|
||||||
run_podman run --rm $IMAGE ls -1 /run/.containerenv
|
# Nonprivileged container: file exists, but must be empty
|
||||||
is "$output" "/run/.containerenv"
|
run_podman run --rm $IMAGE stat -c '%s' /run/.containerenv
|
||||||
|
is "$output" "0" "file size of /run/.containerenv, nonprivileged"
|
||||||
|
|
||||||
run_podman run --privileged --rm $IMAGE sh -c '. /run/.containerenv; echo $engine'
|
# Prep work: get ID of image; make a cont. name; determine if we're rootless
|
||||||
is "$output" ".*podman.*" "failed to identify engine"
|
run_podman inspect --format '{{.ID}}' $IMAGE
|
||||||
|
local iid="$output"
|
||||||
|
|
||||||
run_podman run --privileged --name "testcontainerenv" --rm $IMAGE sh -c '. /run/.containerenv; echo $name'
|
random_cname=c$(random_string 15 | tr A-Z a-z)
|
||||||
is "$output" ".*testcontainerenv.*"
|
local rootless=0
|
||||||
|
if is_rootless; then
|
||||||
|
rootless=1
|
||||||
|
fi
|
||||||
|
|
||||||
run_podman run --privileged --rm $IMAGE sh -c '. /run/.containerenv; echo $image'
|
run_podman run --privileged --rm --name $random_cname $IMAGE \
|
||||||
is "$output" ".*$IMAGE.*" "failed to idenitfy image"
|
sh -c '. /run/.containerenv; echo $engine; echo $name; echo $image; echo $id; echo $imageid; echo $rootless'
|
||||||
|
|
||||||
run_podman run --privileged --rm $IMAGE sh -c '. /run/.containerenv; echo $rootless'
|
# FIXME: on some CI systems, 'run --privileged' emits a spurious
|
||||||
# FIXME: on some CI systems, 'run --privileged' emits a spurious
|
# warning line about dup devices. Ignore it.
|
||||||
# warning line about dup devices. Ignore it.
|
remove_same_dev_warning
|
||||||
remove_same_dev_warning
|
|
||||||
if is_rootless; then
|
is "${lines[0]}" "podman-.*" 'containerenv : $engine'
|
||||||
is "$output" "1"
|
is "${lines[1]}" "$random_cname" 'containerenv : $name'
|
||||||
else
|
is "${lines[2]}" "$IMAGE" 'containerenv : $image'
|
||||||
is "$output" "0"
|
is "${lines[3]}" "[0-9a-f]\{64\}" 'containerenv : $id'
|
||||||
fi
|
is "${lines[4]}" "$iid" 'containerenv : $imageid'
|
||||||
|
is "${lines[5]}" "$rootless" 'containerenv : $rootless'
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "podman run with --net=host and --port prints warning" {
|
@test "podman run with --net=host and --port prints warning" {
|
||||||
|
@ -82,4 +82,43 @@ load helpers
|
|||||||
run_podman rm -a
|
run_podman rm -a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "podman ps -a --storage" {
|
||||||
|
skip_if_remote "ps --storage does not work over remote"
|
||||||
|
|
||||||
|
# Setup: ensure that we have no hidden storage containers
|
||||||
|
run_podman ps --storage -a
|
||||||
|
is "${#lines[@]}" "1" "setup check: no storage containers at start of test"
|
||||||
|
|
||||||
|
# Force a buildah timeout; this leaves a buildah container behind
|
||||||
|
PODMAN_TIMEOUT=5 run_podman 124 build -t thiswillneverexist - <<EOF
|
||||||
|
FROM $IMAGE
|
||||||
|
RUN sleep 30
|
||||||
|
EOF
|
||||||
|
|
||||||
|
run_podman ps -a
|
||||||
|
is "${#lines[@]}" "1" "podman ps -a does not see buildah container"
|
||||||
|
|
||||||
|
run_podman ps --storage -a
|
||||||
|
is "${#lines[@]}" "2" "podman ps -a --storage sees buildah container"
|
||||||
|
is "${lines[1]}" \
|
||||||
|
"[0-9a-f]\{12\} \+$IMAGE *buildah .* seconds ago .* storage .* ${PODMAN_TEST_IMAGE_NAME}-working-container" \
|
||||||
|
"podman ps --storage"
|
||||||
|
|
||||||
|
cid="${lines[1]:0:12}"
|
||||||
|
|
||||||
|
# 'rm -a' should be a NOP
|
||||||
|
run_podman rm -a
|
||||||
|
run_podman ps --storage -a
|
||||||
|
is "${#lines[@]}" "2" "podman ps -a --storage sees buildah container"
|
||||||
|
|
||||||
|
# This is what deletes the container
|
||||||
|
# FIXME: why doesn't "podman rm --storage $cid" do anything?
|
||||||
|
run_podman rm -f "$cid"
|
||||||
|
|
||||||
|
run_podman ps --storage -a
|
||||||
|
is "${#lines[@]}" "1" "storage container has been removed"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# vim: filetype=sh
|
# vim: filetype=sh
|
||||||
|
@ -100,8 +100,17 @@ function _assert_mainpid_is_conmon() {
|
|||||||
run_podman logs sdnotify_conmon_c
|
run_podman logs sdnotify_conmon_c
|
||||||
is "$output" "READY" "\$NOTIFY_SOCKET in container"
|
is "$output" "READY" "\$NOTIFY_SOCKET in container"
|
||||||
|
|
||||||
|
# The 'echo's help us debug failed runs
|
||||||
run cat $_SOCAT_LOG
|
run cat $_SOCAT_LOG
|
||||||
is "${lines[-1]}" "READY=1" "final output from sdnotify"
|
echo "socat log:"
|
||||||
|
echo "$output"
|
||||||
|
|
||||||
|
# ARGH! 'READY=1' should always be the last output line. But sometimes,
|
||||||
|
# for reasons unknown, we get an extra MAINPID=xxx after READY=1 (#8718).
|
||||||
|
# Who knows if this is a systemd bug, or conmon, or what. I don't
|
||||||
|
# even know where to begin asking. So, to eliminate the test flakes,
|
||||||
|
# we look for READY=1 _anywhere_ in the output, not just the last line.
|
||||||
|
is "$output" ".*READY=1.*" "sdnotify sent READY=1"
|
||||||
|
|
||||||
_assert_mainpid_is_conmon "${lines[0]}"
|
_assert_mainpid_is_conmon "${lines[0]}"
|
||||||
|
|
||||||
|
@ -168,8 +168,11 @@ function run_podman() {
|
|||||||
|
|
||||||
if [ "$status" -eq 124 ]; then
|
if [ "$status" -eq 124 ]; then
|
||||||
if expr "$output" : ".*timeout: sending" >/dev/null; then
|
if expr "$output" : ".*timeout: sending" >/dev/null; then
|
||||||
echo "*** TIMED OUT ***"
|
# It's possible for a subtest to _want_ a timeout
|
||||||
false
|
if [[ "$expected_rc" != "124" ]]; then
|
||||||
|
echo "*** TIMED OUT ***"
|
||||||
|
false
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user