From d814707f54b5225075476cdc47a2d8d152626ddc Mon Sep 17 00:00:00 2001 From: Joerg Steffens Date: Thu, 29 Dec 2016 18:10:04 +0100 Subject: [PATCH] reload-test: enhanced Should now also work on other Unix platforms, not only on Linux. Also adding valid resources and checks if these are available after a reload. --- tests/reload-test | 90 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 64 insertions(+), 26 deletions(-) diff --git a/tests/reload-test b/tests/reload-test index 36be47092c9..60b392aab68 100755 --- a/tests/reload-test +++ b/tests/reload-test @@ -1,24 +1,41 @@ #!/bin/sh + +# +# test the reload and test command. # -# test the reload and test command +# Adds different (valid and invalid) statements to the Director configuration. +# Checks if invalid statements are detected by the test command +# and if reload can cope with them (not reloading the configuration). +# Also checks, if valid resources are available after reload. # + TestName="reload-test" . scripts/functions -require_linux +#require_linux scripts/cleanup scripts/copy-confs +# backup the configuration +cp $conf/bareos-dir.conf $tmp/1 + bstat=0 rstat=0 zstat=0 -detect_error() +check_config() { + # checks, if "bareos-dir -t" detects the error in the configuration $bin/bareos-dir -t $conf/bareos-dir.conf 2>&1 >> $tmp/testconf.log - if [ $? = 0 ]; then + return $? +} + +detect_error() +{ + # checks, if "bareos-dir -t" detects the error in the configuration + if check_config; then estat=1 - print_debug "Should detect error on bareos-dir.conf" + print_debug "There should be an error in bareos-dir.conf. However, bareos-dir -t does not detect it." fi } @@ -36,18 +53,45 @@ EOF print_debug "Bareos shouldn't die with a reload" fi - ls -l /proc/$pid/fd | grep bareos-dir.conf - if [ $? = 0 ]; then - estat=1 - print_debug "Should not have bareos-dir.conf open" + #ls -l /proc/$pid/fd | grep bareos-dir.conf + #if [ $? = 0 ]; then + # estat=1 + # print_debug "Should not have bareos-dir.conf open" + #fi +} + +is_client_existing() +{ + NAME="$1" + echo ".clients" | $bin/bconsole -c $conf/bconsole.conf | grep "$NAME" >/dev/null + return $? +} + +add_client_resource() +{ + NAME="$1" + + if [ -z "$NAME" ]; then + set_error "Failed: no client name given." + fi + +cat >> $conf/bareos-dir.conf<> $conf/bareos-dir.conf<> $conf/bareos-dir.conf<> $conf/bareos-dir.conf<> $conf/bareos-dir.conf</dev/null end_test +