]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
regress: Add test delete-volume-test
authorEric Bollengier <eric@baculasystems.com>
Mon, 2 Feb 2026 07:52:53 +0000 (08:52 +0100)
committerEric Bollengier <eric@baculasystems.com>
Mon, 2 Feb 2026 07:59:43 +0000 (08:59 +0100)
regress/tests/delete-volume-test [new file with mode: 0755]

diff --git a/regress/tests/delete-volume-test b/regress/tests/delete-volume-test
new file mode 100755 (executable)
index 0000000..8bc4f7e
--- /dev/null
@@ -0,0 +1,71 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2021 Kern Sibbald
+# Copyright (C) 2021-2025 Bacula Systems SA
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# This script will test volume deletion
+#
+. scripts/functions
+
+TestName="delete-volume-test"
+JobName=NightlySave
+
+scripts/cleanup
+scripts/copy-test-confs
+
+start_test
+
+echo $PWD/build/po > tmp/file-list
+
+$bperl -e "add_attribute('$conf/bacula-dir.conf', 'MaximumVolumeJobs', '10', 'Pool')"
+$bperl -e "add_attribute('$conf/bacula-dir.conf', 'LabelFormat', 'Vol', 'Pool')"
+$bperl -e "add_attribute('$conf/bacula-dir.conf', 'SpoolData', 'no', 'Job')"
+$bperl -e "add_attribute('$conf/bacula-dir.conf', 'Autoprune', 'no', 'Director')"
+
+cat <<EOF >> $conf/bacula-dir.conf
+Pool {
+ Name = Test1
+ Pool Type = Backup
+ LabelFormat = Vol
+ VolumeRetention = 1d
+ MaximumVolumeJobs = 10
+ MaximumVolumeBytes = 1MB
+}
+EOF
+
+cat <<EOF > ${cwd}/tmp/bconcmds
+@output /dev/null
+messages
+@$out $tmp/log1.out
+run job=$JobName level=full pool=Test1 yes
+wait
+messages
+@output $tmp/1.out
+.jlist pool=Test1
+@output $tmp/2.out
+.jlist volumes pool=Test1
+@$out $tmp/log1.out
+delete volume=Vol0001 yes
+@output $tmp/3.out
+.jlist pool=Test1
+quit
+EOF
+
+run_bacula
+stop_bacula
+
+grep '{' $tmp/1.out | perl -MJSON -e '$obj = decode_json(<>); exit $obj->{data}->[0]->{numvols};'
+nb1=$?
+
+grep '{' $tmp/3.out | perl -MJSON -e '$obj = decode_json(<>); exit $obj->{data}->[0]->{numvols};'
+nb2=$?
+
+nb3=`expr $nb2 + 1`
+
+if [ $nb3 != $nb1 ]; then
+    print_debug "ERROR: Should find one volume less in $tmp/3.out (nb1=$nb1 nb2=$nb2)"
+    estat=1
+fi
+
+end_test