]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
BEE Backport regress/tests/dynamic-client-address-test
authorEric Bollengier <eric.bollengier@baculasystems.com>
Wed, 2 Sep 2020 13:06:53 +0000 (15:06 +0200)
committerEric Bollengier <eric@baculasystems.com>
Tue, 1 Mar 2022 14:36:18 +0000 (15:36 +0100)
This commit is the result of the squash of the following main commits:

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Tue Jul 21 10:28:13 2020 +0200

    regress: Add copyright to regress scripts

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Wed May 1 15:22:44 2019 +0200

    regress: Add test for dynamic client address

regress/tests/dynamic-client-address-test [new file with mode: 0755]

diff --git a/regress/tests/dynamic-client-address-test b/regress/tests/dynamic-client-address-test
new file mode 100755 (executable)
index 0000000..7b633b2
--- /dev/null
@@ -0,0 +1,88 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Test the Address = "|my script" Client field
+#
+TestName="dynamic-client-address-test"
+JobName=backup
+. scripts/functions
+
+scripts/cleanup
+scripts/copy-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
+
+$bperl -e "add_attribute('$conf/bacula-dir.conf', 'Address', '|echo 127.0.0.11', 'Client')"
+
+cat <<END_OF_DATA >$tmp/bconcmds
+@output /dev/null
+messages
+@$out $tmp/log1.out
+label volume=TestVolume001 storage=File1 pool=File slot=1 drive=0
+show client
+status client
+estimate job=$JobName
+run job=$JobName yes
+wait
+messages
+@# 
+@# now do a restore
+@#
+@$out $tmp/log2.out  
+setdebug level=4 storage=File1
+restore where=$tmp/bacula-restores select all done
+yes
+wait
+messages
+quit
+END_OF_DATA
+
+run_bacula
+check_for_zombie_jobs storage=File1
+
+nb=`grep "127.0.0.11" $tmp/log1.out | wc -l`
+if [ $nb != 3 ]; then
+    print_debug "ERROR: Should find 5 times the ip address in $tmp/log1.out"
+    estat=1
+fi
+
+grep "echo 127.0.0.11" $tmp/log1.out > /dev/null
+if [ $? != 0 ]; then
+    print_debug "ERROR: Should find the command $tmp/log1.out"
+    estat=1
+fi
+
+$bperl -e "add_attribute('$conf/bacula-dir.conf', 'Address', '|aaaaa', 'Client')"
+cat <<END_OF_DATA >$tmp/bconcmds
+@$out $tmp/log3.out
+reload
+status client
+estimate job=$JobName
+messages
+quit
+END_OF_DATA
+
+run_bconsole
+
+nb=`grep "invalid address" $tmp/log3.out| wc -l`
+if [ $nb != 4 ]; then
+    print_debug "ERROR: Should find 4 times 'invalid address' in $tmp/log3.out"
+    estat=1
+fi
+
+stop_bacula
+check_two_logs
+check_restore_diff
+end_test