]> git.sur5r.net Git - bacula/bacula/commitdiff
regress: add bconsole test
authorEric Bollengier <eric@eb.homelinux.org>
Wed, 24 Feb 2010 17:24:04 +0000 (18:24 +0100)
committerEric Bollengier <eric@eb.homelinux.org>
Mon, 2 Aug 2010 14:49:34 +0000 (16:49 +0200)
regress/tests/bconsole-test [new file with mode: 0755]

diff --git a/regress/tests/bconsole-test b/regress/tests/bconsole-test
new file mode 100755 (executable)
index 0000000..83b5487
--- /dev/null
@@ -0,0 +1,116 @@
+#!/bin/sh
+#
+# Run a couple of tests with bconsole
+#
+TestName="bconsole-test"
+JobName=backup
+. scripts/functions
+
+scripts/cleanup
+scripts/copy-test-confs
+
+#
+# Zap out any schedule in default conf file so that
+#  it doesn't start during our test
+#
+outf="$tmp/sed_tmp"
+echo "s%  Schedule =%# Schedule =%g" >${outf}
+cp $scripts/bacula-dir.conf $tmp/1
+sed -f ${outf} $tmp/1 >$scripts/bacula-dir.conf
+
+change_jobname BackupClient1 $JobName
+start_test
+
+# start the director
+touch $tmp/bconcmds
+run_bacula
+
+print_debug "Test bconsole -l and -D with a single director definition"
+
+$bin/bconsole -c $conf/bconsole.conf -l > $tmp/1
+if [ $? -ne 0 ]; then
+    print_debug "Bconsole doesn't support -l option"
+    estat=1
+fi
+
+nb=`cat $tmp/1 | wc -l`
+if [ "$nb" -ne 1 ]; then
+    print_debug "Found more than one director in bconsole -l output"
+    estat=2
+fi
+
+grep "$HOST-dir" $tmp/1 > /dev/null
+if [ $? -ne 0 ]; then
+    print_debug "bconsole -l option doesn't display $HOST-dir"
+    estat=3
+fi
+
+echo quit | $bin/bconsole -c $conf/bconsole.conf -D "this is a test" > $tmp/1
+if [ $? -eq 0 ]; then
+    print_debug "Bconsole should abort if selected directors isn't defined"
+    estat=4
+fi
+
+echo quit | $bin/bconsole -c $conf/bconsole.conf -D "$HOST-dir" > $tmp/1
+if [ $? -ne 0 ]; then
+    print_debug "bconsole doesn't connect to $HOST-dir"
+    estat=5
+fi
+
+perl -Mscripts::functions \
+    -e "extract_resource('$conf/bconsole.conf', 'Director', '$HOST-dir')" \
+    > $tmp/1
+
+sed "s/$HOST-dir/bconsole-test-dir/" $tmp/1 >> $conf/bconsole.conf
+
+$bin/bconsole -t -c $conf/bconsole.conf > $tmp/1
+if [ $? -ne 0 ]; then
+    print_debug "configuration tweak failed"
+    estat=6
+fi
+
+$bin/bconsole -c $conf/bconsole.conf -l > $tmp/1
+if [ $? -ne 0 ]; then
+    print_debug "Bconsole doesn't support -l option"
+    estat=7
+fi
+
+nb=`cat $tmp/1 | wc -l`
+if [ "$nb" -ne 2 ]; then
+    print_debug "Found more than one director in bconsole -l output"
+    estat=8
+fi
+
+grep "$HOST-dir" $tmp/1 > /dev/null
+if [ $? -ne 0 ]; then
+    print_debug "bconsole -l option doesn't display $HOST-dir"
+    estat=9
+fi
+
+grep "bconsole-test-dir" $tmp/1 > /dev/null
+if [ $? -ne 0 ]; then
+    print_debug "bconsole -l option doesn't display bconsole-test-dir"
+    estat=10
+fi
+
+echo quit | $bin/bconsole -c $conf/bconsole.conf -D "this is a test" > $tmp/1
+if [ $? -eq 0 ]; then
+    print_debug "Bconsole should abort if selected directors isn't defined"
+    estat=11
+fi
+
+echo quit | $bin/bconsole -c $conf/bconsole.conf -D "$HOST-dir" > $tmp/1
+if [ $? -ne 0 ]; then
+    print_debug "bconsole doesn't connect to $HOST-dir"
+    estat=12
+fi
+
+echo quit | $bin/bconsole -c $conf/bconsole.conf -D "bconsole-test-dir" > $tmp/1
+if [ $? -ne 0 ]; then
+    print_debug "bconsole doesn't connect to bconsole-test-dir"
+    estat=13
+fi
+
+
+stop_bacula
+end_test