]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
BEE Backport regress/tests/restore-stop-read5-test
authorEric Bollengier <eric@baculasystems.com>
Wed, 2 Sep 2020 13:32:41 +0000 (15:32 +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:   Tue Dec 20 15:23:09 2016 +0100

    regress: Remove some FORCE_CLOUD checks when it's not necessary and add new tests

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Mon May 18 08:35:43 2015 +0200

    regress: Update restore-stop-read5-test

Author: Kern Sibbald <kern@sibbald.com>
Date:   Sat May 16 11:45:06 2015 +0200

    Tweak restore-stop tests

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Fri May 15 16:24:39 2015 +0200

    regress: Add test for #876 where a restore reads too far on tape

regress/tests/restore-stop-read5-test [new file with mode: 0755]

diff --git a/regress/tests/restore-stop-read5-test b/regress/tests/restore-stop-read5-test
new file mode 100755 (executable)
index 0000000..7ef395a
--- /dev/null
@@ -0,0 +1,140 @@
+#!/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 one file and see if we read too much
+#   data
+#
+TestName="restore-stop-read5-test"
+JobName=backup
+. scripts/functions
+
+scripts/cleanup
+scripts/copy-confs
+
+require_disk
+
+#
+# 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
+
+#$bperl -e "add_attribute('$conf/bacula-sd.conf', 'MaximumFileSize', '10MB', 'Device')"
+#$bperl -e "add_attribute('$conf/bacula-dir.conf', 'MaximumVolumeBytes', '50MB', 'Pool')"
+$bperl -e "add_attribute('$conf/bacula-dir.conf', 'Label Format', 'Vol2-', 'Pool', 'Default')"
+$bperl -e "add_attribute('$conf/bacula-dir.conf', 'FileSet', 'FewFiles', 'Job', 'BackupClient1')"
+
+cat >> $conf/bacula-dir.conf <<EOF
+FileSet {
+  Name = "FewFiles"
+  Include {
+    File = "$cwd/build/0.dat"
+    File = "$cwd/build/1.dat"
+    File = "$cwd/build/11.dat"
+    File = "$cwd/build/12.dat"
+    File = "$cwd/build/13.dat"
+    File = "$cwd/build/2.dat"
+    File = "$cwd/build/3.dat"
+    File = "$cwd/build/4.dat"
+    File = "$cwd/build/5.dat"
+    File = "$cwd/build/src"
+  }
+}
+EOF
+director=`$bperl -e "get_dirname()"`
+
+(
+dd if=/dev/zero of=$cwd/build/0.dat count=1 seek=500
+dd if=/dev/zero of=$cwd/build/1.dat count=1 seek=50000
+dd if=/dev/zero of=$cwd/build/11.dat count=1 seek=500
+dd if=/dev/zero of=$cwd/build/12.dat count=1 seek=500
+dd if=/dev/zero of=$cwd/build/13.dat count=1 seek=500
+dd if=/dev/zero of=$cwd/build/2.dat count=1 seek=50000
+dd if=/dev/zero of=$cwd/build/3.dat count=1 seek=20000
+dd if=/dev/zero of=$cwd/build/4.dat count=1 seek=50000
+dd if=/dev/zero of=$cwd/build/5.dat count=1 seek=50000
+) 2> /dev/null
+trap "rm -f $cwd/build/*.dat" EXIT
+
+change_jobname BackupClient1 $JobName
+start_test
+
+cat <<END_OF_DATA >$tmp/bconcmds
+@$out /dev/null
+messages
+@$out $tmp/log1.out
+run job=$JobName storage=File1 yes
+wait
+messages
+END_OF_DATA
+
+run_bacula
+
+touch $cwd/build/4.dat
+touch $cwd/build/5.dat
+
+cat <<END_OF_DATA >$tmp/bconcmds
+@$out /dev/null
+messages
+@$out $tmp/log1.out
+run job=$JobName storage=File2 level=Incremental Pool=Default yes
+wait
+messages
+END_OF_DATA
+
+run_bconsole
+
+cat <<END_OF_DATA >$tmp/bconcmds
+@$out $tmp/log2.out  
+@# 
+@# now do a restore
+@#
+setdebug level=500 trace=1 storage=File1
+restore where=$tmp/bacula-restores
+5
+cd "$cwd/build"
+mark "1.dat"
+mark "11.dat"
+mark "12.dat"
+mark "13.dat"
+mark "4.dat"
+done
+@sleep 2
+@exec "cp $working/$director.restore.1.bsr $working/restore1.bsr"
+yes
+wait
+messages
+quit
+END_OF_DATA
+
+run_bconsole
+
+check_for_zombie_jobs storage=File1
+stop_bacula
+
+check_two_logs
+
+# looking for dircmd.c:1244-3 FileIndex=3-6
+efi=`awk -F '-' '/FileIndex=/ { if (invol) { ret=$4>ret?$4:ret } } /Storage="File1"/ { invol=1 } /Storage="File2"/ { invol=0} END { print ret }' $working/*trace`
+
+# read_header: FI=10
+efiseen=`awk '/match_volume=Vol-/ { invol=1 } /match_volume=Vol2-/ { invol=0 } /read_header: FI=[0-9]+/ { if (invol) { gsub(/FI=/, "", $4); v=int($4); ret=ret>v?ret:v } } END { print ret}' $working/*trace` 
+
+# count one more
+e=`expr $efi + 1`
+
+if [ $efiseen -gt $e ] ; then
+    estat=1
+    print_debug "ERROR: We need to get $efi FileIndex, we saw $efiseen in the log, we read too far"
+else
+    print_debug "INFO: We need to get $efi FileIndex, we saw $efiseen in the log"
+fi
+
+
+end_test