]> git.sur5r.net Git - bacula/bacula/commitdiff
Cleanup tape clean scripts
authorKern Sibbald <kern@sibbald.com>
Sun, 30 Mar 2008 19:37:08 +0000 (19:37 +0000)
committerKern Sibbald <kern@sibbald.com>
Sun, 30 Mar 2008 19:37:08 +0000 (19:37 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.2@6705 91ce42f0-d328-0410-95d8-f526ca767f89

regress/scripts/cleanup-2tape.in
regress/scripts/prepare-two-tapes.in
regress/tests/incremental-2tape

index 0f33ec95c7992c3f47cfba7969da2197118d2609..28eea0b59314231ce85ed090d7db065d9d3ca62b 100755 (executable)
@@ -2,13 +2,16 @@
 #
 # Cleanup left over files -- both before and after test run
 #
+
+. scripts/functions
+
 scripts/cleanup
 
 if test x@autochanger@ != x/dev/null; then
-   drive=`bin/mtx-changer @autochanger@ loaded 0 dummy 0`
-   if test x${drive} != x2; then
-      bin/mtx-changer @autochanger@ unload 0 @tape_drive@ 0
-      bin/mtx-changer @autochanger@ load 2 @tape_drive@ 0
+   slot=`bin/mtx-changer @autochanger@ loaded 0 dummy $DRIVE1`
+   if test "x${slot}" != "x$SLOT2"; then
+      bin/mtx-changer @autochanger@ unload $slot @tape_drive@ $DRIVE1
+      bin/mtx-changer @autochanger@ load $SLOT2 @tape_drive@ $DRIVE1
    fi
    mt -f @tape_drive@ rewind
    mt -f @tape_drive@ weof
@@ -19,10 +22,10 @@ fi
 # If we have an autochanger always load tape in slot 1
 #
 if test x@autochanger@ != x/dev/null; then
-   drive=`bin/mtx-changer @autochanger@ loaded 0 dummy 0`
-   if test x${drive} != x1; then
-      bin/mtx-changer @autochanger@ unload 0 @tape_drive@ 0
-      bin/mtx-changer @autochanger@ load 1 @tape_drive@ 0
+   slot=`bin/mtx-changer @autochanger@ loaded 0 dummy $DRIVE1`
+   if test "x${slot}" != "x$SLOT1"; then
+      bin/mtx-changer @autochanger@ unload $slot @tape_drive@ $DRIVE1
+      bin/mtx-changer @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1
    fi
 fi
 
index 3be1775df18683e246d4df74679801edc156830b..28eea0b59314231ce85ed090d7db065d9d3ca62b 100755 (executable)
@@ -1,56 +1,33 @@
 #!/bin/sh
 #
-# Create two blank tapes
+# Cleanup left over files -- both before and after test run
 #
 
-# mt status output
-# SunOS     No Additional Sense
-# FreeBSD   Current Driver State: at rest.
-# Linux     ONLINE
-#  Note Debian has an inferior mt. When no tape is in the
-#    drive it waits 2 minutes. When a tape is in the drive, it
-#    prints user unfriendly output.
-#
+. scripts/functions
+
+scripts/cleanup
 
-OS=`uname`
-case ${OS} in
-  SunOS)
-    ready="No Additional Sense"
-    ;;
-  FreeBSD)
-    ready="Current Driver State: at rest."
-    ;;
-  Linux)
-    if test -e /etc/debian_version ; then
-       ready="drive status"
-    else
-       ready="ONLINE"
-    fi
-  ;;
-esac
+if test x@autochanger@ != x/dev/null; then
+   slot=`bin/mtx-changer @autochanger@ loaded 0 dummy $DRIVE1`
+   if test "x${slot}" != "x$SLOT2"; then
+      bin/mtx-changer @autochanger@ unload $slot @tape_drive@ $DRIVE1
+      bin/mtx-changer @autochanger@ load $SLOT2 @tape_drive@ $DRIVE1
+   fi
+   mt -f @tape_drive@ rewind
+   mt -f @tape_drive@ weof
+fi
 
-wait_for_drive() {
-  i=0 
-  while [ $i -le 300 ]; do  # Wait max 300 seconds
-    if mt -f $1 status 2>&1 | grep "${ready}" >/dev/null 2>&1; then
-      break
-    fi
-#   debug "Device $1 - not ready, retrying..."
-    sleep 1
-    i=`expr $i + 1`
-  done
-}
 
 #
