]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
BEE Backport regress scripts
authorEric Bollengier <eric@baculasystems.com>
Tue, 21 Jul 2020 08:49:34 +0000 (10:49 +0200)
committerEric Bollengier <eric@baculasystems.com>
Tue, 1 Mar 2022 14:36:16 +0000 (15:36 +0100)
39 files changed:
regress/tests/bad-password-test [new file with mode: 0755]
regress/tests/base-job-test
regress/tests/bconsole-test
regress/tests/bextract-test
regress/tests/big-catalog [new file with mode: 0755]
regress/tests/big-files-test
regress/tests/big-fileset-test
regress/tests/big-virtual-changer-test
regress/tests/big-vol-test
regress/tests/bls-test
regress/tests/bpipe-test
regress/tests/bpipe-unittests [new file with mode: 0755]
regress/tests/bpipe2-test [new file with mode: 0755]
regress/tests/breaddir-unittests [new file with mode: 0755]
regress/tests/broken-media-bug-2-test
regress/tests/broken-media-bug-test [changed mode: 0644->0755]
regress/tests/bscan-fast-tape
regress/tests/bscan-on-error-test [new file with mode: 0755]
regress/tests/bscan-tape
regress/tests/bscan-test
regress/tests/bsr-opt-test
regress/tests/bsr-read-test
regress/tests/bsr-skip-issue-test [new file with mode: 0755]
regress/tests/bsr-test
regress/tests/btape-fill-full-changer
regress/tests/btape-fill-full-tape
regress/tests/btape-test
regress/tests/btape-test-changer
regress/tests/btape-test-tape
regress/tests/bug-1227
regress/tests/bug-7640 [new file with mode: 0755]
regress/tests/bug-897
regress/tests/bug-fatal-test
regress/tests/bug-rwhere-7768 [new file with mode: 0755]
regress/tests/bvfs-cmds-test
regress/tests/bvfs-restore-test
regress/tests/bvfs-test
regress/tests/cancel-all-test [new file with mode: 0755]
regress/tests/copy-sqlquery-duplicate-test

