mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
Improve compose tests
* Add traps to report setup, tests, and teardown errors as failures * Pass through return code of podman commands * Fix unset variables * Fix simple_port_map image build when installing flask (PEP 668 - externally managed environment error) * Ignore kill errors in slirp4netns_opts teardown steps Signed-off-by: Gavin Lam <gavin.oss@tutamail.com>
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
FROM alpine
|
FROM alpine
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN apk update && apk add py3-pip && pip3 install flask
|
RUN apk update && apk add py3-flask
|
||||||
COPY . /app
|
COPY . /app
|
||||||
ENTRYPOINT ["python3"]
|
ENTRYPOINT ["python3"]
|
||||||
CMD ["app.py"]
|
CMD ["app.py"]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# -*- bash -*-
|
# -*- bash -*-
|
||||||
|
|
||||||
kill $nc_pid &> /dev/null
|
kill $nc_pid &> /dev/null || true
|
||||||
rm -f $OUTFILE
|
rm -f $OUTFILE
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#
|
#
|
||||||
# Usage: test-compose [testname]
|
# Usage: test-compose [testname]
|
||||||
#
|
#
|
||||||
|
set -Eu
|
||||||
ME=$(basename $0)
|
ME=$(basename $0)
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@ -240,7 +241,10 @@ function podman() {
|
|||||||
--runroot $WORKDIR/runroot \
|
--runroot $WORKDIR/runroot \
|
||||||
--network-config-dir $WORKDIR/cni \
|
--network-config-dir $WORKDIR/cni \
|
||||||
"$@")
|
"$@")
|
||||||
|
rc=$?
|
||||||
|
|
||||||
echo -n "$output" >>$WORKDIR/output.log
|
echo -n "$output" >>$WORKDIR/output.log
|
||||||
|
return $rc
|
||||||
}
|
}
|
||||||
|
|
||||||
###################
|
###################
|
||||||
@ -300,8 +304,8 @@ for t in "${tests_to_run[@]}"; do
|
|||||||
testdir="$(dirname $t)"
|
testdir="$(dirname $t)"
|
||||||
testname="$(basename $testdir)"
|
testname="$(basename $testdir)"
|
||||||
|
|
||||||
if [ -e $test_dir/SKIP ]; then
|
if [ -e $testdir/SKIP ]; then
|
||||||
reason="$(<$test_dir/SKIP)"
|
reason="$(<$testdir/SKIP)"
|
||||||
if [ -n "$reason" ]; then
|
if [ -n "$reason" ]; then
|
||||||
reason=" - $reason"
|
reason=" - $reason"
|
||||||
fi
|
fi
|
||||||
@ -315,13 +319,21 @@ for t in "${tests_to_run[@]}"; do
|
|||||||
(
|
(
|
||||||
cd $testdir || die "Cannot cd $testdir"
|
cd $testdir || die "Cannot cd $testdir"
|
||||||
|
|
||||||
|
if [ -e teardown.sh ]; then
|
||||||
|
trap 'teardown' EXIT
|
||||||
|
function teardown() {
|
||||||
|
trap '_show_ok 0 "$testname - teardown" "[ok]" "[error]"' ERR
|
||||||
|
. teardown.sh
|
||||||
|
trap - ERR
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
# setup file may be used for creating temporary directories/files.
|
# setup file may be used for creating temporary directories/files.
|
||||||
# We source it so that envariables defined in it will get back to us.
|
# We source it so that envariables defined in it will get back to us.
|
||||||
if [ -e setup.sh ]; then
|
if [ -e setup.sh ]; then
|
||||||
|
trap '_show_ok 0 "$testname - setup" "[ok]" "[error]"' ERR
|
||||||
. setup.sh
|
. setup.sh
|
||||||
fi
|
trap - ERR
|
||||||
if [ -e teardown.sh ]; then
|
|
||||||
trap '. teardown.sh' 0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
podman compose up -d &> $logfile
|
podman compose up -d &> $logfile
|
||||||
@ -337,11 +349,13 @@ for t in "${tests_to_run[@]}"; do
|
|||||||
# Run tests. This is likely to be a series of 'test_port' checks
|
# Run tests. This is likely to be a series of 'test_port' checks
|
||||||
# but may also include podman commands to inspect labels, state
|
# but may also include podman commands to inspect labels, state
|
||||||
if [ -e tests.sh ]; then
|
if [ -e tests.sh ]; then
|
||||||
|
trap '_show_ok 0 "$testname - tests" "[ok]" "[error]"' ERR
|
||||||
. tests.sh
|
. tests.sh
|
||||||
|
trap - ERR
|
||||||
fi
|
fi
|
||||||
# FIXME: if any tests fail, try 'podman logs' on container?
|
# FIXME: if any tests fail, try 'podman logs' on container?
|
||||||
|
|
||||||
if [ -n "$COMPOSE_WAIT" ]; then
|
if [ -n "${COMPOSE_WAIT:-}" ]; then
|
||||||
echo -n "Pausing due to \$COMPOSE_WAIT. Press ENTER to continue: "
|
echo -n "Pausing due to \$COMPOSE_WAIT. Press ENTER to continue: "
|
||||||
read keepgoing
|
read keepgoing
|
||||||
fi
|
fi
|
||||||
@ -379,7 +393,7 @@ done
|
|||||||
test_count=$(<$testcounter_file)
|
test_count=$(<$testcounter_file)
|
||||||
failure_count=$(<$failures_file)
|
failure_count=$(<$failures_file)
|
||||||
|
|
||||||
if [ -z "$PODMAN_TESTS_KEEP_WORKDIR" ]; then
|
if [ -z "${PODMAN_TESTS_KEEP_WORKDIR:-}" ]; then
|
||||||
if ! is_rootless; then
|
if ! is_rootless; then
|
||||||
rm -rf $WORKDIR
|
rm -rf $WORKDIR
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user