]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
regress: Add test for #7552 about copying wrong job
authorMichal Rakowski <michal.rakowski@baculasystems.com>
Fri, 23 Apr 2021 12:41:36 +0000 (14:41 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:01 +0000 (09:03 +0100)
regress/tests/copy-twin-test [new file with mode: 0755]

diff --git a/regress/tests/copy-twin-test b/regress/tests/copy-twin-test
new file mode 100755 (executable)
index 0000000..259845d
--- /dev/null
@@ -0,0 +1,72 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2021 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Tests for #7552
+#
+# Run backup job, change its type to copy, reload configuration and run same job once more.
+# Second job should not be started at all.
+#
+TestName="copy-twin-test"
+JobName=copy-twin-test
+. scripts/functions
+
+
+scripts/cleanup
+scripts/copy-migration-confs
+echo "${cwd}/build" >${cwd}/tmp/file-list
+
+sed 's/migrate/copy/g' ${cwd}/bin/bacula-dir.conf > ${cwd}/tmp/1
+sed 's/Migrate/Copy/g' ${cwd}/tmp/1 > ${cwd}/bin/bacula-dir.conf
+rm -f ${cwd}/build/po/test.po >/dev/null
+
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "Type", "Backup", "Job", "copy-uncopied")'
+
+start_test
+
+# Run job with type=backup
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@output /dev/null
+messages
+@$out ${cwd}/tmp/log1.out
+label storage=File volume=FileVolume001 Pool=Default
+wait
+messages
+run job=copy-uncopied yes
+wait
+messages
+quit
+END_OF_DATA
+
+run_bacula
+
+# Change job's type to copy, reload configuration and run job once more
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "Type", "Copy", "Job", "copy-uncopied")'
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+reload
+@$out ${cwd}/tmp/log2.out
+run job=copy-uncopied yes
+wait
+messages
+quit
+END_OF_DATA
+
+run_bconsole
+
+n_msg=`cat ${cwd}/tmp/log2.out | grep "Unexpected type ('c') of job to copy:" | wc -l`
+n_err=`cat ${cwd}/tmp/log2.out | grep 'Copying Error' | wc -l`
+
+if [ ${n_msg} -ne 1 ]; then
+   estat=1
+   print_debug "Wrong count of error message regarding already existing job: ${n_msg}, expected 1"
+fi
+
+if [ ${n_msg} -ne 1 ]; then
+   estat=1
+   print_debug "Wrong count of 'Copying Error' message: ${n_err}, expected 1"
+fi
+
+stop_bacula
+end_test