]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/bsr-read-test
Make out of freespace non-fatal for removable devices -- i.e. behaves like tape
[bacula/bacula] / regress / tests / bsr-read-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6
7 #
8 # Run a backup of a small file, then do several other backups
9 #   to expand the size of a volume.  Then do a restore of the first
10 #   file, and make sure it doesn't read to the end of the disk.
11 #
12 TestName="bsr-read-test"
13 JobName=bsr-read
14 . scripts/functions
15
16 scripts/cleanup
17 scripts/copy-migration-confs
18 scripts/prepare-disk-changer
19
20 cp ${cwd}/build/configure ${cwd}/tmp
21 cat ${cwd}/build/configure >> ${cwd}/tmp/configure
22 echo "${cwd}/tmp/configure" >${cwd}/tmp/file-list
23 echo "${cwd}/build" >>${cwd}/tmp/file-list
24
25 change_jobname NightlySave $JobName
26 start_test
27
28 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
29 @$out /dev/null
30 messages
31 @$out ${cwd}/tmp/log1.out
32 label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Full drive=0
33 label storage=File volume=TestVolume001 pool=Default
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 run job=$JobName level=Full yes
62 wait
63 messages
64 @# 
65 @# now do a restore
66 @#
67 @$out ${cwd}/tmp/log2.out
68 setdebug level=30 trace=1 fd
69 setdebug level=500 trace=1 storage=File
70 sql
71 @# print the JobMedia records
72 select * from JobMedia;
73
74 @# 
75 @# now do a restore
76 @#
77 restore
78 3
79 2
80 mark *
81 done
82 yes
83 wait
84 messages
85 @# 
86 @# now do a restore
87 @#
88 @$out ${cwd}/tmp/log3.out
89 restore
90 3
91 1
92 mark *
93 done
94 yes
95 wait
96 messages
97 restore all
98 3
99 3
100 done
101 yes
102 wait
103 messages
104 update volume=TestVolume001 volstatus=Used
105 run job=migrate-job jobid=1 yes
106 run job=migrate-job jobid=2 yes
107 run job=migrate-job jobid=3 yes
108 wait
109 messages
110 quit
111 END_OF_DATA
112
113 run_bacula
114 check_for_zombie_jobs storage=File
115 stop_bacula
116
117 check_two_logs
118 # check_restore_tmp_build_diff
119 dstat=0
120
121 perl -ne '
122 sub check_block {
123   return unless ($last_block || $last_bsr_block);
124   $nb = $last_block - $last_bsr_block;
125   if ($nb > 65000) {
126      print "ERROR: read too many bytes $nb\n";
127   }
128 }
129 sub print_stat {
130      if ($last_bsr_addr) {
131         $last_bsr_block = $last_bsr_addr & 0xFFFFFFFF;
132      }   
133      print "$last_job\nlast_bsr_block=$last_bsr_block last_block_read=$last_block\n";
134      check_block();
135      $last_bsr_block = $last_block=0;
136 }
137
138 if (/dircmd.c.+(JobId=\d+ job=\S+) .+client_name=.+-fd/) {
139   if ($last_job) {
140       print_stat();
141   }
142 }
143
144 $last_job=$1      if /dircmd.c.+(JobId=\d+ job=\S+)/;
145 $last_bsr_addr=$1  if /fd_cmds.c:.+VolAddr=\d+-(\d+)/;
146 $last_bsr_block=$1 if /fd_cmds.c:.+VolBlock=\d+-(\d+)/;
147 $last_block=$1     if /read_record.c.+file:block=\d+:(\d+)/;
148 END { 
149   print_stat();
150 }' working/*-sd.trace > tmp/result
151
152 grep ERROR tmp/result > /dev/null
153 if [ $? -eq 0 ]; then
154     rstat=2
155     cat tmp/result
156 fi
157
158 end_test