From ef548434a638e869d91e459714308502ddf3985d Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sun, 30 Mar 2008 19:37:08 +0000 Subject: [PATCH] Cleanup tape clean scripts 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 | 19 ++++--- regress/scripts/prepare-two-tapes.in | 69 +++++++++----------------- regress/tests/incremental-2tape | 74 ++++++++++------------------ 3 files changed, 59 insertions(+), 103 deletions(-) diff --git a/regress/scripts/cleanup-2tape.in b/regress/scripts/cleanup-2tape.in index 0f33ec95c7..28eea0b593 100755 --- a/regress/scripts/cleanup-2tape.in +++ b/regress/scripts/cleanup-2tape.in @@ -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 diff --git a/regress/scripts/prepare-two-tapes.in b/regress/scripts/prepare-two-tapes.in index 3be1775df1..28eea0b593 100755 --- a/regress/scripts/prepare-two-tapes.in +++ b/regress/scripts/prepare-two-tapes.in @@ -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 diff --git a/regress/tests/incremental-2tape b/regress/tests/incremental-2tape index 67d4211a20..187a45c0bf 100755 --- a/regress/tests/incremental-2tape +++ b/regress/tests/incremental-2tape @@ -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 <${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 <${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 -- 2.39.2