]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
BEE Backport regress/tests/virtual-changer-restore-test
authorEric Bollengier <eric@baculasystems.com>
Wed, 2 Sep 2020 13:36:53 +0000 (15:36 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:02:56 +0000 (09:02 +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: Kern Sibbald <kern@sibbald.com>
Date:   Fri Jul 29 11:09:22 2016 +0200

    regress: replace old using of disk-changer with Bacula virtual autochanger

Author: Kern Sibbald <kern@sibbald.com>
Date:   Mon Sep 2 16:59:21 2013 +0200

    Fix virtual-changer-restore-test bug with multiple MediaTypes

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Fri Aug 30 17:18:20 2013 +0200

    regress: Add script to show problems with Virtual Autochanger

regress/tests/virtual-changer-restore-test [new file with mode: 0755]

diff --git a/regress/tests/virtual-changer-restore-test b/regress/tests/virtual-changer-restore-test
new file mode 100755 (executable)
index 0000000..7cb9d84
--- /dev/null
@@ -0,0 +1,108 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# See how the Bacula Storage Daemon will choose a free Device
+# when doing a restore.
+#
+TestName="virtual-changer-restore-test"
+JobName="virtualchangertest"
+. scripts/functions
+
+scripts/cleanup
+scripts/copy-2disk-drive-confs
+##scripts/prepare-disk-changer
+
+CLIENT=2drive2disk
+
+echo "${cwd}/build" >${cwd}/tmp/file-list
+#change_jobname Virtual $JobName
+start_test
+
+# Turn off Prefer Mounted Volumes so we use 2 drives
+outf="${cwd}/tmp/sed_tmp"
+echo "s%# Prefer Mounted Volumes%  Prefer Mounted Volumes%g" >${outf}
+cp ${cwd}/bin/bacula-dir.conf ${cwd}/tmp/1
+# Comment the next line out to write everything to one drive
+#  otherwise, it writes the two jobs to different drives
+sed -f ${outf} ${cwd}/tmp/1 >${cwd}/bin/bacula-dir.conf
+
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "MaximumConcurrentJobs", "10", "Job")'
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "MaximumConcurrentJobs", "10", "Client")'
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "MaximumConcurrentJobs", "10", "Storage")'
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "MaximumConcurrentJobs", "10", "Autochanger")'
+
+# Write out bconsole commands
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@output /dev/null
+messages
+@$out ${cwd}/tmp/log1.out
+@#setdebug level=50 storage=Virtual
+@#setdebug level=200 client=$CLIENT 
+label storage=Virtual volume=TestVolume001 slot=0 Pool=Default drive=0
+label storage=Virtual2 volume=TestVolume002 slot=0 Pool=Default drive=0
+run job=Virtual level=Full storage=Virtual  Pool=Default yes
+run job=Virtual level=Full storage=Virtual2 Pool=Default yes
+wait
+@#
+@# The following jobs should block waiting for a mount
+@# This is done on purpose to block the restores from using certain drives 
+run job=Virtual level=Full Pool=Inc   storage=Virtual yes
+run job=Virtual level=Full Pool=Full  storage=Virtual yes
+run job=Virtual level=Full Pool=Inc   storage=Virtual2 yes
+run job=Virtual level=Full Pool=Full  storage=Virtual2 yes
+@sleep 2
+messages
+quit
+END_OF_DATA
+
+# exit
+
+run_bacula
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@output /dev/null
+messages
+@# 
+@# now do a restore
+@#
+@$out ${cwd}/tmp/log2.out
+@#setdebug level=150 storage=VirtualRestore
+@# restore jobid=1
+restore where=${cwd}/tmp/bacula-restores storage=VirtualRestore
+3
+1
+mark *
+done
+yes
+@sleep 5
+status dir
+wait jobid=7
+messages
+@# now restore jobid=2
+restore where=${cwd}/tmp/bacula-restores storage=VirtualRestore
+3
+2
+mark *
+done
+yes
+@sleep 5
+status dir
+wait jobid=8
+messages
+@out /dev/null
+@# terminate jobs
+cancel all yes
+wait
+messages
+quit
+END_OF_DATA
+
+run_bconsole
+
+check_for_zombie_jobs storage=Virtual
+stop_bacula
+
+check_two_logs
+
+end_test