From 9b4df22b9c0b41cf32d95a6e0c23f52c8129d175 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Thu, 24 Feb 2011 18:45:13 +0100 Subject: [PATCH] regress: Add test with for find_next_volume and StorageId --- regress/tests/storageid-test-changer | 162 +++++++++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100755 regress/tests/storageid-test-changer diff --git a/regress/tests/storageid-test-changer b/regress/tests/storageid-test-changer new file mode 100755 index 0000000000..bcb1ebf2d8 --- /dev/null +++ b/regress/tests/storageid-test-changer @@ -0,0 +1,162 @@ +#!/bin/sh +# +# Run backups with dummy tape driver +# This test setups an Autochanger with 80 slots +# and 5 drives (3 LTO3 and 2 LTO1) +# +# TAPE_DRIVE="$cwd/working/ach/drive0" +# TAPE_DRIVE1="$cwd/working/ach/drive0" +# AUTOCHANGER="$cwd/working/ach/conf" +# USE_VTAPE=yes +# AUTOCHANGER_SCRIPT=disk-changer +# + +TestName="storageid-test-changer" +JobName=backup +. scripts/functions + +require_vtape + +scripts/cleanup +scripts/copy-tape-confs +cp $rscripts/bacula-dir-vtape.conf $conf/bacula-dir.conf +cp $rscripts/bacula-sd-vtape.conf $conf/bacula-sd.conf +scripts/prepare-fake-autochanger + +echo "${cwd}/build" >${cwd}/tmp/file-list + +start_test + +when1=`perl -MPOSIX -e "print strftime('%F %T', localtime(time+30))"` +when2=`perl -MPOSIX -e "print strftime('%F %T', localtime(time+45))"` + +clientname=`awk '/Name = .*-fd/ { if (!ok) { print $3 ; ok=1 } }' bin/bacula-dir.conf` + +# Catalog record for cleaning tape "CLN01" successfully created. +# CLN01 | Cleaning + +# Write out bconsole commands +cat <${cwd}/tmp/bconcmds +@$out /dev/null +messages +@$out ${cwd}/tmp/log6.out +@#setdebug level=200 storage=LTO1 +label barcodes pool=Scratch slots=1-4 storage=LTO1-ANSI_6 drive=6 +yes +label barcodes pool=Scratch slots=15-25 storage=LTO1 drive=3 +yes +messages +list volumes +END_OF_DATA + +run_bacula + +cat <${cwd}/tmp/bconcmds +@$out ${cwd}/tmp/log7.out +label barcodes pool=Scratch slots=41-50 storage=LTO3 drive=0 +yes +sql +SELECT Storage.Name, VolumeName, Slot, InChanger, Pool.Name + FROM Media JOIN Storage USING (StorageId) JOIN Pool USING (PoolId); + +messages +list volumes +@$out ${cwd}/tmp/log1.out +run storage=LTO3_0 job=NightlySave pool=Inc yes +wait +messages +run storage=LTO3_0 job=NightlySave2 pool=Full yes +wait +messages +@$out ${cwd}/tmp/log4.out +setdebug level=51 trace=1 dir +@exec "touch $cwd/build/po/fr.po" +run storage=LTO3_1 job=NightlySave pool=Inc yes +wait +setdebug level=0 trace=0 dir +messages +@$out ${cwd}/tmp/log1.out +run storage=LTO1_4 job=NightlySave pool=Inc yes +wait +messages +sql +SELECT Storage.Name, MediaType, VolumeName, Slot, InChanger, Pool.Name + FROM Media JOIN Storage USING (StorageId) JOIN Pool USING (PoolId); + +@$out ${cwd}/tmp/log2.out +restore storage=LTO3_1 client=$clientname +3 +1,2,3 +m * +done +yes +wait +messages +quit +END_OF_DATA + +run_bconsole +check_for_zombie_jobs storage=LTO1 client=$clientname + +grep 'Volume ".*" previously written, moving' $cwd/tmp/log4.out > /dev/null +if [ $? -ne 0 ]; then + print_debug "ERROR: Job 3 should re-use a volume" + estat=1 +fi + +grep "Call prune_volumes" $working/*trace > /dev/null +if [ $? -eq 0 ]; then + print_debug "ERROR: Job 3 should re-use a volume, not try to prune one" + estat=1 +fi + +grep "after get scratch volume ok=" $working/*trace > /dev/null +if [ $? -eq 0 ]; then + print_debug "ERROR: Job 3 should re-use a volume, not try to get a scratch one" + estat=1 +fi + +# remove volume vol20 from autochanger +grep -v vol20 ${cwd}/working/ach/barcodes > ${cwd}/tmp/1 +cp ${cwd}/tmp/1 ${cwd}/working/ach/barcodes + +cat <${cwd}/tmp/bconcmds +@$out ${cwd}/tmp/log3.out +list volume=vol20 +update slots slots=5-40 storage=LTO1 drive=3 +list volume=vol20 +sql +SELECT Storage.Name, VolumeName, Slot, InChanger, Pool.Name + FROM Media JOIN Storage USING (StorageId) JOIN Pool USING (PoolId); + +END_OF_DATA + +run_bconsole + +stop_bacula + +touch ${cwd}/tmp/log2.out +check_two_logs +check_restore_diff + +# get InChanger flag +RES=`awk -F'|' '/vol20.+Append/ { print $11 }' ${cwd}/tmp/log3.out` +set "$RES" +if [ "$1" = "$2" ]; then + echo "Error in update slots" + bstat=1 +fi + +grep LTO1_5 tmp/log1.out > /dev/null +if test $? = 0; then + echo "AutoSelect option broken" + bstat=1 +fi + +grep 'Error: Re-read' tmp/log1.out > /dev/null +if test $? = 0; then + echo "Found Re-read errors" + bstat=1 +fi + +end_test -- 2.39.5