From f74c44b0638dd7040d32074c1614d7012dfd445d Mon Sep 17 00:00:00 2001 From: Ivan Okhotnikov Date: Mon, 15 Jun 2026 23:05:59 +0300 Subject: [PATCH] test(e2e): drop bash-only RETURN trap from bucket.bats port-forward MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- hack/e2e-apps/bucket.bats | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hack/e2e-apps/bucket.bats b/hack/e2e-apps/bucket.bats index 5fc4480b1..e51053a60 100644 --- a/hack/e2e-apps/bucket.bats +++ b/hack/e2e-apps/bucket.bats @@ -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'