3 # Test different cancel cases
15 # Zap out any schedule in default conf file so that
16 # it doesn't start during our test
19 echo "s% Schedule =%# Schedule =%g" >$outf
20 cp ${cwd}/bin/bacula-dir.conf ${cwd}/tmp/1
21 sed -f ${outf} ${cwd}/tmp/1 >${cwd}/bin/bacula-dir.conf
25 # Add some jobs and fileset for this test
26 cat <<EOF >>${cwd}/bin/bacula-dir.conf
33 file = "\\</path/to/nowhere"
38 ClientRunBeforeJob = "/bin/false"
44 Command = "/bin/false"
51 ClientRunBeforeJob="/bin/sleep 10"
53 Command = "/bin/sleep 600"
61 ClientRunBeforeJob="/bin/sleep 10"
63 Command = "/bin/sleep 40"
71 change_jobname BackupClient1 $JobName
74 when=`perl -MPOSIX -e "print strftime('%F %T', localtime(time+6000))"`
76 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
79 @$out ${cwd}/tmp/logfile1.out
80 @################################################################
81 @# run a first test without volume
82 @# Expect: duration < 60
83 @################################################################
91 @$out ${cwd}/tmp/logfile2.out
92 @################################################################
93 @# run test with a small volume
94 @# Expect: duration < 60
95 @################################################################
96 label volume=TestVolume001 storage=File pool=Default
97 update volume=TestVolume001 MaxVolBytes=1MB
106 @$out ${cwd}/tmp/logfile3.out
107 @################################################################
108 @# run test with 2 jobs in // (limit 1)
109 @# expect that the second job don't stay in the list
110 @# Expect: Job2 not present at the end
111 @################################################################
112 label volume=TestVolume002 storage=File pool=Default
128 @$out ${cwd}/tmp/logfile4.out
129 @################################################################
130 @# test with a broken fileset
131 @# Expect: duration < 20s
132 @################################################################
133 run job=$JobName fileset=FS_ERR yes
139 @$out ${cwd}/tmp/logfile5.out
140 @################################################################
141 @# test with a broken runscript
142 @# Expect: duration < 20s
143 @################################################################
150 @$out ${cwd}/tmp/logfile6.out
151 @################################################################
152 @# test with a broken runscript
153 @# Expect: duration < 20s
154 @################################################################
161 @$out ${cwd}/tmp/logfile7.out
162 @################################################################
163 @# test with a broken runscript and a very long AfterJob
164 @# we break the backup during the ClientRunBeforeJob
165 @# Expect: duration > 550
166 @################################################################
178 @$out ${cwd}/tmp/logfile8.out
179 @################################################################
180 @# test with a broken runscript and a very long AfterJob
181 @# we break the backup during the ClientRunAfterJob
182 @# Expect: duration > 550
184 @################################################################
196 @$out ${cwd}/tmp/logfile9.out
197 @################################################################
198 @# test with a broken runscript and a very long AfterJob
199 @# we break the backup during the backup
200 @# Expect: duration > 550
202 @################################################################
203 update volume=TestVolume002 volstatus=Used
204 label volume=TestVolume003 storage=File pool=Default
205 update volume=TestVolume003 MaxVolBytes=1MB
217 @$out ${cwd}/tmp/logfile10.out
218 @################################################################
219 @# test with a broken runscript and a short AfterJob
220 @# we break the backup during the backup
221 @# Expect: print sleep 40
222 @################################################################
223 update volume=TestVolume003 volstatus=Used
224 label volume=TestVolume004 storage=File pool=Default
225 update volume=TestVolume004 MaxVolBytes=1MB
239 @$out ${cwd}/tmp/logfile11.out
240 @################################################################
241 @# Test to cancel the job immediately
242 @# Expect: duration < 30
243 @################################################################
244 label volume=TestVolume005 storage=File pool=Default
255 @$out ${cwd}/tmp/logfile12.out
256 @################################################################
257 @# Test to cancel the job before it starts
259 @################################################################
260 run job=$JobName when="$when" yes
272 @$out ${cwd}/tmp/logfile20.out
273 @################################################################
274 @# test with a broken connexion between DIR/FD
275 @# the test will run a job that will stop, and we send
276 @# the STOP signal to the FD process
277 @# Expect: duration < 400
278 @################################################################
279 update volume=TestVolume005 volstatus=Used
280 label volume=TestVolume006 storage=File pool=Default
281 update volume=TestVolume006 MaxVolBytes=1MB
290 print_debug "Stopping FD"
291 # stop the bacula-fd and cancel the job
292 kill -STOP $(pidof bacula-fd)
294 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
295 @$out ${cwd}/tmp/logfile20.out
309 kill -CONT $(pidof bacula-fd)
311 check_for_zombie_jobs storage=File
314 # A fileset or runscript error goes fast
315 check_duration ${cwd}/tmp/logfile1.out 30
316 check_duration ${cwd}/tmp/logfile3.out 30
317 check_duration ${cwd}/tmp/logfile4.out 30
318 check_duration ${cwd}/tmp/logfile5.out 30
319 check_duration ${cwd}/tmp/logfile6.out 30
321 check_duration ${cwd}/tmp/logfile8.out 550 lt
322 grep 'ClientAfterJob "/bin/sleep 600"' tmp/logfile8.out >/dev/null
323 if [ $? -ne 0 ]; then
324 print_debug "Can't find ClientAfterJob"
328 check_duration ${cwd}/tmp/logfile9.out 550 lt
329 grep 'ClientAfterJob "/bin/sleep 600"' tmp/logfile9.out >/dev/null
330 if [ $? -ne 0 ]; then
331 print_debug "Can't find ClientAfterJob"
335 grep 'ClientAfterJob "/bin/sleep 40"' tmp/logfile10.out >/dev/null
336 if [ $? -ne 0 ]; then
337 print_debug "Can't find ClientAfterJob"
341 # Verify the broken connection
342 check_duration ${cwd}/tmp/logfile20.out 400 lt