test(e2e): drop bash-only RETURN trap from bucket.bats port-forward

The previous attempt added a bash `trap '...' RETURN` to clean up
kubectl port-forward when the test function returned. cozytest.sh
sources its converted bats test bodies into the runner shell, which
on the GitHub-hosted Linux runner is /bin/sh -> dash. dash does not
implement the bash-specific RETURN pseudo-signal, so the trap
command exits non-zero, the surrounding `set -eu` aborts the test
body immediately, and the captured output stops two lines after
`name=test` with no other diagnostic — the test never reaches the
mc S3 operations at all.

Drop the trap and rely on cozytest.sh's existing process-group
cleanup: when the test function returns, the leftover port-forward
job in the same group is terminated. This restores POSIX shell
compatibility while keeping the lifecycle fix from the previous
commit (no `bash -c '... &'` wrapper, port-forward stays alive
through the mc operations because it is a child of the calling
shell, not of a transient subshell that exits immediately).

Signed-off-by: Ivan Okhotnikov <ivan.okhotnikov@aenix.io>
This commit is contained in:
Ivan Okhotnikov committed 2026-06-15 23:05:59 +03:00
1 parent 07cca8b6b3
commit f74c44b063
1 file changed
+3 -3
+3 -3
View File
@@ -42,10 +42,10 @@ EOF
# wrapper subshell exits immediately, the backgrounded kubectl becomes an
# orphan and gets reaped before the first mc S3 request, so `mc cp` sees
# `dial tcp 127.0.0.1:8333: connect: connection refused` even though the
# earlier `nc -z` probe succeeded.
# earlier `nc -z` probe succeeded). The forked port-forward inherits the
# test process group; cozytest.sh kills the whole group when the test
# function returns, so no explicit cleanup is needed.
kubectl port-forward service/seaweedfs-s3 -n tenant-root 8333:8333 >/dev/null 2>&1 &
PORT_FORWARD_PID=$!
trap 'kill ${PORT_FORWARD_PID} 2>/dev/null || true' RETURN
# Wait for port-forward to be ready
timeout 30 sh -ec 'until nc -z 127.0.0.1 8333; do sleep 1; done'