From: Eric Bollengier Date: Wed, 2 Sep 2020 13:32:39 +0000 (+0200) Subject: BEE Backport regress/tests/restore-stop-read4-test X-Git-Tag: Release-11.3.2~1172 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b68341a1fd20908cc9d3e07e7fe8a18f4dc53d31;p=thirdparty%2Fbacula.git BEE Backport regress/tests/restore-stop-read4-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: Tue Dec 20 15:23:09 2016 +0100 regress: Remove some FORCE_CLOUD checks when it's not necessary and add new tests Author: Kern Sibbald Date: Sat May 16 11:45:06 2015 +0200 Tweak restore-stop tests Author: Eric Bollengier Date: Tue Dec 2 18:14:30 2014 +0100 regress: Add test to reproduce bsr restore error --- diff --git a/regress/tests/restore-stop-read4-test b/regress/tests/restore-stop-read4-test new file mode 100755 index 0000000000..ac22717e26 --- /dev/null +++ b/regress/tests/restore-stop-read4-test @@ -0,0 +1,91 @@ +#!/bin/sh +# +# Copyright (C) 2000-2020 Kern Sibbald +# License: BSD 2-Clause; see file LICENSE-FOSS +# +# Run two simple backups of the Bacula build directory +# then restore the first one and see if we read too much +# data +# 1) run a full backup +# 2) run a 2nd full backup on the same volume +# 3) run an incremental backup on a different volume +# 4) delete the 2nd job from the catalog +# 5) restore the first full backup +# 6) see in traces if we stopped at the end of the first backup +# +TestName="restore-stop-read4-test" +JobName=backup +. scripts/functions + +scripts/cleanup +scripts/copy-confs + +require_disk + +# +# Zap out any schedule in default conf file so that +# it doesn't start during our test +# +outf="$tmp/sed_tmp" +echo "s% Schedule =%# Schedule =%g" >${outf} +cp $scripts/bacula-dir.conf $tmp/1 +sed -f ${outf} $tmp/1 >$scripts/bacula-dir.conf + +$bperl -e "add_attribute('$conf/bacula-sd.conf', 'MaximumFileSize', '10MB', 'Device')" + +change_jobname BackupClient1 $JobName +start_test + +cat <$tmp/bconcmds +@$out /dev/null +messages +@$out $tmp/log1.out +label volume=TestVolume001 storage=File1 pool=File slot=1 drive=0 +run job=$JobName level=full yes +wait +run job=$JobName level=full yes +wait +@exec "touch $cwd/build/po/fr.po" +@echo "run incremental over a different volume" +update volume=TestVolume001 volstatus=Used +label volume=TestVolume002 storage=File2 pool=File slot=2 drive=0 +run job=$JobName storage=File2 yes +wait +messages +END_OF_DATA + +run_bacula + +cat <$tmp/bconcmds +@$out $tmp/log2.out +@# +@# now do a restore +@# +delete jobid=2 yes +setdebug level=500 trace=1 storage=File1 +restore where=$tmp/bacula-restores select all done yes +wait +messages +quit +END_OF_DATA + +run_bconsole + +check_for_zombie_jobs storage=File1 +stop_bacula + +# looking for zog8-sd: dircmd.c:1243-3 VolAddr=99993804-100365372 +eaddr=`awk -F '-' '/VolAddr=/ { ret=$4>ret?$4:ret } END { print ret }' $working/*trace` + +# zog8-sd: match_bsr.c:674-3 match_voladdr: saddr=99993804 eaddr=100365372 recaddr=200358958 sfile=0 efile=0 recfile=0 +eaddrseen=`awk '/match_voladdr: saddr=/ { gsub(/recaddr=/, "", $6); ret=ret>$6?ret:$6 } END { print ret}' $working/*trace` + +eaddrmax=$(($eaddr + $eaddr/2)) + +if [ "$eaddrseen" -gt "$eaddrmax" ]; then + print_debug "ERROR: The restore process read too much data should stop at eaddr=$eaddr, read eaddrseen=$eaddrseen" + estat=1 +fi + +check_two_logs +end_test