]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
regress: Add procedure to test verify plugin
authorEric Bollengier <eric@baculasystems.com>
Thu, 7 Oct 2021 16:47:13 +0000 (18:47 +0200)
committerEric Bollengier <eric@baculasystems.com>
Wed, 6 Sep 2023 07:49:01 +0000 (09:49 +0200)
regress/scripts/new-test-bacula-dir.conf.in
regress/tests/verify-plugin-test [new file with mode: 0755]

index 6f37a8946655ea2301fb2c5e7bf166cb5b91ad46..a8520f245fca8865f97edf86e00a02fa96b8e614 100644 (file)
@@ -148,7 +148,7 @@ Job {
 }
 
 Job {
-  Name = "VerifyData"
+  Name = VerifyData
   Type = Verify
   Level = Data
   Client=@hostname@-fd 
@@ -863,14 +863,14 @@ Messages {
   operatorcommand = "@sbindir@/bsmtp -h localhost -f \"\(Bacula regression\) %r\" -s \"Regression: Intervention needed for %j\" %r"
 # MailOnError = @job_email@ = all
 # operator = @job_email@ = mount
-  console = all, !skipped, !terminate, !restored
+  console = all, !skipped, !terminate, !restored, !verified
 #
 # WARNING! the following will create a file that you must cycle from
 #          time to time as it will grow indefinitely. However, it will
 #          also keep all your messages if the scroll off the console.
 #
-  append = "@working_dir@/log" = all, !skipped
-  catalog = all, !skipped
+  append = "@working_dir@/log" = all, !skipped, !verified
+  catalog = all, !skipped, !verified
 }
 
 Messages {
diff --git a/regress/tests/verify-plugin-test b/regress/tests/verify-plugin-test
new file mode 100755 (executable)
index 0000000..47bb7a3
--- /dev/null
@@ -0,0 +1,121 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Run test-verify-fd.  Note, this plugin is for testing
+#   new features and probably should not be run in normal
+#   testing
+#
+TestName="verify-plugin-test"
+JobName=TestPluginTest
+. scripts/functions
+
+scripts/cleanup
+scripts/copy-test-confs
+file=encrypt-bug.jpg
+rm -rf ${cwd}/tmp/*
+echo $tmp/file > ${cwd}/tmp/file-list
+echo "${cwd}/build/src" >>${cwd}/tmp/file-list
+echo $tmp/file >> ${cwd}/tmp/file-list
+
+# To see the actual files verified
+#sed -i "s/, !verified//" $conf/bacula-dir.conf
+
+echo "Hello PATTERNTESTVERIFY" > $tmp/file
+
+# Build and install the test plugin
+cd ${cwd}/build/src/plugins/fd
+make install-test-plugin
+if [ $? -ne 0 ]; then
+   print_debug "Failed to build or install test plugin!"
+   exit 1
+fi
+
+cd ${cwd}
+
+start_test
+
+$bperl -e "add_attribute('$conf/bacula-dir.conf', 'PluginOptions', 'test-verify: pattern=PATTERNTESTVERIFY', 'Job', 'VerifyData')"
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@output /dev/null
+messages
+@$out ${cwd}/tmp/log1.out
+label storage=File1 volume=TestVolume001
+run job=MonsterSave storage=File1 yes
+wait
+status client=$CLIENT
+messages
+quit
+END_OF_DATA
+
+run_bacula
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@$out ${cwd}/tmp/log2.out
+run job=VerifyData jobid=1 storage=File1
+yes
+wait
+messages
+quit
+END_OF_DATA
+
+run_bconsole
+
+$bperl -e "add_attribute('$conf/bacula-dir.conf', 'PluginOptions', 'xxx:', 'Job', 'VerifyData')"
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@$out ${cwd}/tmp/log3.out
+reload
+run job=VerifyData jobid=1 storage=File1
+yes
+wait
+messages
+quit
+END_OF_DATA
+
+run_bconsole
+
+nb=`grep "matching pattern" $tmp/log2.out | wc -l`
+if [ $nb != 2 ]; then
+    print_debug "ERROR: Should find 2 matching pattern in $tmp/log2.out"
+    estat=2
+fi
+
+grep "$tmp/file matching pattern" $tmp/log2.out > /dev/null
+if [ $? != 0 ]; then
+    print_debug "ERROR: Should find a matching pattern in $tmp/log2.out"
+    estat=1
+fi
+
+grep "Got plugin command" $tmp/log2.out > /dev/null
+if [ $? != 0 ]; then
+    print_debug "ERROR: Should find plugin activation in $tmp/log2.out"
+    estat=1
+fi
+
+################################################################
+# The plugin is not started via a plugin command
+
+nb=`grep "matching pattern" $tmp/log3.out | wc -l`
+if [ $nb != 0 ]; then
+    print_debug "ERROR: Should find 0 matching pattern in $tmp/log3.out"
+    estat=2
+fi
+
+grep "$tmp/file matching pattern" $tmp/log3.out > /dev/null
+if [ $? = 0 ]; then
+    print_debug "ERROR: Should NOT find a matching pattern in $tmp/log3.out"
+    estat=1
+fi
+
+grep "Got plugin command" $tmp/log3.out > /dev/null
+if [ $? = 0 ]; then
+    print_debug "ERROR: Should NOT find plugin activation in $tmp/log3.out"
+    estat=1
+fi
+
+
+stop_bacula
+end_test