]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/bconsole-test
baculum: Add module to check resource dependencies
[bacula/bacula] / regress / tests / bconsole-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 # Run a couple of tests with bconsole
9 #
10 TestName="bconsole-test"
11 JobName=backup
12 . scripts/functions
13
14 scripts/cleanup
15 scripts/copy-test-confs
16
17 #
18 # Zap out any schedule in default conf file so that
19 #  it doesn't start during our test
20 #
21 outf="$tmp/sed_tmp"
22 echo "s%  Schedule =%# Schedule =%g" >${outf}
23 cp $scripts/bacula-dir.conf $tmp/1
24 sed -f ${outf} $tmp/1 >$scripts/bacula-dir.conf
25
26 change_jobname BackupClient1 $JobName
27 start_test
28
29 # start the director
30 touch $tmp/bconcmds
31 run_bacula
32
33 print_debug "Test bconsole -l and -D with a single director definition"
34
35 $bin/bconsole -c $conf/bconsole.conf -l > $tmp/1 < /dev/null
36 if [ $? -ne 0 ]; then
37     print_debug "Bconsole doesn't support -l option"
38     estat=1
39 fi
40
41 nb=`cat $tmp/1 | wc -l`
42 if [ "$nb" -ne 1 ]; then
43     print_debug "Found more than one director in bconsole -l output"
44     estat=2
45 fi
46
47 grep "$HOST-dir" $tmp/1 > /dev/null
48 if [ $? -ne 0 ]; then
49     print_debug "bconsole -l option doesn't display $HOST-dir"
50     estat=3
51 fi
52
53 echo quit | $bin/bconsole -c $conf/bconsole.conf -D "this is a test" > $tmp/1
54 if [ $? -eq 0 ]; then
55     print_debug "Bconsole should abort if selected directors isn't defined"
56     estat=4
57 fi
58
59 echo quit | $bin/bconsole -c $conf/bconsole.conf -D "$HOST-dir" > $tmp/1
60 if [ $? -ne 0 ]; then
61     print_debug "bconsole doesn't connect to $HOST-dir"
62     estat=5
63 fi
64
65 perl -Mscripts::functions \
66     -e "extract_resource('$conf/bconsole.conf', 'Director', '$HOST-dir')" \
67     > $tmp/1
68
69 sed "s/$HOST-dir/bconsole-test-dir/" $tmp/1 >> $conf/bconsole.conf
70
71 $bin/bconsole -t -c $conf/bconsole.conf > $tmp/1 < /dev/null
72 if [ $? -ne 0 ]; then
73     print_debug "configuration tweak failed"
74     estat=6
75 fi
76
77 $bin/bconsole -c $conf/bconsole.conf -l > $tmp/1 < /dev/null
78 if [ $? -ne 0 ]; then
79     print_debug "Bconsole doesn't support -l option"
80     estat=7
81 fi
82
83 nb=`cat $tmp/1 | wc -l`
84 if [ "$nb" -ne 2 ]; then
85     print_debug "Found more than one director in bconsole -l output"
86     estat=8
87 fi
88
89 grep "$HOST-dir" $tmp/1 > /dev/null
90 if [ $? -ne 0 ]; then
91     print_debug "bconsole -l option doesn't display $HOST-dir"
92     estat=9
93 fi
94
95 grep "bconsole-test-dir" $tmp/1 > /dev/null
96 if [ $? -ne 0 ]; then
97     print_debug "bconsole -l option doesn't display bconsole-test-dir"
98     estat=10
99 fi
100
101 echo quit | $bin/bconsole -c $conf/bconsole.conf -D "this is a test" > $tmp/1
102 if [ $? -eq 0 ]; then
103     print_debug "Bconsole should abort if selected directors isn't defined"
104     estat=11
105 fi
106
107 echo quit | $bin/bconsole -c $conf/bconsole.conf -D "$HOST-dir" > $tmp/1
108 if [ $? -ne 0 ]; then
109     print_debug "bconsole doesn't connect to $HOST-dir"
110     estat=12
111 fi
112
113 echo quit | $bin/bconsole -c $conf/bconsole.conf -D "bconsole-test-dir" > $tmp/1
114 if [ $? -ne 0 ]; then
115     print_debug "bconsole doesn't connect to bconsole-test-dir"
116     estat=13
117 fi
118
119 # Do not try to check jobmedia with this test
120 export CHECK_JOBMEDIA=0
121
122 stop_bacula
123 end_test