]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
regress: add test for bug #7739 about deleting running job
authorMichal Rakowski <michal.rakowski@baculasystems.com>
Fri, 4 Jun 2021 11:49:14 +0000 (13:49 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:02 +0000 (09:03 +0100)
regress/tests/delete-running-job-test [new file with mode: 0755]

diff --git a/regress/tests/delete-running-job-test b/regress/tests/delete-running-job-test
new file mode 100755 (executable)
index 0000000..619a652
--- /dev/null
@@ -0,0 +1,67 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2021 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Test for #7739
+# Check if bacula denies to delete job which is actually running
+#
+TestName="delete-running-job-test"
+JobName=backup
+. scripts/functions
+
+scripts/cleanup
+scripts/copy-confs
+
+#
+# Zap out any schedule in default conf file so that
+#  it doesn't start during our test
+#
+outf="$tmp/sed_tmp"
+echo "s%  Schedule =%# Schedule =%g" >${outf}
+cp $scripts/bacula-dir.conf $tmp/1
+sed -f ${outf} $tmp/1 >$scripts/bacula-dir.conf
+
+change_jobname BackupClient1 $JobName
+start_test
+
+cat <<END_OF_DATA >$tmp/bconcmds
+@output /dev/null
+messages
+@$out $tmp/log1.out
+label volume=TestVolume001 storage=File1 pool=File slot=1 drive=0
+run job=$JobName yes
+run job=$JobName yes
+@sleep 1
+@$out $tmp/log2.out
+delete jobid=1,2
+@$out $tmp/log3.out
+wait
+messages
+quit
+END_OF_DATA
+
+run_bacula
+
+n_job1=`cat ${cwd}/tmp/log2.out | grep "Skipping JobId=1, job is still running!" | wc -l`
+if [ $n_job1 -ne 1 ]; then
+   estat=1
+   print_debug "JobId=1 should be skipped when deleting records!"
+fi
+
+n_job2=`cat ${cwd}/tmp/log2.out | grep "Skipping JobId=2, job is still running!" | wc -l`
+if [ $n_job2 -ne 1 ]; then
+   estat=1
+   print_debug "JobId=2 should be skipped when deleting records!"
+fi
+
+
+n_bakup_ok=`cat ${cwd}/tmp/log3.out | grep "Termination: " | tr -s ' ' | grep "Backup OK" | wc -l`
+if [ $n_bakup_ok -ne 2 ]; then
+   estat=1
+   print_debug "Backup of some jobs failed! See ${cwd}/tmp/log2.out for more info!"
+fi
+
+stop_bacula
+
+end_test