]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/restore-stop-read2-test
Pull regression truncate-test from Branch-9.1
[bacula/bacula] / regress / tests / restore-stop-read2-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6 # Run two simple backups of the Bacula build directory
7 #   then restore the first one and see if we read too much
8 #   data
9 # 1) run a full backup
10 # 2) run a 2nd full backup on the same volume
11 # 3) delete the 2nd job from the catalog
12 # 4) restore the first full backup
13 # 5) see in traces if we stopped at the end of the first backup
14 #
15 TestName="restore-stop-read2-test"
16 JobName=backup
17 . scripts/functions
18
19 scripts/cleanup
20 scripts/copy-confs
21
22 #
23 # Zap out any schedule in default conf file so that
24 #  it doesn't start during our test
25 #
26 outf="$tmp/sed_tmp"
27 echo "s%  Schedule =%# Schedule =%g" >${outf}
28 cp $scripts/bacula-dir.conf $tmp/1
29 sed -f ${outf} $tmp/1 >$scripts/bacula-dir.conf
30
31 $bperl -e "add_attribute('$conf/bacula-sd.conf', 'MaximumFileSize', '10MB', 'Device')"
32
33 change_jobname BackupClient1 $JobName
34 start_test
35
36 cat <<END_OF_DATA >$tmp/bconcmds
37 @$out /dev/null
38 messages
39 @$out $tmp/log1.out
40 label volume=TestVolume001 storage=File1 pool=File slot=1 drive=0
41 run job=$JobName level=full yes
42 wait
43 run job=$JobName level=full yes
44 wait
45 messages
46 END_OF_DATA
47
48 run_bacula
49
50 cat <<END_OF_DATA >$tmp/bconcmds
51 @$out $tmp/log2.out  
52 @# 
53 @# now do a restore
54 @#
55 setdebug level=500 trace=1 storage=File1
56 delete jobid=2 yes
57 restore where=$tmp/bacula-restores select all done yes
58 wait
59 messages
60 setdebug level=0 trace=0 storage=File1
61 quit
62 END_OF_DATA
63
64 run_bconsole
65
66 check_for_zombie_jobs storage=File1
67 stop_bacula
68
69 # looking for zog8-sd: dircmd.c:1243-3 VolAddr=99993804-100365372
70 eaddr=`awk -F '-' '/VolAddr=/ { ret=$4 } END { print ret }' $working/*trace`
71
72 # zog8-sd: match_bsr.c:674-3 match_voladdr: saddr=99993804 eaddr=100365372 recaddr=200358958 sfile=0 efile=0 recfile=0
73 eaddrseen=`awk '/match_voladdr: saddr=/ { gsub(/recaddr=/, "", $6); ret=$6 } END { print ret}' $working/*trace` 
74
75 eaddrmax=$(($eaddr + $eaddr/2))
76
77 if [ "$eaddrseen" -gt "$eaddrmax" ]; then
78     print_debug "ERROR: The restore process read too much data should stop at eaddr=$eaddr, read eaddrseen=$eaddrseen"
79     estat=1
80 fi
81
82 check_two_logs
83 end_test