]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
BEE Backport regress/tests/reload-duplicate-test
authorEric Bollengier <eric@baculasystems.com>
Wed, 2 Sep 2020 13:31:57 +0000 (15:31 +0200)
committerEric Bollengier <eric@baculasystems.com>
Tue, 1 Mar 2022 14:36:18 +0000 (15:36 +0100)
This commit is the result of the squash of the following main commits:

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Tue Jul 21 10:28:13 2020 +0200

    regress: Add copyright to regress scripts

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Wed Dec 18 09:49:40 2013 +0100

    regress: Add test to reproduce bug #1863 about reload that creates duplicate jobs

regress/tests/reload-duplicate-test [new file with mode: 0755]

diff --git a/regress/tests/reload-duplicate-test b/regress/tests/reload-duplicate-test
new file mode 100755 (executable)
index 0000000..2d76c60
--- /dev/null
@@ -0,0 +1,78 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Try to reproduce #2012 about reloading the director while a backup is in
+# progress causing duplicate jobs
+#
+TestName="reload-duplicate-test"
+. scripts/functions
+
+require_linux
+scripts/cleanup
+scripts/copy-confs
+
+start_test
+
+# time in one minutes
+WHEN=`date --date="1 min" +%H:%M`
+# nb of secs to wait for the start time
+SLEEP=`date --date="$WHEN:00" +%s`
+NOW=`date +%s`
+
+SLEEP=`expr $SLEEP - $NOW + 10`
+
+print_debug "Will start job at $WHEN, will sleep $SLEEP secs"
+print_debug ""
+
+cat <<EOF >> $conf/bacula-dir.conf
+Schedule {
+  Name = Test
+  Run = Level="Full"  at $WHEN
+}
+EOF
+
+$bperl -e 'set_global_maximum_concurrent_jobs(10)'
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "Schedule", "Test", "Job", "BackupClient1")'
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "MaximumBandwidth", "700kb/s", "Job", "BackupClient1")'
+
+cat <<EOF > $tmp/bconcmds
+@out /dev/null
+message
+EOF
+
+run_bacula
+
+# Do something to reload slowly
+echo '@|"sleep 5"' >> $conf/bacula-dir.conf
+
+sleep $SLEEP
+
+cat <<EOF > $tmp/bconcmds
+@$out $tmp/log1.out
+.status dir running
+@exec date
+@exec "killall -HUP bacula-dir"
+@#reload
+message
+@sleep 20
+message
+.status dir running
+wait
+@$out $tmp/log2.out
+llist jobs
+EOF
+
+run_bconsole
+
+stop_bacula
+
+nb=`grep -i ' jobid:' $tmp/log2.out | wc -l`
+
+if [ "$nb" -ne 1 ]; then
+    print_debug "ERROR: found $nb jobs in the job list instead of 1"
+    estat=1
+fi
+
+end_test