From c138bd24d3750edc120f56eefba1556721f82ef6 Mon Sep 17 00:00:00 2001 From: Tobias Kaupat Date: Sat, 17 Oct 2026 23:36:56 +0200 Subject: [PATCH] test: prove RESTIC_JOB_ARGS reaches restic backup The suite recorded RESTIC_JOB_ARGS only indirectly through backup-last.log, which proves nothing about restic ever seeing the arguments. Removing ${RESTIC_JOB_ARGS} from the restic backup call in backup.sh left compat at 32 passed, 0 failed - exactly the failure class this PR is supposed to catch, and exactly blocker 1 of PR #109. compat.sh gets a section that runs a backup with RESTIC_JOB_ARGS=--exclude=/data/skipme.txt and requires the excluded file to be absent from the restore while the other file is restored intact, so the arguments must have a visible effect. features.sh gets the matching assertion inside the existing `stream` feature gate (RESTIC_JOB_ARGS=--host=jobargshost must show up in the snapshot metadata of a stdin backup). It is reported as SKIP until PR #109 is rebased, which is the point of the gate. Verification on Git-Bash: bash test/run.sh -> structure 13/13, compat 39 passed 0 failed, features 4 SKIP, exit 0 sabotage (backup.sh:40 ${RESTIC_JOB_ARGS} removed), rebuilt image IMAGE=rbd-sab-jobargs bash test/compat.sh -> FAIL RESTIC_JOB_ARGS is passed to restic backup "the excluded file was backed up anyway" -> 38 passed, 1 failed, exit 1 backup.sh was restored with git checkout and the sabotage image removed. Co-Authored-By: Claude Opus 5 (1M context) Agent-Id: agent-4966d0e6-7f4d-4b37-be3d-0648ed56cb8a --- test/compat.sh | 24 ++++++++++++++++++++++++ test/features.sh | 18 ++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/test/compat.sh b/test/compat.sh index e261caa..d57d6ea 100644 --- a/test/compat.sh +++ b/test/compat.sh @@ -133,6 +133,30 @@ assert_eq "1" "$(snapshot_count)" \ "--keep-last 1 leaves exactly one snapshot" stop_container +echo +echo "=== compat: RESTIC_JOB_ARGS ===" +# backup-last.log only records the variable, it does not prove restic ever saw +# it. The arguments have to have a visible effect, otherwise a backup that +# silently drops RESTIC_JOB_ARGS still looks healthy. + +start_container jobargs -e "RESTIC_JOB_ARGS=--exclude=/data/skipme.txt" +wait_for_start || { fail "container starts with RESTIC_JOB_ARGS"; summary "compat"; exit 1; } +write_file /data/keep.txt "keep" +write_file /data/skipme.txt "skip" +jobargs_log="$(in_container /bin/backup 2>&1)" +assert_contains "$jobargs_log" "Backup Successful" \ + "backup with RESTIC_JOB_ARGS succeeds" +in_container restic restore latest --target /tmp/restore >/dev/null 2>&1 +assert_eq "keep" "$(in_container cat /tmp/restore/data/keep.txt 2>&1)" \ + "RESTIC_JOB_ARGS does not break a normal backup" +if in_container test -f /tmp/restore/data/skipme.txt; then + fail "RESTIC_JOB_ARGS is passed to restic backup" \ + "the excluded file was backed up anyway" +else + pass "RESTIC_JOB_ARGS is passed to restic backup" +fi +stop_container + echo echo "=== compat: BACKUP_SOURCES ===" diff --git a/test/features.sh b/test/features.sh index 7a98232..ca38d6f 100644 --- a/test/features.sh +++ b/test/features.sh @@ -40,6 +40,24 @@ if require_feature stream "PR #109"; then fi stop_container + # Blocker 1 of PR #109: the stream branch must honour RESTIC_JOB_ARGS, the + # same way the file backup does. --host is used because it is visible in + # the snapshot metadata of a stdin backup. + start_container stream-jobargs \ + -e RESTIC_STREAM=1 \ + -e "RESTIC_STREAM_CMD=echo hello-stream" \ + -e RESTIC_STREAM_FILENAME=stream.txt \ + -e "RESTIC_JOB_ARGS=--host=jobargshost" + if wait_for_start; then + in_container /bin/backup >/dev/null 2>&1 + stream_snapshots="$(in_container restic snapshots --json 2>/dev/null)" + assert_contains "$stream_snapshots" '"jobargshost"' \ + "RESTIC_JOB_ARGS is passed to the stream backup" + else + fail "stream RESTIC_JOB_ARGS container starts" + fi + stop_container + # A half-configured stream must not look like a successful backup. start_container stream-misconfigured -e RESTIC_STREAM=1 if wait_for_start; then