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);
}
# 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} @_;
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')"
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
#!/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
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
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
#!/bin/sh
#
-# This script will test prune algo with
-# vtape
+# This script will test prune algo
#
. scripts/functions
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")'
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
list jobs
@$out $tmp/log6.out
@################################################################
-@# Should prune the last incr
run job=$JobName level=incremental yes
wait
messages
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