diff --git a/regress/tests/bad-password-test b/regress/tests/bad-password-test
new file mode 100755 (executable)
index 0000000..09908de
--- /dev/null
@@ -0,0 +1,102 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Use incorrect name/password to connect each daemon
+# and check that we are properly kicked out
+#
+TestName="bad-password-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
+
+cat <<END_OF_DATA >$tmp/bconcmds
+setdebug level=100 trace=1 client
+setdebug level=100 trace=1 storage
+quit
+END_OF_DATA
+
+run_bacula
+
+cat <<END_OF_DATA >$tmp/bconcmds
+@output /dev/null
+messages
+@$out $tmp/log1.out
+reload
+status dir
+@$out $tmp/log2.out
+status client
+@$out $tmp/log3.out
+status storage
+quit
+END_OF_DATA
+
+run_bconsole
+
+cp $conf/*.conf $tmp/
+cp $tmp/bconcmds $tmp/bconcmds.tpl
+
+################################################################
+# Test FD with incorrect password
+cp $tmp/*.conf $conf/
+sed s:/log:/log-client: $tmp/bconcmds.tpl > $tmp/bconcmds
+
+$bperl -e "add_attribute('$conf/bacula-dir.conf', 'Password', 'xxx', 'Client')"
+run_bconsole
+
+################################################################
+# Test SD with incorrect password
+cp $tmp/*.conf $conf/
+sed s:/log:/log-sd: $tmp/bconcmds.tpl > $tmp/bconcmds
+
+$bperl -e "add_attribute('$conf/bacula-dir.conf', 'Password', 'xxx', 'Storage')"
+$bperl -e "add_attribute('$conf/bacula-dir.conf', 'Password', 'xxx', 'Autochanger')"
+run_bconsole
+
+################################################################
+# Test DIR with incorrect password
+
+cp $tmp/*.conf $conf/
+sed s:/log:/log-cons: $tmp/bconcmds.tpl > $tmp/bconcmds
+
+$bperl -e "add_attribute('$conf/bconsole.conf', 'Password', 'xxx', 'Director')"
+run_bconsole
+
+################################################################
+# Test back with good passwords
+cp $tmp/*.conf $conf/
+sed s:/log:/log-back: $tmp/bconcmds.tpl > $tmp/bconcmds
+
+run_bconsole
+
+################################################################
+# Check logs, all daemons should answer the call
+nb=`grep "Daemon started" $tmp/log-back* | wc -l`
+if [ $nb != 3 ]; then
+    print_debug "ERROR: Should find 3 daemon status in $tmp/log-back*"
+    estat=1
+fi
+
+# Threads are taking some time to cleanup the memory
+sleep 7
+
+export CHECK_JOBMEDIA=0
+export CHECK_ENCRYPTION=0
+
+stop_bacula
+end_test
index 1048a7a43ebb4b714c132ebbc96e7b92bb91d82a..39ec28ebebb4ce1707e6ff558fc6ef3f64307001 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2017 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
 #
 # Run a basejob backup of the Bacula build directory
index 4405e899975b7297d3eaf44a1fe586844307b709..6fe226c16eee5ed0b0d20285d7b30375164bbed3 100755 (executable)
@@ -1,9 +1,7 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
 #
 # Run a couple of tests with bconsole
 #
@@ -62,12 +60,18 @@ if [ $? -ne 0 ]; then
     estat=5
 fi
 
-perl -Mscripts::functions \
+$bperl \
     -e "extract_resource('$conf/bconsole.conf', 'Director', '$HOST-dir')" \
     > $tmp/1
 
 sed "s/$HOST-dir/bconsole-test-dir/" $tmp/1 >> $conf/bconsole.conf
 
+$bperl \
+     -e "add_attribute('$conf/bconsole.conf', 'HistoryFile', '$tmp/histfile', 'Director', 'bconsole-test-dir')"
+
+$bperl \
+    -e "add_attribute('$conf/bconsole.conf', 'HistoryFileSize', '200', 'Director', 'bconsole-test-dir')" \
+
 $bin/bconsole -t -c $conf/bconsole.conf > $tmp/1 < /dev/null
 if [ $? -ne 0 ]; then
     print_debug "configuration tweak failed"
@@ -116,8 +120,13 @@ if [ $? -ne 0 ]; then
     estat=13
 fi
 
+if [ ! -f $tmp/histfile ]; then
+    print_debug "bconsole history file not found"
+    estat=14
+fi
+
 # Do not try to check jobmedia with this test
 export CHECK_JOBMEDIA=0
-
+export CHECK_OPENFILE=0
 stop_bacula
 end_test
index e43c641e0d82fc10aaa44deeb20bae7566792cb5..bf03c14a32964cb1a0ad143bfec7936f93edd1a6 100755 (executable)
@@ -1,9 +1,7 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
 #
 # Run a simple backup of the Bacula build directory but 
 #   split the archive into two volumes, then build a BSR with
diff --git a/regress/tests/big-catalog b/regress/tests/big-catalog
new file mode 100755 (executable)
index 0000000..f5ebc92
--- /dev/null
@@ -0,0 +1,65 @@
+#!/usr/bin/perl -w
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Small test to setup a backup with $nb_files*2 to backup,
+# then, we can run multiple full jobs over the directory
+# and create a "large" catalog.
+#
+use strict;
+
+# use bacula functions
+use scripts::functions;
+
+my $nb_files = 250000;
+my $SD="storage=File";
+
+# initialize the configuration
+if ($FORCE_DEDUP eq 'yes') {
+    system("scripts/copy-test-confs");
+} else {
+    system("scripts/copy-fifo-confs");
+    $SD = "";
+}
+
+start_test();
+
+# cleanup the previous conf
+cleanup();
+
+# Create 500,000 files in files directory
+create_many_hardlinks("$cwd/files", $nb_files);
+
+# initialize the fileset
+add_to_backup_list("$cwd/files/");
+
+# Do not use spooling
+add_attribute("$conf/bacula-dir.conf", "SpoolData", "no", "Job");
+
+# We will run the jobs as fast as possible
+set_global_maximum_concurrent_jobs(10);
+
+start_bacula();
+
+create_bconcmds(
+    "$out $tmp/log1.out",
+    "label volume=TestVolume001 pool=Scratch $SD");
+
+run_bconsole();
+
+create_bconcmds(
+    "run job=NightlySave level=full yes",
+    "run job=NightlySave level=full yes",
+    "run job=NightlySave level=full yes",
+    "run job=NightlySave level=full yes",
+    "run job=NightlySave level=full yes",
+    "run job=NightlySave level=full yes",
+    "wait",
+    "messages");
+
+run_bconsole();
+
+stop_bacula();
+
+end_test();
index c9c942dda4fa2d2cd8299a81dcded185f4fecce5..c63f3a049f586f0cb504299f01bc686e5fdebba7 100755 (executable)
@@ -1,9 +1,7 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
 #
 #  Test if Bacula can handle big fileset
 #  This test create 2M files on a directory and
index 1167bf4049ffc9bd7e1be94873518212813ed027..bf3082d8c5f3ad0aea791312eab895f61f3636f8 100755 (executable)
@@ -1,9 +1,7 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
 #
 #  Test if Bacula can handle big fileset
 #
index 144c683b5db6544b6fe1e7bde5cd61f5802b4ba7..9445c9af170ccad8bc49313798222bd437272ddf 100755 (executable)
@@ -1,9 +1,7 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
 #
 # Run a simple backup of the Bacula build directory. Create three
 #   tapes, each in a different pool, then run two jobs both of which
index 38283779d7d203cd73cbc3475428cbc3fd8c392e..45afaffead254f144a67a2d40307fab9a89486a0 100755 (executable)
@@ -1,9 +1,7 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
 #
 # Create a big Volume > 5 GB and backup to it to test disk
 #   seeking on big volumes.  We cheat and artifically grow 
@@ -13,11 +11,7 @@ TestName="big-vol-test"
 JobName=bigvol
 . scripts/functions
 
-if test x$FORCE_CLOUD = xyes ; then
-  echo "\n=== Test $TestName skipped not compatible with Cloud  ==="
-  exit 0
-fi
-
+unset FORCE_CLOUD
 
 scripts/cleanup
 scripts/copy-test-confs
index 8df11a151668e235f0e60ebc2ef8c6822c21f1b7..ff7fa1b1bb7fd16db8e842964f1acca7679a28a8 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2017 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
 #
 # Run a simple backup of the Bacula build directory then bls
index 5c2845b32a327da9417b0e9734f6479d8ef931df..80898e8addf779420ba815cdea296d391245a228 100755 (executable)
@@ -1,9 +1,8 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2017 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
 #
-#
 # Attempt to backup and restore a file with the bpipe plugin
 #
 TestName="bpipe-test"
@@ -25,7 +24,6 @@ messages
 @$out ${cwd}/tmp/log1.out
 label storage=File1 volume=TestVolume001
 estimate job=$JobName level=Full
-setdebug level=100 client=$CLIENT
 @#setdebug level=50 traclient=$CLIENT
 run job=$JobName storage=File1 yes
 wait
@@ -72,6 +70,23 @@ if [ $nb -ne 1 ]; then
     bstat=1
 fi
 
+nb=`grep $file $tmp/list | wc -l`
+if [ $nb -ne 1 ]; then
+    print_debug "ERROR: Should find the RestoreObject for $file in $tmp/list"
+    bstat=1
+fi
+
+nb=`grep Makefile $tmp/list | wc -l`
+if [ $nb -ne 1 ]; then
+    print_debug "ERROR: Should find the RestoreObject for Makefile in $tmp/list"
+    bstat=1
+fi
+
+nb=`grep restore_command $tmp/conf | wc -l`
+if [ $nb -ne 2 ]; then
+    print_debug "ERROR: Should find the RestoreObject for Makefile and $file in $tmp/conf"
+    bstat=1
+fi
 
 cat <<EOF >$tmp/obj
 restore_command="cat >$tmp/Makefile.bak"
@@ -85,7 +100,7 @@ messages
 @$out ${cwd}/tmp/log3.out
 setdebug level=50 client=$CLIENT trace=1
 @putfile obj1 $tmp/obj
-restore where=${cwd}/tmp  select all storage=File1 done
+restore pluginrestoreconf="2:obj1" where=${cwd}/tmp  select all storage=File1 done
 yes
 wait
 setdebug level=0 client=$CLIENT trace=0
@@ -98,15 +113,16 @@ run_bconsole
 #
 # Remove plugin so we can try the restore without the plugin
 #
-mv -f ${cwd}/bin/plugins/bpipe-fd.so ${cwd}/bin/plugins/bpipe-fd.sox
+mkdir -p $tmp/empty
+$bperl -e 'add_attribute("$conf/bacula-fd.conf", "Plugin Directory", "$tmp/empty", "FileDaemon")'
 
 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
 @$out ${cwd}/tmp/log2.out
 @# 
 @# now do a restore without the plugin
 @#
-@$out ${cwd}/tmp/log2.out
 @#setdebug level=50 client=$CLIENT
+status client
 restore where=${cwd}/tmp  select all storage=File1 done
 yes
 wait
@@ -123,12 +139,24 @@ stop_bacula
 #
 # Restore plugin
 #
-mv -f ${cwd}/bin/plugins/bpipe-fd.sox ${cwd}/bin/plugins/bpipe-fd.so
+#$bperl -e 'add_attribute("$conf/bacula-fd.conf", "Plugin Directory", "$plugin", "FileDaemon")'
+
+grep "bpipe-fd" $tmp/log2.out > /dev/null
+if [ $? = 0 ]; then
+    print_debug "ERROR: Should not find plugin in client status output ($tmp/log2.out)"
+    estat=1
+fi
 
 check_two_logs
 #
 # ****FIXME**** test that all three files are restored correctly
 #
+diff ${cwd}/Makefile ${cwd}/tmp/Makefile.bak
+dstat=$?
+
+diff ${cwd}/${file} ${cwd}/tmp/${file}
+dstat=$(($dstat + $?))
+
 diff ${cwd}/tmp/@bpipe@/${file} ${cwd}/${file}
 dstat=$(($dstat + $?))
 
diff --git a/regress/tests/bpipe-unittests b/regress/tests/bpipe-unittests
new file mode 100755 (executable)
index 0000000..dd7b55b
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2018 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# This is an open_bpipe() unit test
+#
+TestName="bpipe_test"
+. scripts/functions
+make -C $src/src/tools install-unittests
+
+$bin/$TestName
+exit $?
diff --git a/regress/tests/bpipe2-test b/regress/tests/bpipe2-test
new file mode 100755 (executable)
index 0000000..f41fd8c
--- /dev/null
@@ -0,0 +1,121 @@
+#!/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 bpipe plugin and
+# play with stdout/stderr
+#
+TestName="bpipe2-test"
+JobName=pluginTest
+. scripts/functions
+
+scripts/cleanup
+scripts/copy-plugin-confs
+
+file=bpipe.sh
+rm -rf ${cwd}/tmp/*
+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
+run job=$JobName fileset=bpipe storage=File1 yes
+wait
+status client=$CLIENT
+messages
+@$out ${cwd}/tmp/log3.out
+restore comment="Should finish in error" select all done yes
+wait
+messages
+quit
+END_OF_DATA
+
+# make check_two_logs happy
+touch $tmp/log2.out
+
+run_bacula
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@$out $tmp/files
+list files jobid=1
+END_OF_DATA
+
+run_bconsole
+
+if ! test -f $tmp/bpipe.sh
+then
+    print_debug "ERROR: Unable to find $tmp/bpipe.sh"
+    estat=1
+fi
+
+$rscripts/bpipe.sh > $tmp/1 2> /dev/null
+
+if ! diff $tmp/bpipe.sh $tmp/1
+then
+    print_debug "ERROR: Found a difference in $tmp/bpipe.sh and $tmp/1"
+    estat=1
+fi
+
+str="This is a message for Bacula"
+grep "$str" $tmp/log1.out > /dev/null
+if [ $? -ne 0 ]
+then
+    print_debug "ERROR: Should find string in job log $tmp/log1.out"
+    estat=1
+fi
+
+str="This is an error message"
+grep "$str" $tmp/log3.out > /dev/null
+if [ $? -ne 0 ]
+then
+    print_debug "ERROR: Should find '$str' in $tmp/log3.out"
+    estat=1
+fi
+
+str="An other line for Bacula"
+grep "$str" $tmp/log1.out > /dev/null
+if [ $? -ne 0 ]
+then
+    print_debug "ERROR: Should find '$str' in $tmp/log1.out"
+    estat=1
+fi
+
+str="This is an error message"
+grep "$str" $tmp/log3.out > /dev/null
+if [ $? -ne 0 ]
+then
+    print_debug "ERROR: Should find '$str' in $tmp/log3.out"
+    estat=1
+fi
+
+str="Last line for Bacula"
+grep "$str" $tmp/log3.out > /dev/null
+if [ $? -ne 0 ]
+then
+    print_debug "ERROR: Should find '$str' in $tmp/log3.out"
+    estat=1
+fi
+
+str="Error closing for file /@bpipe@/bpipe-error-restore.sh"
+grep "$str" $tmp/log3.out > /dev/null
+if [ $? -ne 0 ]
+then
+    print_debug "ERROR: Should find '$str' in $tmp/log3.out"
+    estat=1
+fi
+
+str="Error closing for file /@bpipe@/error"
+grep "$str" $tmp/log1.out > /dev/null
+if [ $? -ne 0 ]
+then
+    print_debug "ERROR: Should find '$str' in $tmp/log1.out"
+    estat=1
+fi
+
+stop_bacula
+end_test
diff --git a/regress/tests/breaddir-unittests b/regress/tests/breaddir-unittests
new file mode 100755 (executable)
index 0000000..f2632aa
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2018 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# This is an breaddir() unit test
+#
+TestName="breaddir_test"
+. scripts/functions
+make -C $src/src/tools install-unittests
+
+$bin/$TestName
+exit $?
index dcdc8f07b03b39e8e4836bccc51e34c08cd63b4b..fa7b8ca8a07b76b8ec4906aeb5c0838f747c0070 100755 (executable)
@@ -1,9 +1,7 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
 #
 # Show the broken media bug(s) again. Test by Graham Keeling.
 #
@@ -43,9 +41,9 @@ echo "${cwd}/build" >${cwd}/tmp/file-list
 
 start_test
 
-echo "Creating huge ${hugefilesize}M file..."
-dd if=/dev/urandom of="$hugefile" bs=1M count="$hugefilesize"
-echo "Done"
+#echo "Creating huge ${hugefilesize}M file..."
+dd if=/dev/urandom of="$hugefile" bs=1M count="$hugefilesize" >/dev/null 2>&1
+#echo "Done"
 
 cat >tmp/bconcmds <<END_OF_DATA
 @$out /dev/null
old mode 100644 (file)
new mode 100755 (executable)
index 4e6a887..382126c
@@ -1,12 +1,7 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2017 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
-#
-# Copyright (C) 2000-2015 Kern Sibbald
-# License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
 #
 # Show the broken media bug. Test by Graham Keeling.
 #
index ba8991889d03aafd1ada530a643726dd5b0bf5e6..4f61bb1f17f3b77e8da9d856ccd0667debfe1597 100755 (executable)
@@ -1,9 +1,7 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
 #
 # Run a simple backup of the Bacula build directory using the compressed option
 #   then backup four times, each with incremental then 
diff --git a/regress/tests/bscan-on-error-test b/regress/tests/bscan-on-error-test
new file mode 100755 (executable)
index 0000000..958e599
--- /dev/null
@@ -0,0 +1,107 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Run a simple backup of the Bacula build directory
+# Then stop the SD, corrupt the volume by adding few
+# bytes at the end, and run a set of new jobs.
+#
+# bscan the volume 
+
+TestName="bscan-on-error-test"
+JobName=bscan
+. scripts/functions
+
+scripts/cleanup
+scripts/copy-test-confs
+echo "${cwd}/build" >tmp/file-list
+
+change_jobname NightlySave $JobName
+start_test
+
+cat <<END_OF_DATA >tmp/bconcmds
+@$out /dev/null
+messages
+@$out tmp/log1.out
+label storage=File1
+TestVolume001
+run job=$JobName storage=File1
+yes
+wait
+sql
+select * from JobMedia;
+
+messages
+quit
+END_OF_DATA
+
+run_bacula
+check_for_zombie_jobs storage=File1
+$bin/bacula-ctl-sd stop
+
+print_debug "Corrupting the volume..."
+echo "BB02" >> $tmp/TestVolume001
+
+$bin/bacula-ctl-sd start
+
+cat <<END_OF_DATA >tmp/bconcmds
+@$out /dev/null
+messages
+@$out tmp/log1.out
+run job=$JobName storage=File1 level=full yes
+wait
+sql
+select * from JobMedia;
+
+messages
+purge volume=TestVolume001
+quit
+END_OF_DATA
+
+run_bconsole
+
+echo "volume=TestVolume001" >$tmp/bscan.bsr
+bscan_libdbi
+
+# If the database has a password pass it to bscan
+if test "x${db_password}" = "x"; then
+  PASSWD=
+else
+  PASSWD="-P ${db_password}"
+fi
+
+if test "$debug" -eq 1 ; then
+    $bin/bscan -w working $BSCANLIBDBI -u ${db_user} -n ${db_name} $PASSWD -S -p -b $tmp/bscan.bsr -s -c $conf/bacula-sd.conf $tmp 
+else
+  $bin/bscan -w working $BSCANLIBDBI -u ${db_user} -n ${db_name} $PASSWD -S -r -p -v -b $tmp/bscan.bsr -s -c $conf/bacula-sd.conf $tmp >$tmp/log3.out 2>&1
+fi
+
+cat <<END_OF_DATA >tmp/bconcmds
+@$out /dev/null
+messages
+@$out tmp/log2.out
+restore where=$tmp/bacula-restores1 jobid=3 all done yes
+restore where=$tmp/bacula-restores2 jobid=4 all done yes
+wait
+messages
+quit
+END_OF_DATA
+
+$bin/bacula-ctl-sd stop
+$bin/bacula-ctl-sd start -p
+
+run_bconsole
+stop_bacula
+
+$rscripts/diff.pl -s $tmp/bacula-restores1/$cwd/build -d $cwd/build
+if [ $? != 0 ]; then
+    print_debug "ERROR: Unable to restore jobid 1 after bscan"
+    estat=1
+fi
+$rscripts/diff.pl -s $tmp/bacula-restores2/$cwd/build -d $cwd/build
+if [ $? != 0 ]; then
+    print_debug "ERROR: Unable to restore jobid 2 after bscan"
+    estat=1
+fi
+end_test
index cf5adc3dc604614d9df7565960bc53664b32683f..669d851eef4069a789182dfa94727d64c6ab7cd8 100755 (executable)
@@ -1,9 +1,7 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
 #
 # Run a simple backup of the Bacula build directory using the compressed option
 #   then backup four times, each with incremental then 
index 81a07de274af72308ad02b32dd150411aff47dd2..89e19714bb5a1a29548bfef68a93826e3841254c 100755 (executable)
@@ -1,9 +1,7 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
 #
 # Run a simple backup of the Bacula build directory but 
 #   split the archive into two volumes then bscan it
index 3bacfc1b93a48f68a0e7df0e7d54f3b4067aea60..08961a127a5905df3fef59d65c66d083b9d1a074 100755 (executable)
@@ -1,9 +1,7 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2018 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
 #
 # Run a simple backup of the Bacula build directory but 
 #   split the archive into two volumes, then restore
@@ -23,6 +21,9 @@ change_jobname NightlySave $JobName
 start_test
 
 MaxVolBytes=3000000
+if test x$FORCE_DEDUP = xyes; then
+   MaxVolBytes=60000
+fi
 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
 @$out /dev/null
 messages
@@ -81,7 +82,7 @@ if [ $? != 0 -o $bsrstat != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
    echo " "
    exit 1
 else
-   echo "  ===== End bsr-opt-test OK `date +%R:%S` ===== "
-   echo "  ===== End bsr-opt-test OK `date +%R:%S` ===== " >>test.out
+   echo "  ===== bsr-opt-test Bacula source OK `date +%R:%S` ===== "
+   echo "  ===== bsr-opt-test OK `date +%R:%S` ===== " >>test.out
    scripts/cleanup
 fi
index cd607b0fff2c02f5638c5519dc43762b3b4123b8..6148ae48a494a35349dfbb400195a71b22d6230a 100755 (executable)
@@ -1,9 +1,7 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
 #
 # Run a backup of a small file, then do several other backups
 #   to expand the size of a volume.  Then do a restore of the first
@@ -15,7 +13,6 @@ JobName=bsr-read
 
 scripts/cleanup
 scripts/copy-migration-confs
-scripts/prepare-disk-changer
 
 cp ${cwd}/build/configure ${cwd}/tmp
 cat ${cwd}/build/configure >> ${cwd}/tmp/configure
diff --git a/regress/tests/bsr-skip-issue-test b/regress/tests/bsr-skip-issue-test
new file mode 100755 (executable)
index 0000000..248a7e7
--- /dev/null
@@ -0,0 +1,110 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Run a simple backup of the Bacula build directory
+# then restore it.
+# Full Pool1   FileVolume001
+# Incr Pool1   FileVolume002 -> FileVolume001
+# Incr Pool1 - FileVolume001
+#
+# The 2nd incremental will spread data on a new volume
+# and on the previous volume.
+#
+#   Volume                SessTime/SessId    FI   New FI
+# rt-incr-disk1-10915     1563431298/23607   13 = 45
+# rt-incr-disk1-3547      1565527787/4       2  = 46
+# rt-incr-disk1-3547      1565527787/4       5  = 47
+# rt-incr-disk1-3547      1565527787/4       9  = 48
+# rt-incr-disk1-3547      1565527787/4      13  = 49
+# rt-incr-disk1-3547      1565527787/1151    2  = 50
+# rt-incr-disk1-10915     1565527787/1151    4  = 51
+# rt-incr-disk1-10915     1565527787/1151   10  = 52
+
+TestName="bsr-skip-issue-test"
+JobName=Vbackup
+. scripts/functions
+
+
+scripts/cleanup
+scripts/copy-migration-confs
+echo "${cwd}/build" >${cwd}/tmp/file-list
+
+$bperl -e "add_attribute('$conf/bacula-dir.conf', 'Accurate', 'yes', 'Job')"
+$bperl -e "add_attribute('$conf/bacula-dir.conf', 'SpoolData', 'no', 'Job')"
+$bperl -e "add_attribute('$conf/bacula-sd.conf', 'MaximumFileSize', '1MB', 'Device')"
+
+rm -f $cwd/build/inc1 $cwd/build/inc2 $cwd/build/diff1
+
+change_jobname NightlySave $JobName
+start_test
+
+# Write out bconsole commands
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@output /dev/null
+messages
+@$out ${cwd}/tmp/log1.out
+@#setdebug level=100 storage=File
+label storage=File volume=FileVolume001 Pool=Special
+label storage=File volume=FileVolume002 Pool=Special
+update volume=FileVolume002 maxvolbytes=1MB
+label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Full drive=0
+@# run several jobs
+@exec "sh -c 'date > ${cwd}/build/date'"
+run job=$JobName level=Full pool=Special yes
+wait
+update volume=FileVolume001 volstatus=Used
+messages
+list jobs
+END_OF_DATA
+
+run_bacula
+
+$cwd/bin/bacula-ctl-sd restart
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@$out ${cwd}/tmp/log1.out
+@exec "touch  $cwd/build/po/fr.po"
+@exec "sh -c 'cp $cwd/build/po/fr.po $cwd/build/inc1'"
+@exec "sh -c 'cp $cwd/build/po/fr.po $cwd/build/inc3'"
+run job=$JobName level=Incremental pool=Special yes
+wait mount
+update volume=FileVolume001 volstatus=Append
+mount storage=File drive=0 slot=0
+wait
+messages
+list jobs
+@exec "touch  $cwd/build/po/de.po"
+@exec "sh -c 'cp $cwd/build/po/de.po $cwd/build/inc2'"
+run job=$JobName level=Incremental pool=Special yes
+wait
+messages
+@# should Consolidate Full, Incremental
+run job=$JobName level=VirtualFull yes
+wait
+messages
+list jobs
+@# 
+@# now do a restore of the consolidated Full
+@#
+@$out $tmp/log2.out
+@#delete jobid=1,2,3 yes
+restore where=${cwd}/tmp/restore1 select all done yes
+wait
+messages
+quit
+END_OF_DATA
+
+run_bconsole
+check_for_zombie_jobs storage=File
+stop_bacula
+
+#
+# We only used one log so copy it to the second log
+#  so that any restore errors will be picked up
+#
+check_two_logs
+check_restore_diff
+
+end_test
index e88f37fed667135fd6917f9c8c72d258443cd917..1f94c979c69944d6f58065a98d4118139c32b404 100755 (executable)
@@ -1,9 +1,8 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2017 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
 #
-#
 # Run a simple backup of the Bacula build directory
 #   then restore it. Used to generate BSR files.
 #
index 1a6cb1c5f5b87d0c2e27bcacb496165cf5404198..22d827be148217e320f338b102ed84bf3b8d67ec 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2017 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
 #
 # Test the fill command in btape
index af58430f4eb341f79b02f86fa65a5badef3f1b94..1e8c9211a2fe372c6b625b44517367a276dd9813 100755 (executable)
@@ -1,9 +1,8 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2017 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
 #
-#
 # Test the fill command in btape
 #
 TestName="btape-fill-full-tape"
index 272da07647c4bedea06bf21bc7a52a10dfbe8180..46a934991d272f5e717d7c2d5f0a45f2fb08ac1d 100755 (executable)
@@ -1,9 +1,8 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2017 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
 #
-#
 # Test the test command in btape
 #
 TestName="btape-test"
index 4980bc08c02f95198fc9471df3c0ec68857b0635..f0f2efed650cf7b81f101f2f323092a04d470ffd 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2017 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
 #
 # Test the test command in btape
index e4f4f72569dcaa99a0ec04f19681c50746cf5963..d58afc5746895c42b43af369801bb91eaa48a952 100755 (executable)
@@ -1,9 +1,7 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
 #
 # Test the test command in btape
 #
@@ -20,12 +18,12 @@ change_jobname $JobName
 start_test
 
 if test "$debug" -eq 1 ; then
-  $bin/btape -c bin/bacula-sd.conf Drive-0 <<END_OF_DATA | tee ${cwd}/tmp/log1.out
+  $bin/btape -w $tmp -c bin/bacula-sd.conf Drive-0 <<END_OF_DATA | tee ${cwd}/tmp/log1.out
 test
 quit
 END_OF_DATA
 else
-  $bin/btape -c bin/bacula-sd.conf Drive-0 <<END_OF_DATA >${cwd}/tmp/log1.out 2>&1
+  $bin/btape -w $tmp -c bin/bacula-sd.conf Drive-0 <<END_OF_DATA >${cwd}/tmp/log1.out 2>&1
 test
 quit
 END_OF_DATA
@@ -47,12 +45,12 @@ cp ${cwd}/bin/bacula-sd.conf ${cwd}/tmp/1
 sed -e 's%64512%262144%' ${cwd}/tmp/1 >${cwd}/bin/bacula-sd.conf
 
 if test "$debug" -eq 1 ; then
-  $bin/btape -c bin/bacula-sd.conf Drive-0 <<END_OF_DATA | tee ${cwd}/tmp/log2.out
+  $bin/btape -w $tmp -c bin/bacula-sd.conf Drive-0 <<END_OF_DATA | tee ${cwd}/tmp/log2.out
 test
 quit
 END_OF_DATA
 else
-  $bin/btape -c bin/bacula-sd.conf Drive-0 <<END_OF_DATA >${cwd}/tmp/log2.out 2>&1
+  $bin/btape -w $tmp -c bin/bacula-sd.conf Drive-0 <<END_OF_DATA >${cwd}/tmp/log2.out 2>&1
 test
 quit
 END_OF_DATA
index 54e8e098fb01ddc8c2c777fae4e5b9afcee937a1..c84883a715c7e530cd2341cc8c99996f349cef03 100755 (executable)
@@ -1,9 +1,7 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
 #
 # Test that reproduce bug 1227
 #
diff --git a/regress/tests/bug-7640 b/regress/tests/bug-7640
new file mode 100755 (executable)
index 0000000..83a5c76
--- /dev/null
@@ -0,0 +1,124 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Run a simple backup of the Bacula build directory then create some           
+#   new files, do an Incremental and restore those two files.
+#
+TestName="bug-7640"
+JobName=bug-7640 
+. scripts/functions
+
+${rscripts}/cleanup
+${rscripts}/copy-test-confs
+echo $tmp/big >${tmp}/file-list
+echo $cwd/build/po >>${tmp}/file-list
+
+dd if=/dev/zero of=$tmp/big seek=1000000 count=1
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "SpoolData", "No", "Job")'
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "ClientRunBeforeJob", "\"sleep 30\"", "Job", "NightlySave")'
+$bperl -e 'add_attribute("$conf/bacula-sd.conf", "MaximumConcurrentJobs", "10", "Device")'
+sed -i 's/sparse=yes;//' $conf/bacula-dir.conf
+
+change_jobname NightlySave $JobName
+start_test
+
+cat <<END_OF_DATA >${tmp}/bconcmds
+@output /dev/null
+messages
+@$out ${tmp}/log1.out
+label storage=File volume=TestVolume000
+label storage=File volume=TestVolume001
+label storage=File volume=TestVolume002
+setdebug level=10 storage
+@# With VolUse=15s nothing restored for JobId 2
+@#update volume=TestVolume000 VolUse=15s
+@# With VolUse=20s both JobId 2 and 3 restore wrong size
+update volume=TestVolume000 VolUse=20s
+update volume=TestVolume001 maxvolbytes=100MB
+sql
+select VolumeName, MediaId FROM Media;
+
+run job=$JobName level=full yes
+@sleep 15
+setbandwidth limit="5000 kb/s" client=$CLIENT
+run job=$JobName level=full yes
+run job=$JobName level=full yes
+@sleep 20
+run job=$JobName level=full yes
+@sleep 10
+@#status client
+@#status dir
+@#status storage
+@sleep 10
+setbandwidth limit=0 client=$CLIENT
+wait
+messages
+sql
+select jobid, mediaid, firstindex,lastindex,volindex from JobMedia order by jobid,volindex;
+select * from JobMedia order by jobid,volindex;                                                  
+
+@$out $tmp/jobmedia2
+list jobmedia jobid=2
+@$out $tmp/jobmedia3
+list jobmedia jobid=3
+quit
+END_OF_DATA
+
+run_bacula
+check_for_zombie_jobs storage=File
+
+cat <<END_OF_DATA >${tmp}/bconcmds
+@# 
+@# now do a restore that will fail (JobId 2)
+@#
+@$out ${tmp}/log2.out
+setdebug level=10 storage=File
+@# Select by JobId 2
+restore where=${tmp}/bacula-restores storage=File
+3
+2
+cd $tmp
+m big
+done
+yes
+wait
+@# Select by JobId 3
+restore where=${tmp}/bacula-restores2 storage=File
+3
+3
+cd $tmp
+m big
+done
+yes
+wait
+@#status client
+@#status storage=File
+messages
+quit
+END_OF_DATA
+
+run_bconsole
+check_for_zombie_jobs storage=File
+stop_bacula
+
+grep -q TestVolume000 $tmp/jobmedia2 && grep -q TestVolume001 $tmp/jobmedia2 && grep -q TestVolume002 $tmp/jobmedia2
+
+if [ $? -ne 0 ]; then
+    print_debug "ERROR: should find TestVolume{000, 001 and 002} volumes for JobId 2"
+    estat=1
+fi
+
+grep -q TestVolume001 $tmp/jobmedia3 && grep -q TestVolume002 $tmp/jobmedia3
+
+if [ $? -ne 0 ]; then
+    print_debug "ERROR: should find TestVolume{001 and 002} for JobId 3"
+    estat=1
+fi
+
+$bin/bls -c $conf/bacula-sd.conf -j -V 'TestVolume000|TestVolume001|TestVolume002' FileStorage > $tmp/bls.jobs
+$bin/bls -c $conf/bacula-sd.conf -V 'TestVolume000|TestVolume001|TestVolume002' FileStorage > $tmp/bls.files
+
+check_two_logs
+end_test
index f81fc0f39f95c60de2e1f98dab24c1b2c2cbdedc..4fd1a0e594be8e6e402e9921019d4b3b9708fd51 100755 (executable)
@@ -1,9 +1,7 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
 #
 #  Test bug 897
 #
index 911d3cbd67fef24608bf5ee713ea078fe4a83a37..b610c34b5849bccd1b54955a951afaf000e9eac1 100755 (executable)
@@ -1,9 +1,7 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
 #
 #  Test RunScript
 #
diff --git a/regress/tests/bug-rwhere-7768 b/regress/tests/bug-rwhere-7768
new file mode 100755 (executable)
index 0000000..faf474b
--- /dev/null
@@ -0,0 +1,73 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Run a simple backup of the Bacula build directory then restore a subdirectory
+# to see if some extra directories are restored also.
+#
+# On Windows, it creates a problem when using RegexWhere
+#
+# RegexWhere: !F:/priv/RZB1_Swiadectwa!!i,!^!F:/priv/RESTORE!
+# Bacula is trying to restore F:/priv/ and the regex engine is
+# creating a directory "F:/priv/RESTOREF:/priv/" which is not possible
+#
+TestName="bug-rwhere-7768"
+JobName=bug-rwhere-7768
+. scripts/functions
+
+${rscripts}/cleanup
+${rscripts}/copy-test-confs
+echo $cwd/build >${tmp}/file-list
+
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "SpoolData", "No", "Job")'
+sed -i 's/!restored/restored/i' $conf/bacula-fd.conf
+
+change_jobname NightlySave $JobName
+start_test
+
+cat <<END_OF_DATA >${tmp}/bconcmds
+@output /dev/null
+messages
+@$out ${tmp}/log1.out
+label storage=File volume=TestVolume000
+run job=$JobName level=full yes
+wait
+messages
+quit
+END_OF_DATA
+
+run_bacula
+check_for_zombie_jobs storage=File
+
+cat <<END_OF_DATA >${tmp}/bconcmds
+@# 
+@# now do a restore that will fail (JobId 2)
+@#
+@$out ${tmp}/log2.out
+setdebug level=10 storage=File
+restore strip_prefix="$cwd/build" add_prefix="$cwd/tmp" where=/ storage=File
+5
+cd $cwd/build
+m po
+done
+yes
+wait
+messages
+@$out $tmp/log3.out
+list joblog jobid=2
+quit
+END_OF_DATA
+
+run_bconsole
+check_for_zombie_jobs storage=File
+stop_bacula
+
+nb=`grep $tmp $tmp/log3.out | grep -v po | wc -l`
+if [ $nb -gt 0 ]; then
+    print_debug "ERROR: Should not find a line with $tmp in $tmp/log3.out, only po directory was selected"
+    estat=1
+fi
+
+check_two_logs
+end_test
index 9d85f1f4f397adb899f23413443152418a1cddfa..760fe15e427c6baa72fc7d546f832a13ee167085 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2017 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
 #
 # Run a simple backup of the Bacula build directory then create some           
@@ -21,7 +21,7 @@ cp -p $src/src/dird/*.c $tmpsrc
 change_jobname CompressedTest $JobName
 start_test
 
-$bperl -e 'add_attribute("$conf/bacula-dir.conf", "ClientRunBeforeJob", "sleep 2", "Job")'
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "ClientRunAfterJob", "sleep 2", "Job")'
 
 cat <<END_OF_DATA >$tmp/bconcmds
 @$out /dev/null
@@ -88,7 +88,7 @@ grep '^2$' $tmp/log5.out        >/dev/null # with a limit
 estat=`expr $estat + $?`
 grep '^3$' $tmp/log6.out        >/dev/null # with a filter on the date
 estat=`expr $estat + $?`
-grep '^2$' $tmp/log7.out        >/dev/null # with a filter on the date
+grep '^1$' $tmp/log7.out        >/dev/null # with a filter on the date
 estat=`expr $estat + $?`
 
 stop_bacula
index 68acd6b31c450aef9866eec854e2f8ccbaf0a1b1..632ae45fbdb30edfdf0d9cedc3938fc503dbc3c4 100755 (executable)
@@ -1,5 +1,8 @@
 #!/bin/sh
 #
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
 # Run a simple backup of the Bacula build directory then create some           
 #   new files, do an Incremental and restore those two files.
 # test the bvfs interface
index ca4f515ef3e574efbf6d6a6078c412ec5398ced0..3cba72cd79ea1008a41f07904f274a0543844aa5 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2017 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
 #
 # Run a simple backup of the Bacula build directory then create some           
@@ -18,6 +18,8 @@ echo "${cwd}/build" >> ${tmp}/file-list
 
 mkdir -p ${tmpsrc}
 cp -p ${src}/src/dird/*.c ${tmpsrc}
+mkdir $tmpsrc/directory
+echo test > $tmpsrc/directory/1
 cd ${tmp}
 echo "${tmpsrc}/ficheriro1.txt" >restore-list
 echo "${tmpsrc}/ficheriro2.txt" >>restore-list
@@ -85,14 +87,23 @@ cd ${tmpsrc}
 cp -f ficheriro2.txt 1
 sed "s%a%b%g" 1 >ficheriro2.txt
 rm -f 1
+rm -rf directory
 cd ${cwd}
 cat <<END_OF_DATA >${tmp}/bconcmds
 @$out /dev/null
 messages
 @$out ${tmp}/log1.out
-run level=Differential job=$JobName yes
+run level=Differential accurate=yes job=$JobName yes
 wait
 messages
+@$out $tmp/log35.out
+.bvfs_update jobid=1,2,3,4
+.bvfs_lsdir jobid=1,2,3 path=$tmp/build/
+.bvfs_lsdir jobid=1,4 path=$tmp/build/
+@$out $tmp/log36.out
+sql
+SELECT * FROM PathVisibility JOIN Path USING (PathId) WHERE JobId=4;
+
 quit
 END_OF_DATA
 
@@ -148,6 +159,18 @@ rm -f ${tmpsrc}/dird_conf.c
 touch ${tmpsrc}/ficheriro2.txt
 ln ${tmpsrc}/ficheriro2.txt ${tmpsrc}/hardlink2
 
+# A linux system has 2000 symlinks
+for i in `seq 1 4000`
+do
+    cat /etc/hosts > ${tmpsrc}/file$i.txt
+    ln ${tmpsrc}/file$i.txt ${tmpsrc}/hl.$i
+done
+
+for i in `seq 1 50`
+do
+    ln ${tmpsrc}/file$i.txt ${tmpsrc}/hl2.$i
+done
+
 cat <<END_OF_DATA >${tmp}/bconcmds
 @$out /dev/null
 messages
@@ -159,9 +182,9 @@ messages
 @$out ${tmp}/log3.out
 .bvfs_update
 .bvfs_lsdir path=$tmpsrc/ jobid=1,2,3,4,5,6,7,8
-.bvfs_lsfile path=$tmpsrc/ jobid=1,2,3,4,5,6,7,8
+.bvfs_lsfile path=$tmpsrc/ jobid=1,2,3,4,5,6,7,8 limit=5000
 @$out ${tmp}/log31.out
-.bvfs_lsfile path=$tmpsrc/ jobid=1,2,3,4,5,6,7
+.bvfs_lsfile path=$tmpsrc/ jobid=1,2,3,4,5,6,7 limit=5000
 @$out ${tmp}/log32.out
 .bvfs_lsfile path=$tmpsrc/ jobid=1,2,3,4,5,6,7,8 filename=ficheriro1.txt
 quit
@@ -238,14 +261,13 @@ cat <<END_OF_DATA >${tmp}/bconcmds
 .bvfs_cleanup path=b21
 END_OF_DATA
 
-jidx=`awk -F '\t' '/ficheriro2.txt|hardlinks2/ { lstat=$5  } 
-   END { print ".bvfs_decode_lstat lstat=\"" lstat "\"" 
-} ' $tmp/log3.out | $bin/bconsole -c $conf/bconsole.conf | awk -F= '/LinkFI/ { print $2 } '`
+# We get the last of ficheriro2.txt and hardlink2 to get the LinkFI
+jidx=`awk -F '\t' '/ficheriro2.txt|hardlink2/ { print "@echo fileid=" $3; print ".bvfs_decode_lstat lstat=\"" $5 "\"" } ' $tmp/log3.out | $bin/bconsole -c $conf/bconsole.conf | awk -F= '/LinkFI=[1-9][0-9]*/ { print $2 } '`
+
+fileid=`awk -F '\t' '/ficheriro2.txt|hardlink2/ { print "@echo fileid=" $3; print ".bvfs_decode_lstat lstat=\"" $5 "\"" } ' $tmp/log3.out | $bin/bconsole -c $conf/bconsole.conf | awk -F= '/fileid=/ { fileid=$2 } /LinkFI=[1-9][0-9]*/ { print fileid } '`
 
