From d225d1001d2a1580f0febe7ece45b0561ed92af9 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Sun, 1 Aug 2010 22:25:49 +0200 Subject: [PATCH] regress: add comments to prune-xxx test --- regress/scripts/functions.pm | 10 +++++----- regress/tests/prune-base-job-test | 23 ++++++++++++++++++----- regress/tests/prune-copy-test | 15 ++++++++++----- regress/tests/prune-migration-test | 8 +++++++- regress/tests/prune-test | 27 +++++++++++++++++++-------- 5 files changed, 59 insertions(+), 24 deletions(-) diff --git a/regress/scripts/functions.pm b/regress/scripts/functions.pm index fd30a16ff3..5c5258fb1d 100644 --- a/regress/scripts/functions.pm +++ b/regress/scripts/functions.pm @@ -40,7 +40,7 @@ our @ISA = qw(Exporter); our @EXPORT = qw(update_some_files create_many_files check_multiple_copies update_client $HOST $BASEPORT add_to_backup_list check_volume_size create_many_dirs cleanup start_bacula stop_bacula get_resource - set_maximum_concurrent_jobs get_time add_attribute check_job_list + set_maximum_concurrent_jobs get_time add_attribute check_prune_list check_min_volume_size check_max_volume_size $estat $bstat $rstat $zstat $cwd $bin $scripts $conf $rscripts $tmp $working extract_resource $db_name $db_user $db_password $src $tmpsrc); @@ -417,11 +417,11 @@ sub add_attribute } # This test the list jobs output to check differences -# Input: read stream from stdin or with file list argument -# check if all argument are not present in the second -# list jobs output +# Input: read file argument +# check if all jobids in argument are present in the first +# 'list jobs' and not present in the second # Output: exit(1) if something goes wrong and print error -sub check_job_list +sub check_prune_list { my $f = shift; my %to_check = map { $_ => 1} @_; diff --git a/regress/tests/prune-base-job-test b/regress/tests/prune-base-job-test index 7b36499a3e..02d27dd4c4 100755 --- a/regress/tests/prune-base-job-test +++ b/regress/tests/prune-base-job-test @@ -20,6 +20,8 @@ cp tmp/1 $conf/bacula-fd.conf change_jobname BackupClient1 $JobName dircfg=$conf/bacula-dir.conf + +# modify some attributes in configuration file for the test $bperl -e "add_attribute('$dircfg', 'AutoPrune', 'No', 'Client')" $bperl -e "add_attribute('$dircfg', 'Job Retention', '1s', 'Client')" $bperl -e "add_attribute('$dircfg', 'File', '<$tmp/lst', 'FileSet', 'FS_TESTJOB_ADVANCE')" @@ -163,19 +165,30 @@ END_OF_DATA run_bconsole -$bperl -e "check_job_list('$tmp/log10.out', 3,5,6)" +# Now we will verify that the pruning code is working as expected. Each time, +# we run 'list jobs', 'prune', 'list jobs'. check_prune_list ensures that jobids +# in argument are present in the first 'list jobs', the 'prune' command deletes +# them (same number), and checks that the last 'list jobs' doesn't contain them +# anymore. See scripts/functions.pm for details. + +# B F I D I0 R I -> B F D I +$bperl -e "check_prune_list('$tmp/log10.out', 3,5,6)" estat=$(($estat + $?)) -$bperl -e "check_job_list('$tmp/log11.out', 2,4,7)" +# B F D I F -> B F +$bperl -e "check_prune_list('$tmp/log11.out', 2,4,7)" estat=$(($estat + $?)) -$bperl -e "check_job_list('$tmp/log12.out')" +# B F B -> B F B +$bperl -e "check_prune_list('$tmp/log12.out')" estat=$(($estat + $?)) -$bperl -e "check_job_list('$tmp/log13.out',1,8)" +# B F B F -> B F +$bperl -e "check_prune_list('$tmp/log13.out',1,8)" estat=$(($estat + $?)) -$bperl -e "check_job_list('$tmp/log14.out',9,10)" +# B F B B F -> B B F +$bperl -e "check_prune_list('$tmp/log14.out',9,10)" estat=$(($estat + $?)) stop_bacula diff --git a/regress/tests/prune-copy-test b/regress/tests/prune-copy-test index 93505f947f..da63f41119 100755 --- a/regress/tests/prune-copy-test +++ b/regress/tests/prune-copy-test @@ -1,11 +1,10 @@ #!/bin/sh +# Not yet working # # Run a simple backup of the Bacula build directory then copy it # to another device. -# -# This script uses the virtual disk autochanger -# -TestName="copy-job-test" +## +TestName="prune-copy-test" JobName=CopyJobSave . scripts/functions @@ -78,7 +77,13 @@ stop_bacula touch $tmp/log2.out check_two_logs -$bperl -e "check_job_list('$tmp/log3.out',1,3,4,5,6,7)" +# Now we will verify that the pruning code is working as expected. Each time, +# we run 'list jobs', 'prune', 'list jobs'. check_prune_list ensures that jobids +# in argument are present in the first 'list jobs', the 'prune' command deletes +# them (same number), and checks that the last 'list jobs' doesn't contain them +# anymore. See scripts/functions.pm for details. + +$bperl -e "check_prune_list('$tmp/log3.out',1,3,4,5,6,7)" estat=$(($estat + $?)) end_test diff --git a/regress/tests/prune-migration-test b/regress/tests/prune-migration-test index 7b200874f9..972d3621cb 100755 --- a/regress/tests/prune-migration-test +++ b/regress/tests/prune-migration-test @@ -92,7 +92,13 @@ stop_bacula check_two_logs check_restore_diff -$bperl -e "check_job_list('$tmp/log3.out',1,2,3,4,5,7)" +# Now we will verify that the pruning code is working as expected. Each time, +# we run 'list jobs', 'prune', 'list jobs'. check_prune_list ensures that jobids +# in argument are present in the first 'list jobs', the 'prune' command deletes +# them (same number), and checks that the last 'list jobs' doesn't contain them +# anymore. See scripts/functions.pm for details. + +$bperl -e "check_prune_list('$tmp/log3.out',1,2,3,4,5,7)" estat=$(($estat + $?)) end_test diff --git a/regress/tests/prune-test b/regress/tests/prune-test index 4a14d69035..c59748b9bd 100755 --- a/regress/tests/prune-test +++ b/regress/tests/prune-test @@ -1,7 +1,6 @@ #!/bin/sh # -# This script will test prune algo with -# vtape +# This script will test prune algo # . scripts/functions @@ -15,6 +14,7 @@ start_test echo $PWD/build/po > tmp/file-list +# We want to have pruning only when doing prune command $bperl -e 'add_attribute("$conf/bacula-dir.conf", "AutoPrune", "No", "Client")' $bperl -e 'add_attribute("$conf/bacula-dir.conf", "Job Retention", "1s", "Client")' @@ -43,7 +43,7 @@ prune jobs yes list jobs @$out $tmp/log4.out @################################################################ -@# Should prune the first incremental job +@# Should prune the two firsts incrementals run job=$JobName level=differential yes wait messages @@ -65,7 +65,6 @@ prune jobs yes list jobs @$out $tmp/log6.out @################################################################ -@# Should prune the last incr run job=$JobName level=incremental yes wait messages @@ -93,16 +92,28 @@ check_two_logs estat=0 -$bperl -e "check_job_list('$tmp/log3.out')" +############################################################################### +# Now we will verify that the pruning code is working as expected. Each time, +# we run 'list jobs', 'prune', 'list jobs'. check_prune_list ensures that jobids +# in argument are present in the first 'list jobs', the 'prune' command deletes +# them (same number), and checks that the last 'list jobs' doesn't contain them +# anymore. See scripts/functions.pm for details. + +# nothing should be pruned +$bperl -e "check_prune_list('$tmp/log3.out')" estat=$(($estat + $?)) -$bperl -e "check_job_list('$tmp/log4.out',2,3)" +# jobids 2 and 3 should be pruned +# (F I I D) -> (F D) +$bperl -e "check_prune_list('$tmp/log4.out',2,3)" estat=$(($estat + $?)) -$bperl -e "check_job_list('$tmp/log5.out',1,4,5)" +# (F D I F) -> (F) +$bperl -e "check_prune_list('$tmp/log5.out',1,4,5)" estat=$(($estat + $?)) -$bperl -e "check_job_list('$tmp/log6.out',7,8)" +# (F I R) -> (F) -- Incremental have 0 file +$bperl -e "check_prune_list('$tmp/log6.out',7,8)" estat=$(($estat + $?)) end_test -- 2.39.5