tests: Robustify exit code handling from podman

Apparently when encountering some cleanup errors (at least when podman
fails to remove its temporary network), podman exits with 0 instead of
with the exit code of the container workload. This hides failing tests.

Pass the test exit code to the host via the logs directory instead.
This commit is contained in:
Martin Pitt 2020-04-06 17:13:40 +02:00
parent 259131798c
commit 46f292cc92

View File

@ -28,8 +28,7 @@ firewall-cmd --add-service=cockpit
# want to install these on the tested image, so run the test in a container, # want to install these on the tested image, so run the test in a container,
# which tests the host. Use a fixed tag to avoid running into failures with # which tests the host. Use a fixed tag to avoid running into failures with
# "latest", as we don't gate container updates on the dist-git tests for now. # "latest", as we don't gate container updates on the dist-git tests for now.
RC=0 cat <<EOF | podman run --rm -i -v "$SOURCE:/source:ro" -v "$LOGS:/logs" docker.io/cockpit/tasks:2020-01-30 /bin/sh -eux || true
cat <<EOF | podman run --rm -i -v "$SOURCE:/source:ro" -v "$LOGS:/logs" docker.io/cockpit/tasks:2020-01-30 /bin/sh -eux || RC=$?
# CSP does not like the the invalid host name _gateway, so translate it # CSP does not like the the invalid host name _gateway, so translate it
HOST=\$(getent hosts _gateway | cut -f1 -d' ') HOST=\$(getent hosts _gateway | cut -f1 -d' ')
@ -53,7 +52,7 @@ export TEST_AUDIT_NO_SELINUX=1
RC=0 RC=0
# not all classes are nondestructive, and we can't run rebooting tests # not all classes are nondestructive, and we can't run rebooting tests
test/verify/check-packagekit -tv --machine \$HOST:22 --browser \$HOST:9090 TestUpdates.test{Basic,SecurityOnly} TestAutoUpdates || RC=1 test/verify/check-packagekit -tv --machine \$HOST:22 --browser \$HOST:9090 TestUpdates.test{Basic,SecurityOnly} TestAutoUpdates || RC=\$?
# check-menu is not @nondestructive yet, keep it last # check-menu is not @nondestructive yet, keep it last
for t in accounts for t in accounts
@ -65,10 +64,10 @@ for t in accounts
storage-partitions storage-partitions
storage-used storage-lvm2 storage-used storage-lvm2
menu; do menu; do
test/verify/check-\$t -tv --machine \$HOST:22 --browser \$HOST:9090 || RC=1 test/verify/check-\$t -tv --machine \$HOST:22 --browser \$HOST:9090 || RC=\$?
done done
exit \$RC echo \$RC > /logs/exitcode
EOF EOF
# reset system changes from verify tests, for running this multiple times in a row # reset system changes from verify tests, for running this multiple times in a row
@ -77,4 +76,5 @@ rm -f /etc/systemd/system/cockpit.service.d/notls.conf
systemctl daemon-reload systemctl daemon-reload
systemctl stop cockpit.service systemctl stop cockpit.service
RC=$(cat $LOGS/exitcode)
exit $RC exit $RC