]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/cancel-test
4b869b4e0ad43f4378397882e9141b04f9e47a2d
[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 EOF
60
61 change_jobname Client1 $JobName
62 start_test
63
64 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
65 @output /dev/null
66 messages
67 @$out ${cwd}/tmp/logfile1.out
68 @################################################################
69 @# run a first test without volume
70 @# Expect: duration < 60
71 @################################################################
72 run job=$JobName yes
73 @sleep 5
74 messages
75 cancel
76 yes
77 wait
78 messages
79 @$out ${cwd}/tmp/logfile2.out
80 @################################################################
81 @# run test with a small volume
82 @# Expect: duration < 60
83 @################################################################
84 label volume=TestVolume001 storage=File pool=Default
85 update volume=TestVolume001 MaxVolBytes=1MB
86 run job=$JobName yes
87 @sleep 5
88 messages
89 st dir
90 cancel
91 yes
92 wait
93 messages
94 @$out ${cwd}/tmp/logfile3.out
95 @################################################################
96 @# run test with 2 jobs in // (limit 1)
97 @# expect that the second job don't stay in the list
98 @# Expect: Job2 not present at the end
99 @################################################################
100 label volume=TestVolume002 storage=File pool=Default
101 run job=$JobName yes
102 @sleep 1
103 messages
104 run job=$JobName yes
105 @sleep 1
106 messages
107 st dir
108 cancel jobid=4
109 @sleep 1
110 st dir
111 cancel jobid=3
112 @sleep 1
113 st dir
114 wait
115 messages
116 @$out ${cwd}/tmp/logfile4.out
117 @################################################################
118 @# test with a broken fileset
119 @# Expect: duration < 20s
120 @################################################################
121 run job=$JobName fileset=FS_ERR yes
122 @sleep 3
123 messages
124 st dir
125 wait
126 messages
127 @$out ${cwd}/tmp/logfile5.out
128 @################################################################
129 @# test with a broken runscript
130 @# Expect: duration < 20s
131 @################################################################
132 run job=RUN_ERR1 yes
133 @sleep 3
134 messages
135 st dir
136 wait
137 messages
138 @$out ${cwd}/tmp/logfile6.out
139 @################################################################
140 @# test with a broken runscript
141 @# Expect: duration < 20s
142 @################################################################
143 run job=RUN_ERR2 yes
144 @sleep 3
145 messages
146 st dir
147 wait
148 messages
149 @$out ${cwd}/tmp/logfile7.out
150 @################################################################
151 @# test with a broken runscript and a very long AfterJob
152 @# we broke the backup during the ClientRunBeforeJob
153 @# Expect: duration > 600
154 @################################################################
155 run job=RUN_ERR3 yes
156 @sleep 5
157 messages
158 st dir
159 cancel
160 yes
161 @sleep 5
162 messages
163 st dir
164 wait
165 messages
166 @$out ${cwd}/tmp/logfile8.out
167 @################################################################
168 @# test with a broken runscript and a very long AfterJob
169 @# we broke the backup during the ClientRunAfterJob
170 @# Expect: duration > 600
171 @################################################################
172 run job=RUN_ERR3 yes
173 @sleep 20
174 messages
175 st dir
176 cancel
177 yes
178 @sleep 5
179 messages
180 st dir
181 wait
182 messages
183 @$out ${cwd}/tmp/logfile9.out
184 @################################################################
185 @# test with a broken runscript and a very long AfterJob
186 @# we broke the backup during the backup
187 @# Expect: duration > 600
188 @################################################################
189 update volume=TestVolume002 volstatus=Used
190 label volume=TestVolume003 storage=File pool=Default
191 update volume=TestVolume003 MaxVolBytes=1MB
192 run job=RUN_ERR3 yes
193 @sleep 20
194 messages
195 st dir
196 cancel
197 yes
198 @sleep 5
199 messages
200 st dir
201 wait
202 messages
203 @$out ${cwd}/tmp/logfile20.out
204 @################################################################
205 @# test with a broken connexion between DIR/FD
206 @# the test will run a job that will stop, and we send
207 @# the STOP signal to the FD process
208 @# Expect: duration < 400
209 @################################################################
210 update volume=TestVolume003 volstatus=Used
211 label volume=TestVolume004 storage=File pool=Default
212 update volume=TestVolume004 MaxVolBytes=1MB
213 run job=$JobName yes
214 @sleep 5
215 messages
216 quit
217 END_OF_DATA
218
219 run_bacula
220
221 print_debug "Stopping FD"
222 # stop the bacula-fd and cancel the job
223 #kill -STOP $(pidof bacula-fd)
224
225 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
226 @$out ${cwd}/tmp/logfile20.out
227 @sleep 3
228 messages
229 st dir
230 cancel
231 yes
232 st dir
233 wait
234 messages
235 quit
236 END_OF_DATA
237
238 run_bconsole
239
240 kill -CONT $(pidof bacula-fd)
241
242 check_for_zombie_jobs storage=File
243 stop_bacula
244
245 # A fileset or runscript error goes fast
246 check_duration ${cwd}/tmp/logfile4.out 30
247 check_duration ${cwd}/tmp/logfile5.out 30
248 check_duration ${cwd}/tmp/logfile6.out 30
249
250 # Verify the broken connection
251 check_duration ${cwd}/tmp/logfile20.out 400
252
253 end_test