-awk '/ficheriro2.txt/ { if (!id) { id=$3 } } /hardlink2/ { if (!id) { id=$3 } }
-  END {
-    print ".bvfs_restore jobid=1,2,3,4,5,6,7,8 hardlink=8,'$jidx' fileid=" id " path=b21"
-  } ' $tmp/log3.out >> $tmp/bconcmds
+# We take the last between ficheriro2.txt and hardlink2, and we restore both via the hardlink command
+echo ".bvfs_restore jobid=1,2,3,4,5,6,7,8 hardlink=8,$jidx fileid=$fileid path=b21" >> $tmp/bconcmds
 
 cat <<END_OF_DATA >>${tmp}/bconcmds
 @$out $tmp/log2.out
@@ -295,6 +317,17 @@ if [ $? != 0 ]; then
     estat=1
 fi
 
+nb=`grep directory/ $tmp/log35.out | wc -l`
+if [ $nb != 1 ]; then
+    print_debug "ERROR: Should find only one time directory/ in $tmp/log35.out"
+    estat=1
+fi
+
+nb=`grep directory/ $tmp/log36.out | wc -l`
+if [ $nb != 0 ]; then
+    print_debug "ERROR: Should not find directory/ in $tmp/log36.out"
+    estat=1
+fi
 
 #
 # Delete .c files because we will only restored the txt files
