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