]> git.sur5r.net Git - bacula/bacula/blobdiff - regress/tests/truncate-bug-tape
Big backport from Enterprise
[bacula/bacula] / regress / tests / truncate-bug-tape
index 040540d2ade12f432e722ebe2a7e72cf57ec7a76..f144460610c009dc28f796b51f64dc8b660fb0a6 100755 (executable)
@@ -1,51 +1,62 @@
 #!/bin/sh
+#
+# Copyright (C) 2000-2015 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+
 #
 # Test for a tape truncation bug.
 #
-cwd=`pwd`
+TestName="truncate-bug-tape" 
+JobName=truncatebug
+. scripts/functions
+
+require_tape_drive
 
 scripts/copy-tape-confs
 scripts/cleanup-tape
-echo "${cwd}/build" >/tmp/file-list
 
-echo " "
-echo " "
-echo " === Starting truncate-bug-tape test at `date +%R:%S` ==="
-echo " === Starting truncate-bug-tape test at `date +%R:%S` ===" >>working/log
-echo " "
+echo "${cwd}/build" >${cwd}/tmp/file-list
+
+change_jobname NightlySave $JobName
+start_test
 
-bin/bacula start 2>&1 >/dev/null
-bin/bconsole -c bin/bconsole.conf <<END_OF_DATA 2>&1 >/dev/null
-@output /dev/null
+cat <<END_OF_DATA >tmp/bconcmds
+@$out /dev/null
 messages
-@output tmp/log1.out
-label storage=DDS-4 volume=TestVolume001 slot=0 pool=Default
+@$out   tmp/log1.out
+label storage=tape volume=TestVolume001 slot=0 pool=Default
 @# do a bunch of saves so we have 12 files on the tape
-run job=NightlySave yes
-run level=Full job=NightlySave yes
-run level=Full job=NightlySave yes
-run level=Full job=NightlySave yes
-run level=Full job=NightlySave yes
-run level=Full job=NightlySave yes
-run level=Full job=NightlySave yes
-run level=Full job=NightlySave yes
-run level=Full job=NightlySave yes
-run level=Full job=NightlySave yes
-run level=Full job=NightlySave yes
-run level=Full job=NightlySave yes
+@#setdebug level=100 dir
+setdebug level=50 storage=tape
+run job=$JobName yes
+run level=Full job=$JobName yes
+run level=Full job=$JobName yes
+run level=Full job=$JobName yes
+run level=Full job=$JobName yes
+run level=Full job=$JobName yes
+run level=Full job=$JobName yes
+run level=Full job=$JobName yes
+run level=Full job=$JobName yes
+run level=Full job=$JobName yes
+run level=Full job=$JobName yes
+run level=Full job=$JobName yes
 wait
 messages
 quit
 END_OF_DATA
-scripts/check_for_zombie_jobs storage=DDS-4
-bin/bconsole -c bin/bconsole.conf <<END_OF_DATA 2>&1 >/dev/null
-@output /dev/null
+
+run_bacula
+scripts/check_for_zombie_jobs storage=tape
+
+cat <<END_OF_DATA >tmp/bconcmds
+@$out /dev/null
 messages
-@output tmp/log1.out
+@$out tmp/log2.out
 @# 
 @# now do a restore
 @#
-restore where=${cwd}/tmp/bacula-restores storage=DDS-4
+restore where=${cwd}/tmp/bacula-restores storage=tape
 3
 @# select JobId=4 (i.e. file five on the tape)
 4
@@ -56,32 +67,28 @@ done
 yes
 wait
 messages
-@output
 quit
 END_OF_DATA
-scripts/check_for_zombie_jobs storage=DDS-4
-bin/bconsole -c bin/bconsole.conf <<END_OF_DATA 2>&1 >/dev/null
-@output /dev/null
+
+run_bconsole
+scripts/check_for_zombie_jobs storage=tape
+
+# Now write to tape one more time
+cat <<END_OF_DATA >tmp/bconcmds
+@$out /dev/null
 messages
-@output tmp/log2.out
-run level=Full job=NightlySave yes
+@$out tmp/log3.out
+run level=Full job=$JobName yes
 wait
 messages
 quit
 END_OF_DATA
-bin/bacula stop 2>&1 >/dev/null
-grep "^  Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
-bstat=$?
-grep "^  Termination: *Backup OK" tmp/log2.out 2>&1 >/dev/null
-rstat=$?
-if [ $bstat != 0 -o $rstat != 0 ] ; then
-   echo " "
-   echo " "
-   echo "  !!!!! truncate-bug-tape test Bacula source failed!!! !!!!! "
-   echo "  !!!!! truncate-bug-tape test failed!!! !!!!! " >>test.out
-   echo " "
-else
-   echo "  ===== truncate-bug-tape test Bacula source OK ===== "
-   echo "  ===== truncate-bug-tape test OK ===== " >>test.out
-   scripts/cleanup
-fi
+
+run_bconsole
+check_for_zombie_jobs storage=tape
+stop_bacula
+
+check_two_logs
+grep "^  Termination: *Backup OK" tmp/log3.out 2>&1 >/dev/null
+dstat=$?
+end_test