diff --git a/regress/tests/cancel-all-test b/regress/tests/cancel-all-test
new file mode 100755 (executable)
index 0000000..8405c7c
--- /dev/null
@@ -0,0 +1,87 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Run a simple backup of the Bacula build directory
+# and test the cancel all command
+#
+# We test "cancel all" => no/. nothing canceled, restore possible
+# We test "cancel all" => yes and "cancel all yes", two canceled jobs
+#
+TestName="cancel-all-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
+
+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
+setbandwidth limit=2MB/s client
+run job=$JobName yes
+@sleep 2
+cancel all
+no
+cancel all
+.
+setbandwidth limit=100MB/s client
+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
+@$out $tmp/log3.out
+setbandwidth limit=2MB/s client
+run job=$JobName level=full yes
+@sleep 2
+cancel all
+yes
+setbandwidth limit=100MB/s client
+wait
+messages
+@$out $tmp/log3.out
+setbandwidth limit=2MB/s client
+run job=$JobName level=full yes
+@sleep 2
+cancel all yes
+setbandwidth limit=100MB/s client
+wait
+messages
+quit
+END_OF_DATA
+
+run_bacula
+check_for_zombie_jobs storage=File1
+stop_bacula
+
+nb=`grep "Backup Canceled" $tmp/log3.out | wc -l`
+if [ $nb != 2 ]; then
+    print_debug "ERROR: Should find two jobs canceled in $tmp/log3.out"
+    estat=1
+fi
+
+check_two_logs
+check_restore_diff
+end_test
index ea78754065ac0334577743db322c5b76d1e05361..ae49539ade3acd3e235afd7b1ef5390230f5e9ee 100755 (executable)
@@ -1,5 +1,8 @@
 #!/bin/sh
 #
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
 # Run a simple backup of the Bacula build directory then copy it
 #   to another device.
 #