3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
6 # Run backups with dummy tape driver
7 # This test setups an Autochanger with 80 slots
8 # and 5 drives (5 LTO3)
12 TestName="copy-swap-fail-test"
19 scripts/copy-tape-confs
20 cp $rscripts/bacula-dir-vtape.conf $conf/bacula-dir.conf
21 sed 's/LTO1/LTO3/g' $rscripts/bacula-sd-vtape.conf > $conf/bacula-sd.conf
22 scripts/prepare-fake-autochanger
24 echo "${cwd}/build" >${cwd}/tmp/file-list
26 $bperl -e 'add_attribute("$conf/bacula-sd.conf", "Maximum Concurrent Jobs", "1", "Device")'
27 $bperl -e 'add_attribute("$conf/bacula-sd.conf", "Maximum Volume Size", "100MB", "Device")'
28 $bperl -e 'add_attribute("$conf/bacula-sd.conf", "LabelMedia", "Yes", "Device", "FileStorage")'
30 $bperl -e 'add_attribute("$conf/bacula-fd.conf", "MaximumBandwidthPerJob", "1200Kb/s", "FileDaemon")'
32 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "Label Format", "TestVolume", "Pool", "Full")'
33 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "Maximum Volume Jobs", "1", "Pool")'
34 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "SpoolData", "no", "Job")'
35 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "NextPool", "Full", "Pool", "Inc")'
36 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "Storage", "File", "Pool", "Full")'
38 cat <<EOF >> $conf/bacula-dir.conf
47 Write Bootstrap = "$working/migratejob.bsr"
49 Maximum Concurrent Jobs = 4
51 Selection Pattern = ".*Save.*"
52 # Allow Duplicate Jobs = No
56 perl -Mscripts::functions -e "extract_resource('$conf/bacula-dir.conf', 'Job', 'NightlySave')" > $tmp/1
57 cat $tmp/1 | sed s/NightlySave/NightlySave4/ >> $conf/bacula-dir.conf
58 cat $tmp/1 | sed s/NightlySave/NightlySave5/ >> $conf/bacula-dir.conf
59 cat $tmp/1 | sed s/NightlySave/NightlySave6/ >> $conf/bacula-dir.conf
60 cat $tmp/1 | sed s/NightlySave/NightlySave7/ >> $conf/bacula-dir.conf
61 cat $tmp/1 | sed s/NightlySave/NightlySave8/ >> $conf/bacula-dir.conf
62 cat $tmp/1 | sed s/NightlySave/NightlySave9/ >> $conf/bacula-dir.conf
63 cat $tmp/1 | sed s/NightlySave/NightlySave10/ >> $conf/bacula-dir.conf
67 clientname=`awk '/Name = .*-fd/ { if (!ok) { print $3 ; ok=1 } }' bin/bacula-dir.conf`
69 when1=`perl -MPOSIX -e "print strftime('%F %T', localtime(time+20))"`
70 when2=`perl -MPOSIX -e "print strftime('%F %T', localtime(time+35))"`
71 when3=`perl -MPOSIX -e "print strftime('%F %T', localtime(time+50))"`
73 # Catalog record for cleaning tape "CLN01" successfully created.
76 # Write out bconsole commands
77 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
80 @$out ${cwd}/tmp/log6.out
81 @#setdebug level=200 storage=LTO1
82 label barcodes pool=Scratch slots=1-10 storage=LTO3 drive=0
90 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
91 @$out ${cwd}/tmp/log1.out
92 setdebug trace=1 level=200 storage=LTO3
93 mount storage=LTO3_2 slot=60 drive=2
94 run storage=LTO3 when="$when1" job=NightlySave pool=Inc yes
95 run storage=LTO3 when="$when2" job=NightlySave2 pool=Inc yes
96 run storage=LTO3 when="$when3" job=NightlySave3 pool=Inc yes
100 run storage=LTO3_2 job=copy-job jobid=1 pool=Inc yes
103 run storage=LTO3_2 job=copy-job jobid=2 pool=Inc yes
106 run storage=LTO3_2 job=copy-job jobid=3 pool=Inc yes
113 check_for_zombie_jobs storage=LTO3 client=$clientname
115 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
116 setdebug trace=1 level=0 storage=LTO3
117 @$out ${cwd}/tmp/log2.out
121 restore client=$clientname fileset="Full Set" where=${cwd}/tmp/bacula-restores select all done
128 check_for_zombie_jobs storage=LTO3 client=$clientname
135 # foreach Job, we store the drive and we count the total
136 # job number per drive
137 m/(\d+): Using Device "(.+?)"/
138 and $drive_info[$i++]="$1 $2" and $drive{$2}++;
142 foreach $k (sort keys %drive) {
143 if ($drive{$k} > 3) {
144 print "ERR $k has more than 3 jobs ($drive{$k})\n";
149 foreach $k (@drive_info) { print "$k\n"}
155 if [ $? -ne 0 ]; then
156 print_debug "ERR: Problem during log analysis"