-# mt -f @tape_drive@ offline
-@changer_path@ -f @autochanger@ unload
-@changer_path@ -f @autochanger@ load 1
-wait_for_drive @tape_drive@
-mt -f @tape_drive@ rewind
-mt -f @tape_drive@ weof
-@changer_path@ -f @autochanger@ unload
-@changer_path@ -f @autochanger@ load 2
-wait_for_drive @tape_drive@
+# If we have an autochanger always load tape in slot 1
+#
+if test x@autochanger@ != x/dev/null; then
+   slot=`bin/mtx-changer @autochanger@ loaded 0 dummy $DRIVE1`
+   if test "x${slot}" != "x$SLOT1"; then
+      bin/mtx-changer @autochanger@ unload $slot @tape_drive@ $DRIVE1
+      bin/mtx-changer @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1
+   fi
+fi
+
 mt -f @tape_drive@ rewind
 mt -f @tape_drive@ weof
-#@changer_path@ -f @autochanger@ unload
index 67d4211a20298bcfd2b6083d9f803ee70c2f41ba..187a45c0bf0cdf4a0b0f5c7b644e094753dff0e1 100755 (executable)
@@ -5,27 +5,17 @@
 #
 # This script uses the autochanger and two tapes
 #
+TestName="incremental-2tape"
+JobName=incremental2tape
 . scripts/functions
-if test x${AUTOCHANGER} = x/dev/null ; then
-   echo "incremental-2tape test skipped. No autochanger."
-   exit
-fi
-debug=0
-if test "$debug" -eq 1 ; then
-  out="tee"
-else
-  out="output"
-fi
-cwd=`pwd`
-bin/bacula stop  2>&1 >/dev/null
-cd bin
-./drop_bacula_tables >/dev/null 2>&1
-./make_bacula_tables >/dev/null 2>&1
-./grant_bacula_privileges 2>&1 >/dev/null
-cd ..
 
+require_tape_drive
+require_autochanger
+
+scripts/cleanup
 scripts/copy-2tape-confs
-scripts/cleanup-2tape
+scripts/prepare-two-tapes
+
 echo "${cwd}/tmp/build" >${cwd}/tmp/file-list
 if test ! -d ${cwd}/tmp/build ; then
    mkdir ${cwd}/tmp/build
@@ -36,35 +26,27 @@ echo "${cwd}/tmp/build/ficheriro1.txt" >restore-list
 echo "${cwd}/tmp/build/ficheriro2.txt" >>restore-list
 cd ${cwd}
 
-echo " "
-echo " "
-echo " === Starting incremental-2tape test ==="
-echo " === Starting incremental-2tape test ===" >>working/log
-echo " "
+start_test
 
 # Write out bconsole commands
 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
 @$out /dev/null
 messages
 @$out ${cwd}/tmp/log1.out
-label storage=DDS-4 volume=TestVolume001 slot=1 Pool=Default drive=0
-label storage=DDS-4 volume=TestVolume002 slot=2 Pool=Default drive=0
+label storage=DDS-4 volume=TestVolume001 slot=$SLOT1 Pool=Default drive=$DRIVE1
+label storage=DDS-4 volume=TestVolume002 slot=$SLOT2 Pool=Default drive=$DRIVE1
 run job=NightlySave yes
 wait
 messages
 quit
 END_OF_DATA
 
-if test "$debug" -eq 1 ; then
-  bin/bacula start
-  cat ${cwd}/tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
-else
-  bin/bacula start 2>&1 >/dev/null
-  cat ${cwd}/tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
-fi
+run_bacula
+
 echo "ficheriro1.txt" >${cwd}/tmp/build/ficheriro1.txt
 echo "ficheriro2.txt" >${cwd}/tmp/build/ficheriro2.txt
-bin/bconsole -c bin/bconsole.conf <<END_OF_DATA
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
 @$out /dev/null
 messages
 @$out ${cwd}/tmp/log1.out
@@ -87,24 +69,18 @@ messages
 @$out
 quit
 END_OF_DATA
-bin/bacula stop 2>&1 >/dev/null
-grep "^  Termination: *Backup OK" ${cwd}/tmp/log1.out 2>&1 >/dev/null
-bstat=$?
-grep "^  Termination: *Restore OK" ${cwd}/tmp/log2.out 2>&1 >/dev/null
+
+run_bconsole
+
+check_for_zombie_jobs storage=DDS-4
+stop_bacula
+check_two_logs
 rstat=$?
+
 #
 # Delete .c files because we will only restored the txt files
 #
 rm -f ${cwd}/tmp/build/*.c
-diff -r ${cwd}/tmp/build ${cwd}/tmp/bacula-restores${cwd}/tmp/build 2>&1 >/dev/null
-if [ $? != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
-   echo " "
-   echo " "
-   echo "  !!!!! incremental-2tape test Bacula source failed!!! !!!!! "
-   echo "  !!!!! incremental-2tape test failed!!! !!!!! " >>test.out
-   echo " "
-else
-   echo "  ===== incremental-2tape test Bacula source OK ===== "
-   echo "  ===== incremental-2tape test OK ===== " >>test.out
-   scripts/cleanup
-fi
+
+check_restore_tmp_build_diff
+end_test