3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
8 # Run a couple of tests with bconsole
10 TestName="bconsole-test"
15 scripts/copy-test-confs
18 # Zap out any schedule in default conf file so that
19 # it doesn't start during our test
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
26 change_jobname BackupClient1 $JobName
33 print_debug "Test bconsole -l and -D with a single director definition"
35 $bin/bconsole -c $conf/bconsole.conf -l > $tmp/1 < /dev/null
37 print_debug "Bconsole doesn't support -l option"
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"
47 grep "$HOST-dir" $tmp/1 > /dev/null
49 print_debug "bconsole -l option doesn't display $HOST-dir"
53 echo quit | $bin/bconsole -c $conf/bconsole.conf -D "this is a test" > $tmp/1
55 print_debug "Bconsole should abort if selected directors isn't defined"
59 echo quit | $bin/bconsole -c $conf/bconsole.conf -D "$HOST-dir" > $tmp/1
61 print_debug "bconsole doesn't connect to $HOST-dir"
65 perl -Mscripts::functions \
66 -e "extract_resource('$conf/bconsole.conf', 'Director', '$HOST-dir')" \
69 sed "s/$HOST-dir/bconsole-test-dir/" $tmp/1 >> $conf/bconsole.conf
71 $bin/bconsole -t -c $conf/bconsole.conf > $tmp/1 < /dev/null
73 print_debug "configuration tweak failed"
77 $bin/bconsole -c $conf/bconsole.conf -l > $tmp/1 < /dev/null
79 print_debug "Bconsole doesn't support -l option"
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"
89 grep "$HOST-dir" $tmp/1 > /dev/null
91 print_debug "bconsole -l option doesn't display $HOST-dir"
95 grep "bconsole-test-dir" $tmp/1 > /dev/null
97 print_debug "bconsole -l option doesn't display bconsole-test-dir"
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"
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"
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"
119 # Do not try to check jobmedia with this test
120 export CHECK_JOBMEDIA=0