]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/cancel-test
ebl update cancel test
[bacula/bacula] / regress / tests / cancel-test
1 #!/bin/sh
2 #
3 # Test different cancel cases
4 # Can be quite long
5
6 #
7 TestName="cancel-test"
8 JobName=backup
9 . scripts/functions
10
11 scripts/cleanup
12 scripts/copy-confs
13
14 #
15 # Zap out any schedule in default conf file so that
16 #  it doesn't start during our test
17 #
18 outf="tmp/sed_tmp"
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
22
23 touch tmp/log1.out
24
25 # Add some jobs and fileset for this test
26 cat <<EOF >>${cwd}/bin/bacula-dir.conf
27 FileSet {
28   Name = FS_ERR
29   Include {
30     Options {
31       signature = MD5
32     }
33     file = "\\</path/to/nowhere"
34   }
35 }
36 Job {
37   Name = RUN_ERR1
38   ClientRunBeforeJob = "/bin/false"
39   JobDefs = DefaultJob
40 }
41 Job {
42   Name = RUN_ERR2
43   RunScript {
44     Command = "/bin/false"
45     RunsWhen = Before
46   }
47   JobDefs = DefaultJob
48 }
49 Job {
50   Name = RUN_ERR3
51   ClientRunBeforeJob="/bin/sleep 10"
52   RunScript {
53     Command = "/bin/sleep 600"
54     RunsWhen = After
55     RunsOnFailure = Yes
56   }
57   JobDefs = DefaultJob
58 }
59 Job {
60   Name = RUN_ERR4
61   ClientRunBeforeJob="/bin/sleep 10"
62   RunScript {
63     Command = "/bin/sleep 40"
64     RunsWhen = After
65     RunsOnFailure = Yes
66   }
67   JobDefs = DefaultJob
68 }
69 EOF
70
71 change_jobname Client1 $JobName
72 start_test
73
74 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
75 @output /dev/null
76 messages
77 @$out ${cwd}/tmp/logfile1.out
78 @################################################################
79 @# run a first test without volume
80 @# Expect: duration < 60
81 @################################################################
82 run job=$JobName yes
83 @sleep 5
84 messages
85 cancel
86 yes
87 wait
88 messages
89 @$out ${cwd}/tmp/logfile2.out
90 @################################################################
91 @# run test with a small volume
92 @# Expect: duration < 60
93 @################################################################
94 label volume=TestVolume001 storage=File pool=Default
95 update volume=TestVolume001 MaxVolBytes=1MB
96 run job=$JobName yes
97 @sleep 5
98 messages
99 st dir
100 cancel
101 yes
102 wait
103 messages
104 @$out ${cwd}/tmp/logfile3.out
105 @################################################################
106 @# run test with 2 jobs in // (limit 1)
107 @# expect that the second job don't stay in the list
108 @# Expect: Job2 not present at the end
109 @################################################################
110 label volume=TestVolume002 storage=File pool=Default
111 run job=$JobName yes
112 @sleep 1
113 messages
114 run job=$JobName yes
115 @sleep 1
116 messages
117 st dir
118 cancel jobid=4
119 @sleep 1
120 st dir
121 cancel jobid=3
122 @sleep 1
123 st dir
124 wait
125 messages
126 @$out ${cwd}/tmp/logfile4.out
127 @################################################################
128 @# test with a broken fileset
129 @# Expect: duration < 20s
130 @################################################################
131 run job=$JobName fileset=FS_ERR yes
132 @sleep 3
133 messages
134 st dir
135 wait
136 messages
137 @$out ${cwd}/tmp/logfile5.out
138 @################################################################
139 @# test with a broken runscript
140 @# Expect: duration < 20s
141 @################################################################
142 run job=RUN_ERR1 yes
143 @sleep 3
144 messages
145 st dir
146 wait
147 messages
148 @$out ${cwd}/tmp/logfile6.out
149 @################################################################
150 @# test with a broken runscript
151 @# Expect: duration < 20s
152 @################################################################
153 run job=RUN_ERR2 yes
154 @sleep 3
155 messages
156 st dir
157 wait
158 messages
159 @$out ${cwd}/tmp/logfile7.out
160 @################################################################
161 @# test with a broken runscript and a very long AfterJob
162 @# we break the backup during the ClientRunBeforeJob
163 @# Expect: duration > 550
164 @################################################################
165 run job=RUN_ERR3 yes
166 @sleep 5
167 messages
168 st dir
169 cancel
170 yes
171 @sleep 5
172 messages
173 st dir
174 wait
175 messages
176 @$out ${cwd}/tmp/logfile8.out
177 @################################################################
178 @# test with a broken runscript and a very long AfterJob
179 @# we break the backup during the ClientRunAfterJob
180 @# Expect: duration > 550
181 @#         print sleep 600
182 @################################################################
183 run job=RUN_ERR3 yes
184 @sleep 20
185 messages
186 st dir
187 cancel
188 yes
189 @sleep 5
190 messages
191 st dir
192 wait
193 messages
194 @$out ${cwd}/tmp/logfile9.out
195 @################################################################
196 @# test with a broken runscript and a very long AfterJob
197 @# we break the backup during the backup
198 @# Expect: duration > 550
199 @#         print sleep 600
200 @################################################################
201 update volume=TestVolume002 volstatus=Used
202 label volume=TestVolume003 storage=File pool=Default
203 update volume=TestVolume003 MaxVolBytes=1MB
204 run job=RUN_ERR3 yes
205 @sleep 20
206 messages
207 st dir
208 cancel
209 yes
210 @sleep 5
211 messages
212 st dir
213 wait
214 messages
215 @$out ${cwd}/tmp/logfile10.out
216 @################################################################
217 @# test with a broken runscript and a short AfterJob
218 @# we break the backup during the backup
219 @# Expect: print sleep 40
220 @################################################################
221 update volume=TestVolume003 volstatus=Used
222 label volume=TestVolume004 storage=File pool=Default
223 update volume=TestVolume004 MaxVolBytes=1MB
224 run job=RUN_ERR4 yes
225 @sleep 20
226 messages
227 st dir
228 cancel
229 yes
230 @sleep 5
231 messages
232 st dir
233 wait
234 messages
235 @$out ${cwd}/tmp/logfile20.out
236 @################################################################
237 @# test with a broken connexion between DIR/FD
238 @# the test will run a job that will stop, and we send
239 @# the STOP signal to the FD process
240 @# Expect: duration < 400
241 @################################################################
242 update volume=TestVolume003 volstatus=Used
243 label volume=TestVolume004 storage=File pool=Default
244 update volume=TestVolume004 MaxVolBytes=1MB
245 run job=$JobName yes
246 @sleep 5
247 messages
248 quit
249 END_OF_DATA
250
251 run_bacula
252
253 print_debug "Stopping FD"
254 # stop the bacula-fd and cancel the job
255 kill -STOP $(pidof bacula-fd)
256
257 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
258 @$out ${cwd}/tmp/logfile20.out
259 @sleep 3
260 messages
261 st dir
262 cancel
263 yes
264 st dir
265 wait
266 messages
267 quit
268 END_OF_DATA
269
270 run_bconsole
271
272 kill -CONT $(pidof bacula-fd)
273
274 check_for_zombie_jobs storage=File
275 stop_bacula
276
277 # A fileset or runscript error goes fast
278 check_duration ${cwd}/tmp/logfile1.out 30
279 check_duration ${cwd}/tmp/logfile3.out 30
280 check_duration ${cwd}/tmp/logfile4.out 30
281 check_duration ${cwd}/tmp/logfile5.out 30
282 check_duration ${cwd}/tmp/logfile6.out 30
283
284 check_duration ${cwd}/tmp/logfile8.out 550 gt
285 grep 'ClientAfterJob "/bin/sleep 600"' tmp/logfile8.out >/dev/null
286 if [ $? -ne 0 ]; then
287     print_debug "Can't find ClientAfterJob"
288     bstat=2
289 fi
290
291 check_duration ${cwd}/tmp/logfile9.out 550 gt
292 grep 'ClientAfterJob "/bin/sleep 600"' tmp/logfile9.out >/dev/null
293 if [ $? -ne 0 ]; then
294     print_debug "Can't find ClientAfterJob"
295     bstat=2
296 fi
297
298 grep 'ClientAfterJob "/bin/sleep 40"' tmp/logfile10.out >/dev/null
299 if [ $? -ne 0 ]; then
300     print_debug "Can't find ClientAfterJob"
301     bstat=2
302 fi
303
304 # Verify the broken connection
305 check_duration ${cwd}/tmp/logfile20.out 400
306
307 end_test