]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
regress: Add simple plugin-objects test
authorMichal Rakowski <michal.rakowski@baculasystems.com>
Wed, 16 Sep 2020 05:54:16 +0000 (07:54 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:02:57 +0000 (09:02 +0100)
regress/tests/plugin-objects-test [new file with mode: 0755]

diff --git a/regress/tests/plugin-objects-test b/regress/tests/plugin-objects-test
new file mode 100755 (executable)
index 0000000..4d8d9ec
--- /dev/null
@@ -0,0 +1,84 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Test if Plugin Objects are created and correctly deleted during volume purging.
+#
+TestName="plugin-object-test"
+JobName=pluginTest
+. scripts/functions
+
+scripts/cleanup
+scripts/copy-plugin-confs
+make -C $src/src/plugins/fd install install-test-plugin
+if [ $? -ne 0 ]; then
+    print_debug "Failed to build and install test-plugin!"
+    exit 1
+fi
+
+file=encrypt-bug.jpg
+rm -rf ${cwd}/tmp/*
+echo "${cwd}/README" >${cwd}/tmp/file-list
+
+$bperl -e 'add_attribute("$conf/bacula-sd.conf", "MaximumFileIndex", "48KB", "Device")'
+
+start_test
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@output /dev/null
+messages
+@$out ${cwd}/tmp/log1.out
+label storage=File1 volume=TestVolume001
+run job=TestPluginTest storage=File1 yes
+wait
+status client=$CLIENT
+messages
+@$out ${cwd}/tmp/log2.out
+list objects
+@$out ${cwd}/tmp/log3.out
+llist objects
+quit
+END_OF_DATA
+
+run_bacula
+
+#TODO add check for fileds in llist output
+objects_lines=`cat ${cwd}/tmp/log2.out | grep 'test-obj-type' | wc -l`
+if [ ${objects_lines} -ne 2 ]; then
+   estat=1
+   print_debug "Wrong plugin objects count found in output: ${objects_lines}, expected 2"
+fi
+
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+messages
+@# now do a restore
+@$out ${cwd}/tmp/log4.out
+restore where=${cwd}/tmp select all storage=File1 done
+yes
+wait
+messages
+quit
+END_OF_DATA
+
+run_bconsole
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@output /dev/null
+messages
+@$out ${cwd}/tmp/log5.out
+purge volume=TestVolume001
+@$out ${cwd}/tmp/log6.out
+list objects
+END_OF_DATA
+
+run_bconsole
+
+objects_lines=`cat ${cwd}/tmp/log6.out | grep 'test-obj-type' | wc -l`
+if [ ${objects_lines} -ne 0 ]; then
+   estat=1
+   print_debug "Wrong plugin objects count found in output: ${objects_lines}, expected 0"
+fi
+
+end_test