]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/multi2-storage-test
Fix status alignment output reported by Wanderlei Huttel
[bacula/bacula] / regress / tests / multi2-storage-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6
7 #
8 # This script uses the virtual disk autochanger
9 #
10 TestName="multi-storage-test"
11 JobName=NightlySave
12 . scripts/functions
13
14 export REGRESS_CHECK_CORRUPTION=no
15
16 scripts/cleanup
17 scripts/copy-2disk-confs
18 scripts/prepare-disk-changer
19
20 # create a new bacula-sd.confs
21 for i in 2 3 4; do
22   perl -ne "\$i='$i';\$tmp='$tmp';"'
23   if (/Name =/ ) { $_ =~ s/-sd/-$i-sd/}
24   if (/SDPort = /) { $_ =~ s/(\d+)/1810$i/}
25   if (/mediatype = /) { $_ =~ s/FileMedia/FileMedia$i/}
26   if (/WorkingDirectory/) { $_ =~ s:working:tmp/$i:}
27   if (/Pid Directory/) { $_ =~ s:working:tmp/$i:}
28   if (/(Archive|Changer) Device/) { $_ =~ s:$tmp:$tmp/$i:}
29   print;
30   ' $conf/bacula-sd.conf > $conf/bacula-sd$i.conf
31   mkdir -p ${tmp}/$i
32   sed "s/bacula-sd.conf/bacula-sd${i}.conf/" $scripts/bacula-ctl-sd \
33       > $tmp/bacula-ctl-sd$i
34   chmod +x $tmp/bacula-ctl-sd$i
35   mkdir -p $tmp/$i
36 done
37
38 # Patch up bacula-dir.conf
39 perl -ne '
40 if (/^Storage {/) { $in=1; $nb++; }
41 if (/^}/) { $in=0 }
42 if (/SDPort = (\d+)/ && $in) {if ($nb == 2) { $_ = "  SDPort = 18102\n"; }}
43 if (/SDPort = (\d+)/ && $in) {if ($nb == 3) { $_ = "  SDPort = 18103\n"; }}
44 if (/SDPort = (\d+)/ && $in) {if ($nb == 4) { $_ = "  SDPort = 18104\n"; }}
45 print;
46 ' $conf/bacula-dir.conf > $tmp/1
47 cp $tmp/1 $conf/bacula-dir.conf
48
49 disable_plugins
50
51 echo "${cwd}/build" >${cwd}/tmp/file-list
52
53 change_jobname $JobName
54 start_test
55
56 # Stop SDs
57 for sd in 2 3 4; do
58   $tmp/bacula-ctl-sd$sd stop &> /dev/null
59 done
60
61 sleep 2
62
63 # Start SDs
64 for sd in 2 3 4; do
65   $tmp/bacula-ctl-sd$sd start &> /dev/null
66 done
67
68 # Write out bconsole commands
69 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
70 @out /dev/null
71 messages
72 @$out ${cwd}/tmp/log1.out
73 label storage=tape volume=TestVolume001 Pool=Default slot=1 drive=0
74 label storage=File  volume=TestVolume002 Pool=Default
75 label storage=File2 volume=File2-Vol001 Pool=Default
76 label storage=File3 volume=File3-Vol001 Pool=Default
77 label storage=File4 volume=File4-Vol001 Pool=Default
78 run job=$JobName storage=tape yes
79 wait
80 messages
81 @exec "touch $cwd/build/po/fr.po"
82 run job=$JobName storage=File yes
83 wait
84 messages
85 @exec "touch $cwd/build/po/de.po"
86 run job=$JobName storage=File2 yes
87 wait
88 messages
89 @exec "touch $cwd/build/po/it.po"
90 run job=$JobName storage=File3 yes
91 wait
92 messages
93 @exec "touch $cwd/build/po/es.po"
94 run job=$JobName storage=File4 yes
95 wait
96 messages
97 quit
98 END_OF_DATA
99
100 run_bacula
101
102 echo "ficheriro1.txt" >${cwd}/build/po/ficheriro1.txt
103 echo "ficheriro2.txt" >${cwd}/build/po/ficheriro2.txt
104
105
106 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
107 @out /dev/null
108 messages
109 @$out ${cwd}/tmp/log1.out
110 @# Force Incremental on the second Volume
111 @exec "touch $cwd/build/po/fi.po"
112 run level=Incremental storage=File job=$JobName yes
113 wait
114 messages
115 @exec "touch $cwd/build/po/uk.po"
116 run level=Incremental storage=File2 job=$JobName yes
117 wait
118 messages
119 @exec "touch $cwd/build/po/sv.po $cwd/build/po/test.po"
120 run level=Incremental storage=File3 job=$JobName yes
121 wait
122 messages
123 @exec "touch $cwd/build/po/README"
124 run level=Incremental storage=File4 job=$JobName yes
125 wait
126 messages
127 @# 
128 @# now do a restore
129 @#
130 @$out ${cwd}/tmp/log22.out
131 setdebug trace=1 level=110 client
132 setdebug trace=1 level=110 director
133 restore where=${cwd}/tmp/bacula-restores select all done yes
134 wait
135 messages
136 @$out ${cwd}/tmp/status.out
137 status all
138 @exec "touch $cwd/build/po/POTFILES"
139 @$out ${cwd}/tmp/log1.out
140 run level=Incremental storage=File4 job=$JobName yes
141 wait
142 messages
143 @# run a job that will wait for a volume
144 @$out ${cwd}/tmp/log23.out
145 @exec "touch $cwd/build/po/ChangeLog"
146 run level=Incremental pool=Special storage=File3 job=$JobName yes
147 @sleep 5
148 messages
149 status dir
150 status storage=File3
151 @sleep 3
152 @# 
153 @# now do a restore with a backup that takes a drive
154 @#
155 setdebug trace=1 level=110 client
156 setdebug trace=1 level=110 director
157 restore where=${cwd}/tmp/bacula-restores1 select all done yes
158 @sleep 10
159 messages
160 status dir
161 label storage=File3 volume=test3 pool=Special
162 mount storage=File3
163 wait
164 messages
165 show storage
166 sql
167 select * FROM Storage;
168 select VolumeName, Name, StorageId, MediaType FROM Media JOIN Storage USING (StorageId);
169
170 @$out ${cwd}/tmp/log24.out
171 restore where=${cwd}/tmp/bacula-restores select all done yes
172 wait
173 messages
174 quit
175 END_OF_DATA
176
177 run_bconsole
178
179 check_for_zombie_jobs storage=File
180 check_for_zombie_jobs storage=File2
181 check_for_zombie_jobs storage=File3
182 check_for_zombie_jobs storage=File4
183 check_for_zombie_jobs storage=tape
184
185 stop_bacula
186 for sd in 2 3 4; do
187   $tmp/bacula-ctl-sd$sd stop &> /dev/null
188 done
189
190 # we have two restore to test
191 cp $tmp/log22.out $tmp/log2.out
192 check_two_logs
193 cp $tmp/log23.out $tmp/log2.out
194 check_two_logs
195 cp $tmp/log24.out $tmp/log2.out
196 check_two_logs
197
198 check_restore_diff
199
200 end_test