]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/reload-test
Pull regression truncate-test from Branch-9.1
[bacula/bacula] / regress / tests / reload-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 # test the reload and test command
9 #
10 TestName="reload-test"
11 . scripts/functions
12
13 require_linux
14 scripts/cleanup
15 scripts/copy-confs
16
17 bstat=0
18 rstat=0
19 zstat=0
20
21 detect_error()
22 {
23     $bin/bacula-dir -t $conf/bacula-dir.conf 2>&1 >> $tmp/testconf.log
24     if [ $? = 0 ]; then
25         estat=1
26         print_debug "ERROR: Should detect error on bacula-dir.conf"
27     fi
28 }
29
30 do_reload()
31 {
32     cat > $tmp/bcons <<EOF
33 reload
34 messages
35 EOF
36     cat $tmp/bcons | $bin/bconsole -c $conf/bconsole.conf 2>&1 | tee -a $tmp/reload.log
37
38     ps $pid > /dev/null
39     if [ $? != 0 ]; then
40         estat=1
41         print_debug "ERROR: Bacula shouldn't die with a reload"
42     fi
43
44     ls -l /proc/$pid/fd | grep bacula-dir.conf
45     if [ $? = 0 ]; then
46         estat=1
47         print_debug "ERROR: Should not have bacula-dir.conf open"
48     fi
49 }
50
51 start_test
52
53 # should be ok
54 $bin/bacula-dir -t $conf/bacula-dir.conf
55 if [ $? != 0 ]; then
56     estat=1
57     print_debug "ERROR: Error on bacula-dir.conf"
58 fi
59
60 $bin/bacula-ctl-dir start >/dev/null
61 pid=`cat $working/bacula-dir.$BASEPORT.pid`
62
63 echo "bacula-dir pid is $pid"
64
65 sleep 2
66
67 ls -l /proc/$pid/fd | grep bacula-dir.conf
68 if [ $? = 0 ]; then
69     estat=1
70     print_debug "ERROR: Should not have bacula-dir.conf open"
71 fi
72
73 # should work well
74 do_reload
75
76 # backup the configuration
77 cp $conf/bacula-dir.conf $tmp/1
78 cat >> $conf/bacula-dir.conf<<EOF
79 This is an error
80 EOF
81
82 detect_error
83 do_reload
84
85 cp $tmp/1 $conf/bacula-dir.conf
86 cat >> $conf/bacula-dir.conf<<EOF
87 Job {
88 }
89 EOF
90
91 detect_error
92 do_reload
93
94 cp $tmp/1 $conf/bacula-dir.conf
95 cat >> $conf/bacula-dir.conf<<EOF
96 Director {
97   Name = second-dir
98   DIRport = 1101                # where we listen for UA connections
99   QueryFile = "/tmp/regress/bin/query.sql"
100   WorkingDirectory = "/tmp/regress/working"
101   PidDirectory = "/tmp/regress/working"
102   Maximum Concurrent Jobs = 1
103   Password = "xxx"         # Console password
104   Messages = Daemon
105 }
106 EOF
107
108 detect_error
109 do_reload
110
111 cp $tmp/1 $conf/bacula-dir.conf
112 cat >> $conf/bacula-dir.conf<<EOF
113 Job {
114   Name = "BackupClient1"
115   JobDefs = "DefaultJob"
116   Write Bootstrap = "/tmp/regress/working/Client1.bsr"
117 }
118 Job {
119   Name = "BackupClient1"
120   JobDefs = "DefaultJob"
121   Write Bootstrap = "/tmp/regress/working/Client1.bsr"
122 }
123 EOF
124
125 detect_error
126 do_reload
127
128 $bin/bacula-ctl-dir stop >/dev/null
129
130 end_test