]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/next-vol-test
ebl Update next volume in autochanger test
[bacula/bacula] / regress / tests / next-vol-test
1 #!/bin/sh
2 #
3 # This script will test next vol algo with
4 # vtape
5 #
6 # TODO: Test Pool with RecyclePool
7 #       Test Pool without RecyclePool
8 #       Test with enabled=false
9 #       Test with recycle=no
10 #       Track scratch usage
11 #
12 . scripts/functions
13
14 TestName="next-vol-test"
15 JobName=backup
16
17 require_linux
18 scripts/cleanup
19 scripts/copy-tape-confs
20 cp scripts/bacula-dir-vtape.conf bin/bacula-dir.conf
21 cp scripts/bacula-sd-vtape.conf bin/bacula-sd.conf
22 scripts/prepare-fake-autochanger
23
24
25 start_test
26
27 cat <<EOF > ${cwd}/tmp/bconcmds
28 @$out ${cwd}/tmp/log.out
29 label barcodes storage=LTO3 slots=46-59 drive=0 pool=Scratch
30 yes
31 update volume=vol47 pool=Test inchanger=no RecyclePool=Test
32 update volume=vol59 pool=Test enabled=no
33 update volume=vol58 pool=Test volstatus=Recycle
34 purge  volume=vol57
35 update volume=vol56 pool=Test
36 update volume=vol55 pool=Test volstatus=Full volretention=15 
37 update volume=vol46 volstatus=Full volretention=15 
38 purge volume=vol46
39 update volume=vol46 pool=Test
40 update volume=vol54 volstatus=Recycle
41 purge  volume=vol53
42 update volume=vol52 MaxVolJobs=1
43 update volume=vol51 inchanger=no volstatus=Recycle
44 purge  volume=vol50
45 update volume=vol50 inchanger=no
46 update volume=vol49 inchanger=no
47 update volume=vol48 inchanger=no pool=Test
48 update volume  AllFromPool=Test
49 sql
50 update Media SET VolJobs=1 WHERE VolumeName='vol52';
51 update Media SET LastWritten='2006-01-01 01:00:00';
52 update Media SET LastWritten='2006-01-01 01:00:01' WHERE VolumeName='vol57';
53 update Media SET LastWritten='2006-01-01 01:00:02' WHERE VolumeName='vol53';
54 list volume
55 EOF
56
57 run_bacula
58
59 echo $PWD/build/po > tmp/file-list
60
61 cat <<EOF > ${cwd}/tmp/bconcmds
62 @$out ${cwd}/tmp/log2.out
63 @# Must choose vol56
64 @# Pool + Append + Enabled + InChanger
65 run level=full pool=Test NightlySave yes
66 wait
67 message
68 list volume
69 @# Must choose vol58
70 @# Pool + Recycled + Enabled + InChanger
71 run level=full pool=Test NightlySave yes
72 wait
73 message
74 list volume
75 @# Must choose vol46
76 @# Pool + Purged + Enabled + InChanger
77 run level=full pool=Test NightlySave yes
78 wait
79 message
80 list volume
81 @# Must choose vol55
82 @# Pool + Full + Recycle + Enabled + InChanger
83 run level=full pool=Test NightlySave yes
84 wait
85 message
86 list volume
87 @# Must choose vol54
88 @# No more in Test pool, get from scratch
89 @# vol52 is Append, but have 1 job and MaxJob
90 @# Scratch + Recycle + Enabled + InChanger
91 run level=full pool=Test NightlySave yes
92 wait
93 message
94 list volume
95 @# Must choose vol52
96 @# Scratch + Purged + Enabled + InChanger + LastW
97 run level=full pool=Test NightlySave yes
98 wait
99 message
100 list volume
101 @# Must choose vol57
102 @# Scratch + Purged + Enabled + InChanger + LastW
103 run level=full pool=Test NightlySave yes
104 wait
105 message
106 list volume
107 @# Must choose vol53
108 @# Scratch + Purged + Enabled + InChanger + LastW
109 run level=full pool=Test NightlySave yes
110 wait
111 message
112 list volume
113 restore fileset="Full Set" pool=Test where=${cwd}/tmp/bacula-restores select all done
114 yes
115 wait
116 messages
117 wait
118 messages
119 @# Must Wait
120 @#run level=full pool=Test NightlySave yes
121 @#wait
122 @#message
123 @#list volume
124 EOF
125
126 run_bconsole
127
128 awk '/Must choose/ { print $4 } '    tmp/log2.out > tmp/normal
129 awk '/Volume name.+:/ { print $3 } ' tmp/log2.out > tmp/real
130 if test "$debug" -eq 1; then
131    diff -ur tmp/normal tmp/real
132 else
133    diff tmp/normal tmp/real > /dev/null
134 fi
135 export dstat=$?
136
137 # try to break the old code 
138 # in this situation, we have 1 available volume (vol50) and bacula will try to use
139 # vol47, vol48 and vol49 and will stop without using vol50.
140
141
142 cat <<EOF > ${cwd}/tmp/bconcmds
143 @$out ${cwd}/tmp/log1.out
144 update volume=vol47 pool=Test VolStatus=Used VolRetention=10s inchanger=no RecyclePool=Test
145 update volume=vol48 pool=Test VolStatus=Used VolRetention=10s inchanger=no RecyclePool=Test
146 update volume=vol49 pool=Test VolStatus=Used VolRetention=10s inchanger=no RecyclePool=Test
147 update volume=vol50 pool=Test VolStatus=Used VolRetention=10s inchanger=yes RecyclePool=Test
148 sql
149 update Media SET LastWritten='2005-01-01 01:00:00' WHERE VolumeName IN ('vol47', 'vol48', 'vol49');
150
151 list volume
152 run level=full pool=Test NightlySave yes
153 wait
154 messages
155 quit
156 EOF
157
158 run_bconsole
159
160 check_for_zombie_jobs storage=LTO3
161 stop_bacula
162
163 grep "Invalid slot=0 defined in catalog for Volume" tmp/log1.out > /dev/null
164 if [ $? -ne 0 ]; then
165    bstat=$?
166 fi
167
168 check_two_logs
169
170 end_test