]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/bsr-read-test
ebl Add code that shows the bug
[bacula/bacula] / regress / tests / bsr-read-test
1 #!/bin/sh
2 #
3 # Run a backup of a small file, then do several other backups
4 #   to expand the size of a volume.  Then do a restore of the first
5 #   file, and make sure it doesn't read to the end of the disk.
6 #
7 TestName="bsr-read-test"
8 JobName=bsr-read
9 . scripts/functions
10
11 scripts/cleanup
12 scripts/copy-migration-confs
13 scripts/prepare-disk-changer
14
15 cp ${cwd}/build/configure ${cwd}/tmp
16 cat ${cwd}/build/configure >> ${cwd}/tmp/configure
17 echo "${cwd}/tmp/configure" >${cwd}/tmp/file-list
18 echo "${cwd}/build" >>${cwd}/tmp/file-list
19
20 change_jobname NightlySave $JobName
21 start_test
22
23 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
24 @$out /dev/null
25 messages
26 @$out ${cwd}/tmp/log1.out
27 label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Full drive=0
28 label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Full drive=0
29 label storage=File volume=TestVolume001 pool=Default
30 label storage=File volume=TestVolume002 pool=Default
31 label storage=File volume=TestVolume003 pool=Default
32 update Volume=TestVolume001 maxvolbytes=120000
33 update Volume=TestVolume002 maxvolbytes=120000
34 run job=$JobName yes
35 wait
36 messages
37 list jobs
38 @# print the JobMedia records
39 sql
40 select * from JobMedia;
41
42 quit
43 END_OF_DATA
44
45 run_bacula
46 check_for_zombie_jobs storage=File
47 stop_bacula
48
49 echo "${cwd}/build" >${cwd}/tmp/file-list
50
51 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
52 @$out /dev/null
53 messages
54 @$out ${cwd}/tmp/log1.out
55 run job=$JobName level=Full yes
56 wait
57 messages
58 run job=$JobName level=Full yes
59 wait
60 messages
61 @# 
62 @# now do a restore
63 @#
64 @$out ${cwd}/tmp/log2.out
65 setdebug level=30 trace=1 fd
66 setdebug level=500 trace=1 storage=File
67 sql
68 @# print the JobMedia records
69 select * from JobMedia;
70
71 restore
72 3
73 1
74 mark *
75 done
76 yes
77 wait
78 messages
79 @# 
80 @# now do a restore of the second job (to compare offset)
81 @#
82 @$out ${cwd}/tmp/log3.out
83 restore
84 3
85 2
86 mark *
87 done
88 yes
89 wait
90 messages
91 @$out
92 update volume=TestVolume003 volstatus=Used
93 run job=migrate-job jobid=1 yes
94 run job=migrate-job jobid=2 yes
95 wait
96 messages
97 quit
98 END_OF_DATA
99
100 run_bacula
101 check_for_zombie_jobs storage=File
102 stop_bacula
103
104 check_two_logs
105 # check_restore_tmp_build_diff
106 dstat=0
107
108 perl -ne '
109 sub check_bloc {   
110   $nb = $last_bloc - $last_bsr_bloc;
111   if ($nb > 65000) {
112      print "ERROR: read too much bytes $nb\n";
113   }
114 }
115 sub print_stat {
116      print "$last_job\nlast_bsr_bloc=$last_bsr_bloc last_bloc_read=$last_bloc\n";
117      check_bloc();
118      $last_bsr_bloc = $last_bloc=0;
119 }
120
121 if (/dircmd.c.+(JobId=\d+ job=\S+) .+client_name=.+-fd/) {
122   if ($last_job) {
123       print_stat();
124   }
125 }
126
127 $last_job=$1      if /dircmd.c.+(JobId=\d+ job=\S+)/;
128 $last_bsr_bloc=$1 if /fd_cmds.c:.+VolBlock=\d+-(\d+)/;
129 $last_bloc=$1     if /read_record.c.+file:block=\d+:(\d+)/;
130 END { 
131   print_stat();
132 }' working/*-sd.trace > tmp/result
133
134 grep ERROR tmp/result > /dev/null
135 if [ $? -eq 0 ]; then
136     rstat=2
137     cat tmp/result
138 fi
139
140 end_test