From 5f83cbe0e3b044d98346e7db20c71fca887c3873 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Wed, 24 Feb 2010 18:24:04 +0100 Subject: [PATCH] regress: add bconsole test --- regress/tests/bconsole-test | 116 ++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100755 regress/tests/bconsole-test diff --git a/regress/tests/bconsole-test b/regress/tests/bconsole-test new file mode 100755 index 0000000000..83b5487261 --- /dev/null +++ b/regress/tests/bconsole-test @@ -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 -- 2.39.5