Stop the smoke test from passing when it measured nothing

Two checks could report success without having verified anything. The version
check read the last line of output without looking at the exit status, so an
import failure printed a traceback whose last line was accepted as a version.
The shutdown check waited for the process to reach its watch loop but carried
on regardless, so if the container had already exited it measured the shutdown
of something that was not running.

The version check now requires a zero exit and a version shaped like one. The
shutdown check fails and prints the container log when the watch loop is never
reached. Both were confirmed against an image with a deliberately removed
module: each reports a failure where it previously reported success.
This commit is contained in:
Maxim Shulga committed 2026-08-02 19:46:27 -07:00
1 parent 84519cf7cc
commit f535e8b7d0
1 file changed
+25 -7
+25 -7
View File
@@ -31,13 +31,18 @@ check() { # check <description> <expected> <actual>
run() { docker run --rm $PLATFORM_ARG "$@"; } run() { docker run --rm $PLATFORM_ARG "$@"; }
echo "== imports and pinned client version" echo "== imports and pinned client version"
out=$(run "$IMAGE" python3 -c " # The exit status matters as much as the output: a traceback also prints a
# non-empty last line, and must not be mistaken for a version.
if out=$(run "$IMAGE" python3 -c "
import os, seafile, pysearpc, dsc.client, dsc.misc, dsc.paths, dsc.secrets, dsc.config import os, seafile, pysearpc, dsc.client, dsc.misc, dsc.paths, dsc.secrets, dsc.config
print(os.environ.get('SEAFILE_CLI_VERSION', 'unset'))" 2>&1 | tail -1) print('VERSION', os.environ['SEAFILE_CLI_VERSION'])" 2>&1); then
if [ -n "$out" ] && [ "$out" != "unset" ]; then version=$(printf '%s\n' "$out" | sed -n 's/^VERSION //p')
pass "imports resolve, seafile client version is $out" case "$version" in
[0-9]*.[0-9]*) pass "imports resolve, seafile client version is $version" ;;
*) fail "no usable version reported, output was: $out" ;;
esac
else else
fail "imports or SEAFILE_CLI_VERSION missing: $out" fail "imports or SEAFILE_CLI_VERSION failed: $out"
fi fi
echo "== the real daemon starts, reports ready, and stops" echo "== the real daemon starts, reports ready, and stops"
@@ -77,12 +82,25 @@ raise SystemExit(
) )
" >/dev/null " >/dev/null
# Wait for the daemon to be up and the process to be in its watch loop. # Wait for the daemon to be up and the process to be in its watch loop. If it
# never gets there the shutdown assertions mean nothing, so say so loudly
# instead of measuring the shutdown of something that already exited.
watching=0
for _ in $(seq 1 60); do for _ in $(seq 1 60); do
docker logs dsc-smoke 2>&1 | grep -q WATCHING && break if docker logs dsc-smoke 2>&1 | grep -q WATCHING; then watching=1; break; fi
sleep 1 sleep 1
done done
if [ "$watching" -eq 0 ]; then
fail "the container never reached its watch loop, shutdown not measured"
printf ' container log:\n'
docker logs dsc-smoke 2>&1 | sed 's/^/ /' | tail -20
docker rm -f dsc-smoke >/dev/null
echo
echo "smoke test failed: $failures check(s)"
exit 1
fi
started=$(date +%s) started=$(date +%s)
docker stop dsc-smoke >/dev/null docker stop dsc-smoke >/dev/null
elapsed=$(( $(date +%s) - started )) elapsed=$(( $(date +%s) - started ))