3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
8 # This script will test next vol algo with
11 # TODO: Test Pool with RecyclePool
12 # Test Pool without RecyclePool
13 # Test with enabled=false
14 # Test with recycle=no
17 # Please do not write any more tests with so many Jobs and combinations,
18 # because when something goes wrong it is very hard and time consuming
19 # to know what caused the failure.
23 TestName="next-vol-test"
28 scripts/copy-tape-confs
29 cp scripts/bacula-dir-vtape.conf bin/bacula-dir.conf
30 cp scripts/bacula-sd-vtape.conf bin/bacula-sd.conf
31 scripts/prepare-fake-autochanger
36 cat <<EOF > ${cwd}/tmp/bconcmds
37 @$out ${cwd}/tmp/log.out
38 label barcodes storage=LTO3 slots=46-59 drive=0 pool=Scratch
41 update Media SET FirstWritten='2006-01-01 01:00:00', LastWritten='2006-01-01 01:00:00';
43 update volume=vol47 pool=Test inchanger=no RecyclePool=Test
44 update volume=vol59 pool=Test enabled=no
45 update volume=vol58 pool=Test volstatus=Recycle
47 update volume=vol56 pool=Test
48 update volume=vol55 pool=Test volstatus=Full
49 update volume=vol46 volstatus=Full volretention=15
51 update volume=vol46 pool=Test
52 update volume=vol54 volstatus=Recycle
54 update volume=vol52 MaxVolJobs=1 volretention=15
55 update volume=vol51 inchanger=no volstatus=Recycle
57 update volume=vol50 inchanger=no
58 update volume=vol49 inchanger=no
59 update volume=vol48 inchanger=no pool=Test
60 update volume AllFromPool=Test
62 update Media SET VolJobs=1 WHERE VolumeName='vol52';
63 update Media SET LastWritten='2006-01-01 01:00:01' WHERE VolumeName='vol57';
64 update Media SET LastWritten='2006-01-01 01:00:02' WHERE VolumeName='vol53';
73 echo $PWD/build/po > tmp/file-list
75 cat <<EOF > ${cwd}/tmp/bconcmds
76 @$out ${cwd}/tmp/log2.out
78 @# Pool + Append + Enabled + InChanger
80 run level=full pool=Test NightlySave yes
85 @# Pool + Recycled + Enabled + InChanger
87 run level=full pool=Test NightlySave yes
92 @# Pool + Purged + Enabled + InChanger
94 run level=full pool=Test NightlySave yes
99 @# Pool + Full + Recycle + Enabled + InChanger
101 run level=full pool=Test NightlySave yes
106 @# No more in Test pool, get from scratch
107 @# vol52 is Append, but have 1 job and MaxJob
108 @# Scratch + Recycle + Enabled + InChanger
110 run level=full pool=Test NightlySave yes
115 @# Scratch + Purged + Enabled + InChanger + LastW
117 run level=Full pool=Test NightlySave yes
122 @# Scratch + Purged + Enabled + InChanger + LastW
124 run level=full pool=Test NightlySave yes
129 @# Scratch + Purged + Enabled + InChanger + LastW
131 run level=full pool=Test NightlySave yes
136 restore fileset="Full Set" pool=Test where=${cwd}/tmp/bacula-restores select all done
144 @#run level=full pool=Test NightlySave yes
153 awk '/Must choose/ { print $4 } ' tmp/log2.out > tmp/normal
154 awk '/Volume name.+:/ { print $3 } ' tmp/log2.out > tmp/real
155 if [ "$debug" -eq 1 ]; then
156 diff -ur tmp/normal tmp/real
158 diff tmp/normal tmp/real > /dev/null
163 # so some tests with File media
164 cat <<EOF > ${cwd}/tmp/bconcmds
165 @$out ${cwd}/tmp/log3.out
166 label volume=file1 storage=File pool=Test
167 label volume=file2 storage=File pool=Test
168 label volume=file3 storage=File pool=Test
169 label volume=file4 storage=File pool=Scratch
170 label volume=file5 storage=File pool=Test
171 label volume=file6 storage=File pool=Test
172 label volume=file7 storage=File pool=Scratch
173 label volume=file8 storage=File pool=Test
174 label volume=file9 storage=File pool=Scratch
175 label volume=file10 storage=File pool=Scratch
176 label volume=file11 storage=File pool=Test
178 update Media SET FirstWritten='2006-01-01 01:00:00', LastWritten='2006-01-01 01:00:00';
180 update volume=file2 enabled=no
181 update volume=file3 volstatus=Recycle
184 update volume=file5 recycle=no volretention=1
185 update volume=file6 volstatus=Full volretention=15
186 update volume=file7 volstatus=Full volretention=15
188 update volume=file8 pool=Test VolRetention=1
189 update volume=file9 volstatus=Recycle
192 update Media SET VolJobs=1 WHERE VolumeName='file9';
193 update Media SET LastWritten='2006-01-01 01:00:01' WHERE VolumeName='file4';
194 update Media SET LastWritten='2006-01-01 01:00:02' WHERE VolumeName='file7';
197 @$out ${cwd}/tmp/log4.out
201 @# Pool + Append + Lowest MediaId
203 run level=full pool=Test storage=File NightlySave yes
208 @# Pool + Append + Lowest MediaId (only once)
210 run level=full pool=Test storage=File NightlySave yes
215 @# Pool + Append + Lowest MediaId
217 run level=full pool=Test storage=File NightlySave yes
224 run level=full pool=Test storage=File NightlySave yes
228 @# Must choose file11
231 run level=full pool=Test storage=File NightlySave yes
236 @# Pool + Full (prunable)
237 setdebug level=50 director
239 run level=full pool=Test storage=File NightlySave yes
242 setdebug level=0 director
246 @# Pool + Full (prunable)
248 run level=full pool=Test storage=File NightlySave yes
251 update volume=file8 enabled=no
253 @# Must choose file10
254 @# (no more Pool) Scratch + Append
256 run level=full pool=Test storage=File NightlySave yes
261 @# (no more Pool) Scratch + Recycle
263 run level=full pool=Test storage=File NightlySave yes
269 @# Used (prunable) + Pool
271 run level=full pool=Test storage=File NightlySave yes
276 @# Used (prunable) + oldest + Scratch
277 run level=full pool=Test storage=File NightlySave yes
282 @# Used (prunable) + oldest + Scratch
284 run level=full pool=Test storage=File NightlySave yes
294 awk '/Must choose/ { print $4 } ' tmp/log4.out > tmp/normal4
295 awk '/Volume name.+:/ { print $3 } ' tmp/log4.out > tmp/real4
296 if [ "$debug" -eq 1 ]; then
297 diff -ur tmp/normal4 tmp/real4
299 diff tmp/normal4 tmp/real4 > /dev/null
301 if [ $dstat -eq 0 ] ; then
303 if [ $dstat -ne 0 ] ; then
304 echo "normal4 and real4 differ!!!!!"
305 echo "normal4 and real4 differ!!!!!" >>test.out
309 # try to break the old code
310 # in this situation, we have 1 available volume (vol50) and bacula will try to use
311 # vol47, vol48 and vol49 and will stop without using vol50.
313 cat <<EOF > ${cwd}/tmp/bconcmds
314 @$out ${cwd}/tmp/log1.out
315 update volume=vol47 pool=Test VolStatus=Used VolRetention=10s inchanger=no RecyclePool=Test
316 update volume=vol48 pool=Test VolStatus=Used VolRetention=10s inchanger=no RecyclePool=Test
317 update volume=vol49 pool=Test VolStatus=Used VolRetention=10s inchanger=no RecyclePool=Test
318 update volume=vol50 pool=Test VolStatus=Used VolRetention=10s inchanger=yes RecyclePool=Test
320 update Media SET FirstWritten='2005-01-01 01:00:00', LastWritten='2005-01-01 01:00:00'
321 WHERE VolumeName IN ('vol47', 'vol48', 'vol49');
325 run level=full pool=Test NightlySave yes
332 grep "Invalid slot=0 defined in catalog for Volume" tmp/log1.out > /dev/null
333 if [ $? -ne 0 ]; then
337 check_for_zombie_jobs storage=LTO3 client=${HOST}-fd