From: Eric Bollengier Date: Thu, 4 Feb 2010 14:05:21 +0000 (+0100) Subject: regress: backport action-on-purge test X-Git-Tag: Release-5.0.1~131 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9280d70d771c4dd56a6d6ce669854fa0e6c2fea7;p=bacula%2Fbacula regress: backport action-on-purge test --- diff --git a/regress/scripts/functions.pm b/regress/scripts/functions.pm index 0b6da0b07e..2208ee32a3 100644 --- a/regress/scripts/functions.pm +++ b/regress/scripts/functions.pm @@ -38,16 +38,23 @@ package scripts::functions; use Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(update_some_files create_many_files check_multiple_copies - update_client $HOST $BASEPORT + update_client $HOST $BASEPORT add_to_backup_list check_volume_size + check_min_volume_size check_max_volume_size $estat $bstat $rstat $zstat $cwd $bin $scripts $conf $rscripts $tmp $working $db_name $db_user $db_password $src $tmpsrc); use File::Copy qw/copy/; -our ($cwd, $bin, $scripts, $conf, $rscripts, $tmp, $working, +our ($cwd, $bin, $scripts, $conf, $rscripts, $tmp, $working, $estat, $bstat, $zstat, $rstat, $db_name, $db_user, $db_password, $src, $tmpsrc, $HOST, $BASEPORT); +END { + if ($estat || $rstat || $zstat || $bstat) { + exit 1; + } +} + BEGIN { # start by loading the ./config file my ($envar, $enval); @@ -80,6 +87,55 @@ BEGIN { $ENV{rscripts} = $rscripts = $ENV{rscripts} || "$cwd/scripts"; $ENV{HOST} = $HOST = $ENV{HOST} || "localhost"; $ENV{BASEPORT} = $BASEPORT = $ENV{BASEPORT} || "8101"; + + $estat = $rstat = $bstat = $zstat = 0; +} + +sub check_min_volume_size +{ + my ($size, @vol) = @_; + my $ret=0; + + foreach my $v (@vol) { + if (! -f "$tmp/$v") { + print "ERR: $tmp/$v not accessible\n"; + $ret++; + next; + } + if (-s "$tmp/$v" < $size) { + print "ERR: $tmp/$v too small\n"; + $ret++; + } + } + $estat+=$ret; + return $ret; +} + +sub check_max_volume_size +{ + my ($size, @vol) = @_; + my $ret=0; + + foreach my $v (@vol) { + if (! -f "$tmp/$v") { + print "ERR: $tmp/$v not accessible\n"; + $ret++; + next; + } + if (-s "$tmp/$v" > $size) { + print "ERR: $tmp/$v too big\n"; + $ret++; + } + } + $estat+=$ret; + return $ret; +} + +sub add_to_backup_list +{ + open(FP, ">>$tmp/file-list") or die "Can't open $tmp/file-list for update $!"; + print FP join("\n", @_); + close(FP); } # update client definition for the current test diff --git a/regress/tests/action-on-purge-test b/regress/tests/action-on-purge-test index ee95c60a59..5c4422f1f7 100755 --- a/regress/tests/action-on-purge-test +++ b/regress/tests/action-on-purge-test @@ -2,7 +2,7 @@ # # TestName="action-on-purge-test" -JobName=AOP +JobName=FIFOTest . scripts/functions cwd=`pwd` @@ -10,10 +10,10 @@ scripts/cleanup scripts/copy-test-confs echo $src > $tmp/file-list + sed 's/Pool Type = Backup/Pool Type = Backup; ActionOnPurge = Truncate/' $conf/bacula-dir.conf > $tmp/1 cp $tmp/1 $conf/bacula-dir.conf -change_jobname CompressedTest $JobName start_test cat >tmp/bconcmds <tmp/bconcmds < $tmp/bconcmds +run_bconsole + +perl -Mscripts::functions -e ' +check_min_volume_size(4096, "TestVolume002","TestVolume003","TestVolume004","TestVolume005"); +check_max_volume_size(4096, "TestVolume001")' + +if [ $? != 0 ]; then + print_debug `ls -l $tmp` + ls -l $tmp + estat=2 +fi + +echo "purge volume action storage=File" > $tmp/bconcmds +run_bconsole + +perl -Mscripts::functions -e ' +check_min_volume_size(4096, "TestVolume002", "TestVolume005"); +check_max_volume_size(4096, "TestVolume001", "TestVolume003", "TestVolume004")' + +if [ $? != 0 ]; then + print_debug `ls -l $tmp` + ls -l $tmp + estat=2 +fi + + +cat < $tmp/bconcmds @######################################################### @# Display catalog settings for Pool and Media @######################################################### @$out $tmp/log4.out +setdebug level=0 director sql select VolumeName, ActionOnPurge FROM Media; select Name, ActionOnPurge FROM Pool; +wait quit END_OF_DATA -run_bacula -check_for_zombie_jobs storage=File +run_bconsole + stop_bacula +touch $tmp/log2.out check_two_logs -check_restore_diff - -perl -e "die 'Volume size too big' if (-s '$tmp/TestVolume001' > 4096)" -if [ $? != 0 ]; then - print_debug `ls -l $tmp/TestVolume001` - bstat=2 -fi - -perl -e "die 'Volume size too small' if (-s '$tmp/TestVolume002' < 4096)" -if [ $? != 0 ]; then - print_debug `ls -l $tmp/TestVolume002` - bstat=2 -fi print_debug "Test if Pool record is ok" r=`awk '/Default/ { print $4 }' $tmp/log4.out` if [ "$r" != 1 ]; then - print_debug "ActionOnPurge on Pool record should be 1" - bstat=2 + print_debug "ActionOnPurge on Pool record should be 1 ($r)" + estat=2 fi print_debug "Test TestVolume001 if Media record is ok" r=`awk '/TestVolume001/ { print $4 }' $tmp/log4.out` if [ "$r" != 1 ]; then print_debug "ActionOnPurge on Media record should be 1" - bstat=2 + estat=2 fi print_debug "Test TestVolume002 if Media record is ok" r=`awk '/TestVolume002/ { print $4 }' $tmp/log4.out` if [ "$r" != 0 ]; then print_debug "ActionOnPurge on Media record should be 0" - bstat=2 + estat=2 fi end_test