]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
BEE Backport regress/tests/opt-plugin-test
authorKern Sibbald <kern@sibbald.com>
Wed, 2 Sep 2020 13:30:24 +0000 (15:30 +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 27 10:14:25 2015 +0200

    regress: Tweak opt-plugin-test to suppress bad output

Author: Kern Sibbald <kern@sibbald.com>
Date:   Tue Oct 23 18:52:29 2012 +0200

    Drop previous regression test output

Author: Kern Sibbald <kern@sibbald.com>
Date:   Tue Dec 27 10:50:32 2011 +0100

    Suppress output in opt-plugin regression if no error

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Fri Nov 11 09:06:17 2011 +0100

    regress: Add new test in all-disks-test

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Thu Nov 10 16:18:48 2011 +0100

    regress: Add test for Options { Plugin= } with rot13

regress/tests/opt-plugin-test [new file with mode: 0755]

diff --git a/regress/tests/opt-plugin-test b/regress/tests/opt-plugin-test
new file mode 100755 (executable)
index 0000000..81f63f5
--- /dev/null
@@ -0,0 +1,112 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Attempt to backup and restore a file with the rot13 option plugin
+#
+TestName="opt-plugin-test"
+JobName=optPluginTest
+. scripts/functions
+
+scripts/cleanup
+scripts/copy-plugin-confs
+make -C $src/src/plugins/fd install-test-plugin 1>${cwd}/tmp/log1.out 2>${cwd}/tmp/log1.out
+if [ $? != 0 ]; then
+  cat ${cwd}/tmp/log1.out
+  exit 1
+fi
+
+rm -rf ${cwd}/tmp/*
+echo "${cwd}/DartTestfile.txt" >${cwd}/tmp/file-list
+echo "${cwd}/README" >>${cwd}/tmp/file-list
+
+start_test
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@output /dev/null
+messages
+@$out ${cwd}/tmp/log1.out
+label storage=File1 volume=TestVolume001
+setdebug level=150 client=$CLIENT
+estimate job=$JobName level=Full
+run job=$JobName storage=File1 yes
+wait
+status client=$CLIENT
+messages
+quit
+END_OF_DATA
+
+
+run_bacula
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+messages
+@# 
+@# now do a restore
+@#
+@$out ${cwd}/tmp/log2.out
+setdebug level=50 client=$CLIENT
+restore fileset="Plugin Option Set" where=${cwd}/tmp  select all storage=File1 done
+yes
+wait
+setdebug level=0 client=$CLIENT
+messages
+quit
+END_OF_DATA
+
+run_bconsole
+
+stop_bacula
+
+
+diff ${cwd}/DartTestfile.txt ${cwd}/tmp/$cwd/DartTestfile.txt > /dev/null
+estat=$?
+
+#
+# Remove plugin so we can try the restore without the plugin
+#
+mv -f ${cwd}/bin/plugins/rot13-fd.so ${cwd}/bin/plugins/rot13-fd.sox 1>/dev/null 2>/dev/null
+rm -rf $cwd/tmp/$cwd 
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@$out ${cwd}/tmp/log2.out
+@# remove plugin
+@exec "sh -c 'rm -f ${cwd}/bin/plugins/bpipe-fd.so'"
+@# 
+@# now do a restore without the plugin
+@#
+@$out ${cwd}/tmp/log2.out
+@#setdebug level=50 client=$CLIENT
+restore fileset="Plugin Option Set" where=${cwd}/tmp  select all storage=File1 done
+yes
+wait
+messages
+quit
+END_OF_DATA
+
+run_bacula -d50
+run_bconsole
+
+check_for_zombie_jobs storage=File1
+stop_bacula
+
+# the file should be encrypted
+test -f $cwd/tmp/$cwd/DartTestfile.txt
+diff ${cwd}/DartTestfile.txt ${cwd}/tmp/$cwd/DartTestfile.txt > /dev/null
+if [ $? = 0 ]; then
+    estat=1
+fi
+
+
+#
+# Restore plugin
+#
+mv -f ${cwd}/bin/plugins/rot13-fd.sox ${cwd}/bin/plugins/rot13-fd.so
+
+check_two_logs
+#
+# ****FIXME**** test that all three files are restored correctly
+#
+
+end_test