]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/bsr-read-test
2b8463b9320cf57857a3b9f39c3df3bdeb3bfa4f
[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=File volume=TestVolume001 pool=Default
29 run job=$JobName yes
30 wait
31 messages
32 list jobs
33 @# print the JobMedia records
34 sql
35 select * from JobMedia;
36
37 quit
38 END_OF_DATA
39
40 run_bacula
41 check_for_zombie_jobs storage=File
42 stop_bacula
43
44 echo "${cwd}/build" >${cwd}/tmp/file-list
45
46 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
47 @$out /dev/null
48 messages
49 @$out ${cwd}/tmp/log1.out
50 run job=$JobName level=Full yes
51 wait
52 messages
53 run job=$JobName level=Full yes
54 wait
55 messages
56 run job=$JobName level=Full yes
57 wait
58 messages
59 @# 
60 @# now do a restore
61 @#
62 @$out ${cwd}/tmp/log2.out
63 setdebug level=30 trace=1 fd
64 setdebug level=500 trace=1 storage=File
65 sql
66 @# print the JobMedia records
67 select * from JobMedia;
68
69 @# 
70 @# now do a restore
71 @#
72 restore
73 3
74 2
75 mark *
76 done
77 yes
78 wait
79 messages
80 @# 
81 @# now do a restore
82 @#
83 @$out ${cwd}/tmp/log3.out
84 restore
85 3
86 1
87 mark *
88 done
89 yes
90 wait
91 messages
92 restore all
93 3
94 3
95 done
96 yes
97 wait
98 messages
99 @$out
100 update volume=TestVolume001 volstatus=Used
101 run job=migrate-job jobid=1 yes
102 run job=migrate-job jobid=2 yes
103 run job=migrate-job jobid=3 yes
104 wait
105 messages
106 quit
107 END_OF_DATA
108
109 run_bacula
110 check_for_zombie_jobs storage=File
111 stop_bacula
112
113 check_two_logs
114 # check_restore_tmp_build_diff
115 dstat=0
116
117 perl -ne '
118 sub check_bloc {   
119   $nb = $last_bloc - $last_bsr_bloc;
120   if ($nb > 65000) {
121      print "ERROR: read too many bytes $nb\n";
122   }
123 }
124 sub print_stat {
125      print "$last_job\nlast_bsr_bloc=$last_bsr_bloc last_bloc_read=$last_bloc\n";
126      check_bloc();
127      $last_bsr_bloc = $last_bloc=0;
128 }
129
130 if (/dircmd.c.+(JobId=\d+ job=\S+) .+client_name=.+-fd/) {
131   if ($last_job) {
132       print_stat();
133   }
134 }
135
136 $last_job=$1      if /dircmd.c.+(JobId=\d+ job=\S+)/;
137 $last_bsr_bloc=$1 if /fd_cmds.c:.+VolBlock=\d+-(\d+)/;
138 $last_bloc=$1     if /read_record.c.+file:block=\d+:(\d+)/;
139 END { 
140   print_stat();
141 }' working/*-sd.trace > tmp/result
142
143 grep ERROR tmp/result > /dev/null
144 if [ $? -eq 0 ]; then
145     rstat=2
146     cat tmp/result
147 fi
148
149 end_test