]> git.sur5r.net Git - bacula/bacula/blobdiff - regress/tests/bscan-tape
Update
[bacula/bacula] / regress / tests / bscan-tape
index 6fe38d0bb2726bac73e99fa40b7b92154026b388..f75fa9d91264761a107e78a8c5b300ec8e1a0d82 100755 (executable)
@@ -5,54 +5,41 @@
 #   do a bscan and restore.
 #   It should require at least 4 different bsrs.
 #
-debug=0
-if test "$debug" -eq 1 ; then
-  out="tee"
-else
-  out="output"
-fi
+TestName="bscan-tape"
+JobName=bscantape
+. scripts/functions
+
+require_tape_drive
 
-cwd=`pwd`
-scripts/copy-tape-confs
-scripts/cleanup-tape
-echo "${cwd}/build" >/tmp/file-list
+copy_tape_confs
 
-cp ${cwd}/bin/bacula-sd.conf ${cwd}/tmp/1
-sed "s%# Maximum File Size%  Maximum File Size%" ${cwd}/tmp/1 >${cwd}/bin/bacula-sd.conf
+echo "${cwd}/build" >tmp/file-list
 
-echo " "
-echo " "
-echo " === Starting bscan-tape at `date +%R:%S` ==="
-echo " === Starting bscan-tape at `date +%R:%S` ===" >>working/log
-echo " "
+cp ${cwd}/bin/bacula-sd.conf tmp/1
+sed "s%# Maximum File Size%  Maximum File Size%" tmp/1 >${cwd}/bin/bacula-sd.conf
+
+change_jobname NightlySave $JobName
+start_test
 
 cat <<END_OF_DATA >tmp/bconcmds
-@$out /dev/null
-estimate job=NightlySave listing
-estimate job=NightlySave listing
-estimate job=NightlySave listing
+@output /dev/null
+estimate job=$JobName listing
+estimate job=$JobName listing
 messages
 @$out tmp/log1.out
 setdebug level=2 storage=DDS-4
 label storage=DDS-4 volume=TestVolume001 slot=0 pool=Default
-run job=NightlySave yes
+run job=$JobName level=Full yes 
 wait
-run job=NightlySave level=Full yes
-wait
-run job=NightlySave level=Full yes
+run job=$JobName level=Full yes
 wait
 messages
 quit
 END_OF_DATA
 
-if test "$debug" -eq 1 ; then
-  bin/bacula start
-  cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
-else
-  bin/bacula start 2>&1 >/dev/null
-  cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
-fi
-scripts/check_for_zombie_jobs storage=DDS-4
+run_bacula
+check_for_zombie_jobs storage=DDS-4
+
 echo "Backup 1 done"
 # make some files for the incremental to pick up
 touch ${cwd}/build/src/dird/*.c ${cwd}/build/src/dird/*.o
@@ -65,44 +52,25 @@ cat <<END_OF_DATA >tmp/bconcmds
 @$out /dev/null
 messages
 @$out tmp/log1.out
-run job=NightlySave level=Incremental yes
+run job=$JobName level=Incremental yes
 wait
 messages
 quit
 END_OF_DATA
-if test "$debug" -eq 1 ; then
-  bin/bacula start
-  cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
-else
-  bin/bacula start 2>&1 >/dev/null
-  cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
-fi
 
+run_bconsole
 scripts/check_for_zombie_jobs storage=DDS-4
+
 echo "Backup 2 done"
 touch ${cwd}/build/src/dird/*.c
 touch ${cwd}/build/src/lib/*.c ${cwd}/build/src/lib/*.o
 #
 # run a third job
 #
-cat <<END_OF_DATA >tmp/bconcmds
-@$out /dev/null
-messages
-@$out tmp/log1.out
-run job=NightlySave level=Incremental yes
-wait
-messages
-quit
-END_OF_DATA
-if test "$debug" -eq 1 ; then
-  bin/bacula start
-  cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
-else
-  bin/bacula start 2>&1 >/dev/null
-  cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
-fi
 
+run_bconsole
 scripts/check_for_zombie_jobs storage=DDS-4
+
 echo "Backup 3 done"
 # make some files for the incremental to pick up
 touch ${cwd}/build/src/lib/*.c ${cwd}/build/src/lib/*.o
@@ -111,24 +79,11 @@ touch ${cwd}/build/src/lib/*.c ${cwd}/build/src/lib/*.o
 # run a fourth job
 #
 
-cat <<END_OF_DATA >tmp/bconcmds
-@$out /dev/null
-messages
-@$out tmp/log1.out
-run job=NightlySave level=Incremental yes
-wait
-messages
-quit
-END_OF_DATA
-if test "$debug" -eq 1 ; then
-  bin/bacula start
-  cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
-else
-  bin/bacula start 2>&1 >/dev/null
-  cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
-fi
-
+run_bconsole
 scripts/check_for_zombie_jobs storage=DDS-4
+
+stop_bacula
+
 echo "Backup 4 done"
 #
 # now drop and recreate the database
@@ -139,40 +94,45 @@ cd bin
 ./grant_bacula_privileges 2>&1 >/dev/null
 cd ..
 
-bin/bacula stop 2>&1 >/dev/null
 echo "volume=TestVolume001" >tmp/bscan.bsr
-bin/bscan -w working -m -s -v -b tmp/bscan.bsr -c bin/bacula-sd.conf DDS-4 2>&1 >/dev/null
-bin/bacula start 2>&1 >/dev/null
-bin/bconsole -c bin/bconsole.conf <<END_OF_DATA 2>&1 >/dev/null
+
+bscan_libdbi
+
+# If the database has a password pass it to bscan
+if test "x${db_passwd}" = "x"; then
+  PASSWD=
+else
+  PASSWD="-P ${db_passwd}"
+fi
+
+if test "$debug" -eq 1 ; then
+  bin/bscan -w working $BSCANLIBDBI -u ${db_user} -n ${db_name} $PASSWD -m -s -v -b tmp/bscan.bsr -c bin/bacula-sd.conf DDS-4                
+else
+  bin/bscan -w working $BSCANLIBDBI -u ${db_user} -n ${db_name} $PASSWD -m -s -v -b tmp/bscan.bsr -c bin/bacula-sd.conf DDS-4 2>&1 >/dev/null
+fi
+
+echo $BSCANLIBDBI
+
+cat <<END_OF_DATA >tmp/bconcmds
 @$out /dev/null
 messages
 @$out tmp/log2.out
 @# 
 @# now do a restore
 @#
-restore where=${cwd}/tmp/bacula-restores select all storage=DDS-4 done
+restore where=tmp/bacula-restores select all storage=DDS-4 done
 yes
 wait
 messages
 @$out
 quit
 END_OF_DATA
-scripts/check_for_zombie_jobs storage=DDS-4
+
+run_bacula
+check_for_zombie_jobs storage=DDS-4
+stop_bacula
 rm -f  ${cwd}/build/src/lib/dummy
-bin/bacula stop 2>&1 >/dev/null
-grep "^  Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
-bstat=$?
-grep "^  Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
-rstat=$?
-diff -r build tmp/bacula-restores${cwd}/build 2>&1 >/dev/null
-if [ $? != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
-   echo " "
-   echo " "
-   echo "  !!!!! bscan-tape Bacula source failed!!! !!!!! "
-   echo "  !!!!! bscan-tape failed!!! !!!!! " >>test.out
-   echo " "
-else
-   echo "  ===== bscan-tape Bacula source OK ===== "
-   echo "  ===== bscan-tape OK ===== " >>test.out
-#  scripts/cleanup
-fi
+
+check_two_logs
+check_restore_diff
+end_test