From: Eric Bollengier Date: Wed, 2 Sep 2020 13:38:38 +0000 (+0200) Subject: BEE Backport regress/tests/vtape-maxconjob1-test X-Git-Tag: Release-11.3.2~1129 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ca2829e61fbb9795f7fe138831bb97543abec1d5;p=thirdparty%2Fbacula.git BEE Backport regress/tests/vtape-maxconjob1-test This commit is the result of the squash of the following main commits: Author: Eric Bollengier Date: Tue Jul 21 10:28:13 2020 +0200 regress: Add copyright to regress scripts Author: Kern Sibbald Date: Tue Oct 23 18:52:29 2012 +0200 Drop previous regression test output Author: Eric Bollengier Date: Thu Jun 21 14:28:21 2012 +0200 regress: use $HOST in vtape-maxconjob1-test Author: Eric Bollengier Date: Thu Jun 21 11:19:58 2012 +0200 regress: Add a copy job in vtape-maxconjob1-test Author: Eric Bollengier Date: Mon Jun 18 19:50:43 2012 +0200 regress: Add test with vtape and maximum concurrent jobs = 1 --- diff --git a/regress/tests/vtape-maxconjob1-test b/regress/tests/vtape-maxconjob1-test new file mode 100755 index 0000000000..3199f19b6d --- /dev/null +++ b/regress/tests/vtape-maxconjob1-test @@ -0,0 +1,159 @@ +#!/bin/sh +# +# Copyright (C) 2000-2020 Kern Sibbald +# License: BSD 2-Clause; see file LICENSE-FOSS +# +# Run backups with dummy tape driver +# This test setups an Autochanger with 80 slots +# and 5 drives (5 LTO3) +# +# + +TestName="vtape-maxconjob1-test" +JobName=backup +. scripts/functions + +require_vtape + +scripts/cleanup +scripts/copy-tape-confs +cp $rscripts/bacula-dir-vtape.conf $conf/bacula-dir.conf +sed 's/LTO1/LTO3/g' $rscripts/bacula-sd-vtape.conf > $conf/bacula-sd.conf +scripts/prepare-fake-autochanger + +echo "${cwd}/build" >${cwd}/tmp/file-list + +$bperl -e 'add_attribute("$conf/bacula-sd.conf", "Maximum Concurrent Jobs", "1", "Device")' +$bperl -e 'add_attribute("$conf/bacula-sd.conf", "Maximum Volume Size", "100MB", "Device")' +$bperl -e 'add_attribute("$conf/bacula-sd.conf", "LabelMedia", "Yes", "Device", "FileStorage")' + +$bperl -e 'add_attribute("$conf/bacula-fd.conf", "MaximumBandwidthPerJob", "1200Kb/s", "FileDaemon")' + +$bperl -e 'add_attribute("$conf/bacula-dir.conf", "Label Format", "TestVolume", "Pool", "Full")' +$bperl -e 'add_attribute("$conf/bacula-dir.conf", "Maximum Volume Jobs", "1", "Pool")' +$bperl -e 'add_attribute("$conf/bacula-dir.conf", "SpoolData", "no", "Job")' +$bperl -e 'add_attribute("$conf/bacula-dir.conf", "NextPool", "Full", "Pool", "Inc")' +$bperl -e 'add_attribute("$conf/bacula-dir.conf", "Storage", "File", "Pool", "Full")' + +cat <> $conf/bacula-dir.conf +Job { + Name = "copy-job" + Type = Copy + Level = Full + Client=${HOST}-fd + FileSet="Full Set" + Messages = Standard + Storage = LTO3 + Write Bootstrap = "$working/migratejob.bsr" + Pool = Default + Maximum Concurrent Jobs = 4 + Selection Type = Job + Selection Pattern = ".*Save.*" +# Allow Duplicate Jobs = No +} +EOF + +perl -Mscripts::functions -e "extract_resource('$conf/bacula-dir.conf', 'Job', 'NightlySave')" > $tmp/1 +cat $tmp/1 | sed s/NightlySave/NightlySave4/ >> $conf/bacula-dir.conf +cat $tmp/1 | sed s/NightlySave/NightlySave5/ >> $conf/bacula-dir.conf +cat $tmp/1 | sed s/NightlySave/NightlySave6/ >> $conf/bacula-dir.conf +cat $tmp/1 | sed s/NightlySave/NightlySave7/ >> $conf/bacula-dir.conf +cat $tmp/1 | sed s/NightlySave/NightlySave8/ >> $conf/bacula-dir.conf +cat $tmp/1 | sed s/NightlySave/NightlySave9/ >> $conf/bacula-dir.conf +cat $tmp/1 | sed s/NightlySave/NightlySave10/ >> $conf/bacula-dir.conf + +start_test + +clientname=`awk '/Name = .*-fd/ { if (!ok) { print $3 ; ok=1 } }' bin/bacula-dir.conf` + +when1=`perl -MPOSIX -e "print strftime('%F %T', localtime(time+20))"` +when2=`perl -MPOSIX -e "print strftime('%F %T', localtime(time+35))"` +when3=`perl -MPOSIX -e "print strftime('%F %T', localtime(time+50))"` + +# Catalog record for cleaning tape "CLN01" successfully created. +# CLN01 | Cleaning + +# Write out bconsole commands +cat <${cwd}/tmp/bconcmds +@output /dev/null +messages +@$out ${cwd}/tmp/log6.out +@#setdebug level=200 storage=LTO1 +label barcodes pool=Scratch slots=1-60 storage=LTO3 drive=0 +yes +messages +list volumes +END_OF_DATA + +run_bacula + +cat <${cwd}/tmp/bconcmds +@$out ${cwd}/tmp/log1.out +setdebug trace=1 level=200 storage=LTO3 +mount storage=LTO3_2 slot=60 drive=2 +run storage=LTO3 when="$when1" job=NightlySave pool=Inc yes +run storage=LTO3 when="$when2" job=NightlySave2 pool=Inc yes +run storage=LTO3 when="$when3" job=NightlySave3 pool=Inc yes +wait jobid=1 +status storage=LTO3 +messages +run storage=LTO3_2 job=copy-job jobid=1 pool=Inc yes +wait jobid=2 +messages +run storage=LTO3_2 job=copy-job jobid=2 pool=Inc yes +wait jobid=3 +messages +run storage=LTO3_2 job=copy-job jobid=3 pool=Inc yes +wait +messages +quit +END_OF_DATA + +run_bconsole +check_for_zombie_jobs storage=LTO3 client=$clientname + +cat <${cwd}/tmp/bconcmds +setdebug trace=1 level=0 storage=LTO3 +@$out ${cwd}/tmp/log2.out +@# +@# now do a restore +@# +restore client=$clientname fileset="Full Set" where=${cwd}/tmp/bacula-restores select all done +yes +wait +messages +END_OF_DATA + +run_bconsole +check_for_zombie_jobs storage=LTO3 client=$clientname + +stop_bacula + +check_two_logs +check_restore_diff +perl -ne ' +# foreach Job, we store the drive and we count the total +# job number per drive +m/(\d+): Using Device "(.+?)"/ + and $drive_info[$i++]="$1 $2" and $drive{$2}++; + +END { + $err=0; + foreach $k (sort keys %drive) { + if ($drive{$k} > 3) { + print "ERR $k has more than 3 jobs ($drive{$k})\n"; + $err++; + } + } + if ($err) { + foreach $k (@drive_info) { print "$k\n"} + exit 1; + } +} +' $tmp/log1.out + +if [ $? -ne 0 ]; then + print_debug "ERR: Problem during log analysis" + estat=1 +fi +end_test