From: Eric Bollengier Date: Wed, 2 Sep 2020 13:22:14 +0000 (+0200) Subject: BEE Backport regress/tests/director-autoprune-test X-Git-Tag: Release-11.3.2~1220 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65e52563d6757a20fa8c65da5ccd4cb55e4041fa;p=thirdparty%2Fbacula.git BEE Backport regress/tests/director-autoprune-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: Eric Bollengier Date: Thu Jan 24 10:41:34 2019 +0100 regress: Check status dir and restore on director-autoprune-test Author: Eric Bollengier Date: Sat Dec 22 17:16:01 2018 +0100 regress: Enhance director-autoprune-test to test status dir as well Author: Eric Bollengier Date: Fri Dec 21 10:11:49 2018 +0100 regress: Add test for the Director:Autoprune feature --- diff --git a/regress/tests/director-autoprune-test b/regress/tests/director-autoprune-test new file mode 100755 index 0000000000..8598222a49 --- /dev/null +++ b/regress/tests/director-autoprune-test @@ -0,0 +1,168 @@ +#!/bin/sh +# +# Copyright (C) 2000-2020 Kern Sibbald +# License: BSD 2-Clause; see file LICENSE-FOSS +# +# This script will test prune algo +# +. scripts/functions + +TestName="director-autoprune-test" +JobName=NightlySave + +scripts/cleanup +scripts/copy-test-confs + +setup_shstore # simulate shared storage if enabled + +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", "Director")' +$bperl -e 'add_attribute("$conf/bacula-dir.conf", "Job Retention", "1s", "Client")' +$bperl -e 'add_attribute("$conf/bacula-dir.conf", "File Retention", "1s", "Client")' +$bperl -e 'add_attribute("$conf/bacula-dir.conf", "Schedule", "WeeklyCycle", "Job")' +$bperl -e 'add_attribute("$conf/bacula-dir.conf", "MaximumVolumeJobs", "1", "Pool")' +$bperl -e 'add_attribute("$conf/bacula-dir.conf", "LabelFormat", "Vol", "Pool")' + +cat < ${cwd}/tmp/bconcmds +@output /dev/null +messages +@$out $tmp/log1.out +run job=$JobName level=full yes +wait +messages +@exec "touch $cwd/build/po/fr.po" +run job=$JobName level=incremental yes +wait +messages +@exec "touch $cwd/build/po/de.po" +run job=$JobName level=incremental yes +wait +messages +@sleep 2 +@$out $tmp/log3.out +@################################################################ +@# Should not prune anything +list jobs +prune jobs yes +list jobs +@$out $tmp/log4.out +@################################################################ +@# Should prune the two firsts incrementals +run job=$JobName level=differential yes +wait +messages +@exec "touch $cwd/build/po/es.po" +run job=$JobName level=incremental yes +wait +messages +status dir +@sleep 2 +list jobs +prune jobs yes +list jobs +@$out $tmp/log5.out +@################################################################ +@# Should prune the first Full+Diff job +run job=$JobName level=full yes +wait +messages +@sleep 2 +list jobs +prune jobs yes +list jobs +@$out $tmp/log6.out +@################################################################ +run job=$JobName level=incremental yes +wait +messages +@$out $tmp/log2.out +restore where=${cwd}/tmp/bacula-restores select all storage=File done +yes +wait +messages +@sleep 2 +@$out $tmp/log6.out +@################################################################ +@# Should not prune anything +list jobs +status dir +list jobs +@$out $tmp/log7.out +@################################################################ +@# Should prune the restore job and the last incremental job (jobfiles=0) +list jobs +prune jobs yes +list jobs +quit +quit +EOF + +run_bacula + +$bperl -e 'add_attribute("$conf/bacula-dir.conf", "AutoPrune", "Yes", "Director")' + +cat < ${cwd}/tmp/bconcmds +@output /dev/null +messages +@$out $tmp/alog7.out +reload +run job=$JobName level=incremental yes +wait +messages +EOF + +run_bconsole + +stop_bacula + +check_two_logs + +estat=0 + +grep -i 'auto prune' $tmp/log*.out > /dev/null +if [ $? = 0 ]; then + print_debug "ERROR: Should not find Autoprune messages in job log" + estat=1 +fi + +grep -i 'auto prune' $tmp/alog7.out > /dev/null +if [ $? != 0 ]; then + print_debug "ERROR: Should find Autoprune messages in job log $tmp/alog7.log" + estat=1 +fi + +############################################################################### +# 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 + $?)) + +# 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 + $?)) + +# (F D I F) -> (F) +$bperl -e "check_prune_list('$tmp/log5.out',1,4,5)" +estat=$(($estat + $?)) + +# (F I R) -> (F I R) -- Incremental have 0 file +$bperl -e "check_prune_list('$tmp/log6.out')" +estat=$(($estat + $?)) + +# (F I R) -> (F) -- Incremental have 0 file +$bperl -e "check_prune_list('$tmp/log7.out',7,8)" +estat=$(($estat + $?)) + +$rscripts/diff.pl -s $cwd/build/po -d $tmp/bacula-restores/$cwd/build/po +rstat=$(($rstat + $?)) + +end_test