]> git.sur5r.net Git - bacula/bacula/blob - regress/README
Make out of freespace non-fatal for removable devices -- i.e. behaves like tape
[bacula/bacula] / regress / README
1 #
2 # Copyright (C) 2000-2015 Kern Sibbald
3 # License: BSD 2-Clause; see file LICENSE-FOSS
4 #
5
6
7              Bacula Regression
8                Kern Sibbald
9
10 This is Bacula's regression script directory.
11
12 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
13 Warning!!!! Make sure not to run it on the same system 
14 with your production Catalog because the tables will all
15 be cleared. You can run it on the your production system
16 if you use a different database. E.g. if your production
17 system uses MySQL, you can use SQLite here.
18 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
19
20
21 To set it up, create your personal configuration file, by
22 copying prototype.conf to config or simply editing prototype.conf
23 directly then copying it to the file config.
24
25 You must end up with a file named config in the main regress 
26 directory that has all the specifications that correspond to
27 your system.
28
29 If you are using SQLite, make sure that depkgs is pre-built if it
30 isn't already: (cd your-depkgs; make sqlite).
31
32 Note, if you use any database other than SQLite, be sure it is not              
33 your production database because Bacula will delete all the tables
34 and recreate them.  With SQLite, a new different database is created,
35 so it will not affect your production system.
36
37 Using the .conf file, you can now select between any Catalog type:
38 SQLite, SQLite3, MySQL, or PostgreSQL.  Be aware, however, if you
39 use an installed database on a production server, running these
40 tests will delete all the tables !!!!!!!!!!!!!!!!!!  I run my
41 tests on a non-production machine, and in addition, I normally use
42 SQLite as the database, while my production uses MySQL.
43
44 Then do:
45
46    make setup
47
48 You run the above one time.  This will build a Makefile from
49 Makefile.in and your xxx.conf file, copy the Bacula source,
50 configure, build it, and configure all the Bacula scripts
51 and conf files.  If you change your source, you will need to
52 redo this command.
53
54 Then you can run any of the tests in the tests subdirectory.
55 Each test whose name ends in -root requires you to be root for
56 a resonable run.  Each test is totally independent of any other
57 test. Aside from the required "make setup", each test is totally
58 self-initalizing and should clean up after itself.
59
60 All the tests expect you to execute them from the main regress 
61 directory!               
62
63 Running the disk based tests:
64
65 You can run all the disk based tests by doing:
66
67   ./do_file
68
69 The disk based tests are totally separate from any production
70 system, provided you have configured the database appropriately     
71 as noted above.
72
73 Running all the "standard" tests:
74
75 You can run all the disk and most of the tape tests by doing:
76
77   ./do_all
78
79 ======== Important !!! ============
80 When running the tape tests, Bacula will write on any tape that
81 is in the tape drive that you have configured.  If it is a production
82 Bacula tape, it will be destroyed.  If you have configured an Autochanger,
83 Bacula will write on the tapes in slots 1 and 2 thus destroying any
84 information on those tapes, even if they are Bacula production tapes.
85 =================================== 
86
87 Each of the above calls one or more scripts. By looking at the
88 scripts available in this directory, you can see that there are a number
89 of options for running tests.
90
91 You can run them individually as:
92
93    tests/two-jobs-test
94
95 or all non-root tests (my normal testing under my account)
96
97   ./all-non-root-tests
98
99 or all tests (I only run these before a production release):
100
101    su
102    ./all-tests
103
104
105 after running the root tests, while still root, it is a good idea
106 to do:
107
108    make reset
109
110 this cleans up any files that may be created with root permissions.
111
112 Tape test naming convention:
113
114 The last part of the tape test name indicates (in general) what kind
115 of test it is.  They are broken (for the most part) into test names
116 ending with:
117
118   -test     => a disk based test
119   -tape     => a tape based test (can be a standalone tape drive
120                 or an autochanger). Only one tape will be used
121                 and it is assumed to be mounted.
122   -changer  => you have an autochanger 
123
124 Adding tests:
125
126 If you want to add more tests, do so by putting the shell script 
127 in the tests subdirectory. Be careful when adding (or better not)
128 new clients, pools, and such to the test-bacula-dir.conf.in file
129 as it may invalidate a good number of tests, which respond to
130 questions by answering with a number (i.e. the order of the selection
131 list is known). It might be better to add your own testb-bacula...
132 configuration file.  
133
134 To avoid re-doing a make setup if you have made a change to the
135 conf files, and you do not need a new copy of the source, you can simply do:
136
137    make sed
138
139 Debugging failed tests:
140
141 Prior versions required editing the tests/xxxx and changing a debug flag.
142 However, that has been replaced by two environment variables:
143
144    REGRESS_DEBUG
145    REGRESS_WAIT
146
147 If you define REGRESS_DEBUG, e.g.
148
149    REGRESS_DEBUG=1
150    export REGRESS_DEBUG
151
152 then run a test, it will display the job and debug output.
153
154 If you define REGRESS_WAIT, the script will stop and request:
155
156 Start Bacula under debugger and enter anything when ready ...
157
158 At this point, you can start any of the daemons under the debugger,
159 then answer the message by entering any character.  The script will         
160 then continue. For any daemon or daemons that you have manually started,
161 you will see an error message when the script attempts to run a second
162 copy, but those messages can be ignored.  This makes it reasonably easy
163 to run any component or components under the debugger if necessary.
164
165 Explicit example:
166
167 In shell window 1.
168
169 cd regress
170 export REGRESS_DEBUG=1
171 export REGRESS_WAIT=1
172 tests/name-of-script-test
173 (wait until it tells you to start the debugger)
174
175 In shell window 2
176
177 cd regress/bin
178 gdb bacula-xx    (where xx is the component you want to debug).
179 (possibly set a break point -- normally not)
180 run -s -f
181 (wait for the output to stop)
182
183 In shell window 1
184 (enter any character or simply a return)
185 (ignore the error message it prints complaining that the daemon
186 you are debugging is already running, which is in fact the case).
187
188
189 That is all there is to it.  The debugger window will get some
190 output and will stop waiting for input if anything goes wrong
191 like a seg fault.  At that point, you can enter commands.
192
193 The procedure avoids modifying the test scripts and trying to
194 find pids and the such.  If you want less debug output when
195 debugging, don't set REGRESS_DEBUG=1.
196
197 ===
198
199 Also, if you run from time to time on a computer that is not connected
200 to the network, please be sure that "hostname" is set to "localhost",
201 otherwise, your tests may fail because the hostname used by Bacula's
202 ./configure cannot be properly resolved.
203
204 Anyway, you can debug where it is happening in the source code using the 
205 following example.  For example, here I get the following backtrace:
206
207 ======= Backtrace: =========
208 /lib/libc.so.6[0xb7b9d6e1]
209 /lib/libc.so.6(cfree+0x89)[0xb7b9ed79]
210 /home/kern/bacula/regress/bin/bacula-fd[0x8082ae5]
211 /home/kern/bacula/regress/bin/bacula-fd[0x8082d58]
212 /home/kern/bacula/regress/bin/bacula-fd[0x80838ac]
213 /home/kern/bacula/regress/bin/bacula-fd[0x807aa3f]
214 /home/kern/bacula/regress/bin/bacula-fd[0x807ac29]
215 /home/kern/bacula/regress/bin/bacula-fd[0x804d188]
216 /lib/libc.so.6(__libc_start_main+0xdc)[0xb7b4ef9c]
217 /home/kern/bacula/regress/bin/bacula-fd[0x804cd21]
218
219 Now to convert this into something more meaningful, kill off any hung Bacula 
220 processes.  Note the one that was running -- above you see that it was 
221 bacula-fd, then bring the same binary up in the debugger.  Then start at the 
222 first bacula-fd line, and feed the hex number to gdb as follows:
223
224 info symbol 0x8082ae5
225 free_addresses(dlist*) + 53 in section .text
226
227 info symbol 0x8082d58
228 add_address(dlist**, IPADDR::i_type, unsigned short, int, char const*, char 
229 const*, char**) + 568 in section .text
230
231 Testing a Binary Installation:
232
233 If you have installed your Bacula from a binary release such as (rpms or
234 debs), you can still run regression tests on it.  First, make sure that your
235 regression config file uses the same catalog backend as your installed
236 binaries.  Then define the variables bin and scripts variables in your config
237 file.
238
239 Example:
240 bin=/opt/bacula/bin
241 scripts=/opt/bacula/scripts
242 conf=/opt/bacula/etc
243
244 The ./scripts/prepare-other-loc will tweak the regress scripts to use
245 your binary location. You will need to run it manually once before you run any
246 regression tests.
247
248 $ scripts/prepare-other-loc
249 $ tests/backup-bacula-test
250 ...
251
252 All regression scripts must be run by hand or by calling the test scripts.  
253 These are principally scripts that begin with all_... such as all_disk_tests},
254 ./all_tests
255
256 None of the 
257 ./do_disk, ./do_all, ./nightly...  scripts will work.
258
259 If you want to switch back to running the regression scripts from source, first
260 remove the bin, scripts, and conf variables from your config file and
261 rerun the make setup step.