From 1f9e078ed07606eab3f985ef238396045fb7fc2f Mon Sep 17 00:00:00 2001 From: Myasnikov Daniil Date: Thu, 5 Nov 2026 07:56:39 +0000 Subject: [PATCH] test(backups): remove the Altinity strategy tests' scratch directories Every test in hack/altinity-backup-strategy.bats made a directory with mktemp -d and never removed it, so each passing run of the file left nine directories in TMPDIR, and they pile up on any machine that keeps it between runs. Each test now removes its directory as its last statement. A failed assertion aborts the body before that line, so a failing test keeps its stub log and rendered script for inspection. Assisted-by: LLM Signed-off-by: Myasnikov Daniil (cherry picked from commit d5559bb934c5c264eff0101fa30a1387e1144692) Signed-off-by: cozystack-ci[bot] <274107086+cozystack-ci[bot]@users.noreply.github.com> --- hack/altinity-backup-strategy.bats | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hack/altinity-backup-strategy.bats b/hack/altinity-backup-strategy.bats index 234ef0b8b..0861da42d 100644 --- a/hack/altinity-backup-strategy.bats +++ b/hack/altinity-backup-strategy.bats @@ -105,6 +105,7 @@ remote_rows() { echo "FAIL: render_script reported success with no chart" false fi + rm -rf "$tmp" } @test "restore reads back the archive the Backup recorded, not the newest one" { @@ -116,6 +117,7 @@ remote_rows() { PATH="$tmp/bin:$PATH" bash "$tmp/s.sh" grep -qxF 'POST http://chi-clickhouse-myapp-clickhouse-0-0.tenant-x.svc:7171/backup/restore_remote/clickhouse-myapp-20260304T050607Z' "$tmp/curl.log" [ "$(grep -c '/backup/restore_remote/' "$tmp/curl.log")" -eq 1 ] + rm -rf "$tmp" } @test "restore fails naming the recorded archive when remote storage lacks it" { @@ -133,6 +135,7 @@ remote_rows() { echo "FAIL: restored another archive: $(cat "$tmp/curl.log")" false fi + rm -rf "$tmp" } @test "restore of a Backup without a recorded archive takes the newest one stamped by its takenAt, and warns" { @@ -150,6 +153,7 @@ remote_rows() { grep -qxF 'POST http://chi-clickhouse-myapp-clickhouse-0-0.tenant-x.svc:7171/backup/restore_remote/clickhouse-myapp-20260304T050607Z' "$tmp/curl.log" [ "$(grep -c '/backup/restore_remote/' "$tmp/curl.log")" -eq 1 ] printf '%s\n' "$out" | grep -qF 'WARNING: Backup bkp-a records no archive name' + rm -rf "$tmp" } @test "restore of a Backup without a recorded archive fails when no archive is stamped by its takenAt" { @@ -167,6 +171,7 @@ remote_rows() { echo "FAIL: restored an archive newer than takenAt: $(cat "$tmp/curl.log")" false fi + rm -rf "$tmp" } @test "backup writes the archive under the name the controller chose" { @@ -175,6 +180,7 @@ remote_rows() { render_script "$tmp/s.sh" backup myapp clickhouse-myapp-20260304T050607Z "" "" PATH="$tmp/bin:$PATH" bash "$tmp/s.sh" grep -qxF 'POST http://chi-clickhouse-myapp-clickhouse-0-0.tenant-x.svc:7171/backup/create_remote?name=clickhouse-myapp-20260304T050607Z&resume=true' "$tmp/curl.log" + rm -rf "$tmp" } @test "a retried backup waits on the attempt the sidecar is still running" { @@ -189,6 +195,7 @@ remote_rows() { echo "FAIL: started another operation over the running one: $(cat "$tmp/curl.log")" false fi + rm -rf "$tmp" } @test "a retried backup after a failed attempt resumes the same archive" { @@ -198,6 +205,7 @@ remote_rows() { printf '{"command":"create_remote clickhouse-myapp-20260304T050607Z","status":"error","start":"2026-03-04 05:06:08","error":"S3 PutObject 403"}\n' > "$tmp/actions" PATH="$tmp/bin:$PATH" bash "$tmp/s.sh" grep -qxF 'POST http://chi-clickhouse-myapp-clickhouse-0-0.tenant-x.svc:7171/backup/create_remote?name=clickhouse-myapp-20260304T050607Z&resume=true' "$tmp/curl.log" + rm -rf "$tmp" } @test "backup falls back to a timestamped name when the controller supplies none" { @@ -206,4 +214,5 @@ remote_rows() { render_script "$tmp/s.sh" backup myapp "" "" "" PATH="$tmp/bin:$PATH" bash "$tmp/s.sh" grep -qE '^POST http://[^ ]*/backup/create_remote\?name=clickhouse-myapp-[0-9]{8}T[0-9]{6}Z&resume=true$' "$tmp/curl.log" + rm -rf "$tmp" }