]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/storageid-test-changer
Tweak cleaner output in accurate-test
[bacula/bacula] / regress / tests / storageid-test-changer
1 #!/bin/sh
2 #
3 # Run backups with dummy tape driver
4 # This test setups an Autochanger with 80 slots
5 # and 5 drives (3 LTO3 and 2 LTO1)
6 #
7 # TAPE_DRIVE="$cwd/working/ach/drive0"
8 # TAPE_DRIVE1="$cwd/working/ach/drive0"
9 # AUTOCHANGER="$cwd/working/ach/conf"
10 # USE_VTAPE=yes
11 # AUTOCHANGER_SCRIPT=disk-changer
12
13
14 TestName="storageid-test-changer"
15 JobName=backup
16 . scripts/functions
17
18 require_vtape
19
20 scripts/cleanup
21 scripts/copy-tape-confs
22 cp $rscripts/bacula-dir-vtape.conf $conf/bacula-dir.conf
23 cp $rscripts/bacula-sd-vtape.conf $conf/bacula-sd.conf
24 scripts/prepare-fake-autochanger
25
26 echo "${cwd}/build" >${cwd}/tmp/file-list
27
28 start_test
29
30 when1=`perl -MPOSIX -e "print strftime('%F %T', localtime(time+30))"`
31 when2=`perl -MPOSIX -e "print strftime('%F %T', localtime(time+45))"`
32
33 clientname=`awk '/Name = .*-fd/ { if (!ok) { print $3 ; ok=1 } }' bin/bacula-dir.conf`
34
35 # Catalog record for cleaning tape "CLN01" successfully created.
36 # CLN01      | Cleaning
37
38 # Write out bconsole commands
39 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
40 @$out /dev/null
41 messages
42 @$out ${cwd}/tmp/log6.out
43 @#setdebug level=200 storage=LTO1
44 label barcodes pool=Scratch slots=1-4 storage=LTO1-ANSI_6 drive=6
45 yes
46 label barcodes pool=Scratch slots=15-25 storage=LTO1 drive=3
47 yes
48 messages
49 list volumes
50 END_OF_DATA
51
52 run_bacula
53
54 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
55 @$out ${cwd}/tmp/log7.out
56 label barcodes pool=Scratch slots=41-50 storage=LTO3 drive=0
57 yes
58 sql
59 SELECT Storage.Name, VolumeName, Slot, InChanger, Pool.Name
60   FROM Media JOIN Storage USING (StorageId) JOIN Pool USING (PoolId);
61
62 messages
63 list volumes
64 @$out ${cwd}/tmp/log1.out
65 run storage=LTO3_0 job=NightlySave  pool=Inc     yes
66 wait
67 messages
68 run storage=LTO3_0 job=NightlySave2 pool=Full    yes
69 wait
70 messages
71 @$out ${cwd}/tmp/log4.out
72 setdebug level=51 trace=1 dir
73 @exec "touch $cwd/build/po/fr.po"
74 run storage=LTO3_1 job=NightlySave  pool=Inc    yes
75 wait
76 setdebug level=0 trace=0 dir
77 messages
78 @$out ${cwd}/tmp/log1.out
79 run storage=LTO1_4 job=NightlySave  pool=Inc     yes
80 wait
81 messages
82 sql
83 SELECT Storage.Name, MediaType, VolumeName, Slot, InChanger, Pool.Name
84   FROM Media JOIN Storage USING (StorageId) JOIN Pool USING (PoolId);
85
86 @$out ${cwd}/tmp/log2.out
87 restore storage=LTO3_1 client=$clientname
88 3
89 1,2,3
90 m *
91 done
92 yes
93 wait
94 messages
95 quit
96 END_OF_DATA
97
98 run_bconsole
99 check_for_zombie_jobs storage=LTO1 client=$clientname
100
101 grep 'Volume ".*" previously written, moving' $cwd/tmp/log4.out > /dev/null
102 if [ $? -ne 0 ]; then
103     print_debug "ERROR: Job 3 should re-use a volume"
104     estat=1
105 fi
106
107 grep "Call prune_volumes" $working/*trace > /dev/null
108 if [ $? -eq 0 ]; then
109     print_debug "ERROR: Job 3 should re-use a volume, not try to prune one"
110     estat=1
111 fi
112
113 grep "after get scratch volume ok=" $working/*trace > /dev/null
114 if [ $? -eq 0 ]; then
115     print_debug "ERROR: Job 3 should re-use a volume, not try to get a scratch one"
116     estat=1
117 fi
118
119 # remove volume vol20 from autochanger
120 grep -v vol20 ${cwd}/working/ach/barcodes > ${cwd}/tmp/1
121 cp ${cwd}/tmp/1 ${cwd}/working/ach/barcodes
122
123 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
124 @$out ${cwd}/tmp/log3.out
125 list volume=vol20
126 update slots slots=5-40 storage=LTO1 drive=3
127 list volume=vol20
128 sql
129 SELECT Storage.Name, VolumeName, Slot, InChanger, Pool.Name
130   FROM Media JOIN Storage USING (StorageId) JOIN Pool USING (PoolId);
131
132 END_OF_DATA
133
134 run_bconsole
135
136 stop_bacula
137
138 touch ${cwd}/tmp/log2.out
139 check_two_logs
140 check_restore_diff
141
142 # get InChanger flag
143 RES=`awk -F'|' '/vol20.+Append/ { print $11 }' ${cwd}/tmp/log3.out`
144 set "$RES"
145 if [ "$1" = "$2" ]; then
146     echo "Error in update slots"
147     bstat=1
148 fi
149
150 grep LTO1_5 tmp/log1.out > /dev/null
151 if test $? = 0; then
152     echo "AutoSelect option broken"
153     bstat=1
154 fi
155
156 grep 'Error: Re-read' tmp/log1.out > /dev/null
157 if test $? = 0; then
158     echo "Found Re-read errors"
159     bstat=1
160 fi
161
162 end_test