From: Kern Sibbald Date: Sun, 1 Jun 2008 20:11:18 +0000 (+0000) Subject: Cleanup some autochanger code X-Git-Tag: Release-2.4.0~5 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=16ca08834fc6de4dc19997e7f5e54e0e601847c0;p=bacula%2Fbacula Cleanup some autochanger code git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.2@7089 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/regress/do_disk b/regress/do_disk new file mode 100755 index 0000000000..0ac4aa8bf3 --- /dev/null +++ b/regress/do_disk @@ -0,0 +1,16 @@ +#!/bin/sh +# /home/kern/bacula/bin/startmysql +nice make setup +echo " " >test.out +cat build/config.out >>test.out +echo " " >>test.out +echo "Test results" >>test.out +echo " " >>test.out +./starttime +nice ./all-non-root-tests +echo " " +echo "End do_file tests" +echo "End do_file tests" >>test.out +scripts/cleanup +cat test.out +./endtime diff --git a/regress/scripts/cleanup-2tape.in b/regress/scripts/cleanup-2tape.in index b937ea115e..8fa197d4df 100755 --- a/regress/scripts/cleanup-2tape.in +++ b/regress/scripts/cleanup-2tape.in @@ -6,28 +6,4 @@ . scripts/functions scripts/cleanup - -if test x@autochanger@ != x/dev/null; then - slot=`bin/@changer_script@ @autochanger@ loaded 0 @tape_drive@ $DRIVE1` - if test "x${slot}" != "x$SLOT2"; then - bin/@changer_script@ @autochanger@ unload $slot @tape_drive@ $DRIVE1 - bin/@changer_script@ @autochanger@ load $SLOT2 @tape_drive@ $DRIVE1 - fi - - init_drive @tape_drive@ -fi - - -# -# If we have an autochanger always load tape in slot 1 -# -if test x@autochanger@ != x/dev/null; then - slot=`bin/@changer_script@ @autochanger@ loaded 0 @tape_drive@ $DRIVE1` - if test "x${slot}" != "x$SLOT1"; then - bin/@changer_script@ @autochanger@ unload $slot @tape_drive@ $DRIVE1 - bin/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1 - fi -fi - -init_drive @tape_drive@ - +scripts/prepare-two-tapes diff --git a/regress/scripts/cleanup-tape.in b/regress/scripts/cleanup-tape.in index 310731c917..936540289d 100755 --- a/regress/scripts/cleanup-tape.in +++ b/regress/scripts/cleanup-tape.in @@ -1,17 +1,26 @@ #!/bin/sh # -# Cleanup left over files -- both before and after test run +# Cleanup left over files, then load $SLOT1 into drive and +# write an EOF on it. # + . scripts/functions scripts/cleanup -if test "x@autochanger@" != "x/dev/null" ; then - a=`bin/@changer_script@ @autochanger@ loaded $SLOT1 @tape_drive@ 0` - if test $a = 0 ; then - bin/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ 0 - fi +if test x@autochanger@ != x/dev/null; then + slot=`bin/@changer_script@ @autochanger@ loaded 0 @tape_drive@ $DRIVE1` + case $slot in + 0) + bin/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1 + ;; + $SLOT1) + ;; + default) + bin/@changer_script@ @autochanger@ unload $slot @tape_drive@ $DRIVE1 + bin/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1 + ;; + esac fi init_drive @tape_drive@ - diff --git a/regress/scripts/functions b/regress/scripts/functions index 11c3789623..61d6eb4999 100644 --- a/regress/scripts/functions +++ b/regress/scripts/functions @@ -2,6 +2,7 @@ # A set of useful functions to be sourced in each test # + start_test() { # Turn off email @@ -55,7 +56,7 @@ if test x${AUTOCHANGER} = x/dev/null ; then fi } -require_faketape() +require_faketape() { if test x${USE_FAKETAPE} = x ; then echo "$TestName test needs the faketape driver." @@ -130,6 +131,21 @@ run_bscan() fi } +bscan_libdbi() +{ + B=`echo $LIBDBI | sed 's/;//' | sed 's/;//g'` + B_D=`echo $B | awk '{print $3}'` + B_t=`echo $B | awk '{print $6}'` + B_p=`echo $B | awk '{print $9}'` + + BSCANLIBDBI="${LIBDBI:+1}" + + if test "$BSCANLIBDBI" = "1" ; then + BSCANLIBDBI="-D $B_D -h $B_t -t $B_p" + else + BSCANLIBDBI=" " + fi +} stop_bacula() { @@ -264,3 +280,6 @@ fi # Source the configuration variables . ${cwd}/config + +CLIENT=${HOST}-fd +AUTOCHANGER_SCRIPT=${AUTOCHANGER_SCRIPT:-mtx-changer} diff --git a/regress/scripts/prepare-two-tapes.in b/regress/scripts/prepare-two-tapes.in index 95dad305c0..642a8f850c 100755 --- a/regress/scripts/prepare-two-tapes.in +++ b/regress/scripts/prepare-two-tapes.in @@ -2,31 +2,51 @@ # # Cleanup left over files -- both before and after test run # +# Write an EOF on tape in slot $SLOT1 and on tape in $SLOT2 . scripts/functions scripts/cleanup -if test x@autochanger@ != x/dev/null; then - slot=`bin/@changer_script@ @autochanger@ loaded 0 @tape_drive@ $DRIVE1` - if test "x${slot}" != "x$SLOT2"; then - bin/@changer_script@ @autochanger@ unload $slot @tape_drive@ $DRIVE1 - bin/@changer_script@ @autochanger@ load $SLOT2 @tape_drive@ $DRIVE1 - fi - init_drive @tape_drive@ -fi - - # -# If we have an autochanger always load tape in slot 1 +# init first of two slots +# optimize so we don't unnecessarily unload and load slots # if test x@autochanger@ != x/dev/null; then slot=`bin/@changer_script@ @autochanger@ loaded 0 @tape_drive@ $DRIVE1` - if test "x${slot}" != "x$SLOT1"; then + case $slot in + 0) + bin/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1 + init_drive @tape_drive@ + slot=$SLOT1 + ;; + $SLOT1) + init_drive @tape_drive@ + slot=$SLOT1 + ;; + $SLOT2) + init_drive @tape_drive@ + slot=$SLOT2 + ;; + default) bin/@changer_script@ @autochanger@ unload $slot @tape_drive@ $DRIVE1 bin/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1 - fi -fi - -init_drive @tape_drive@ + init_drive @tape_drive@ + slot=$SLOT1 + ;; + esac +# init the other slot + case $slot in + $SLOT1) + bin/@changer_script@ @autochanger@ unload $slot @tape_drive@ $DRIVE1 + bin/@changer_script@ @autochanger@ load $SLOT2 @tape_drive@ $DRIVE1 + init_drive @tape_drive@ + ;; + $SLOT2) + bin/@changer_script@ @autochanger@ unload $slot @tape_drive@ $DRIVE1 + bin/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1 + init_drive @tape_drive@ + ;; + esac +fi diff --git a/regress/tests/two-volume-test b/regress/tests/two-volume-test index 1266e75d76..920beb57ac 100755 --- a/regress/tests/two-volume-test +++ b/regress/tests/two-volume-test @@ -38,7 +38,7 @@ sql select * from Storage; select VolumeName,InChanger,StorageId from Media; -@#setdebug level=1000 client +@#setdebug level=1000 client=$CLIENT run job=$JobName yes wait update slots scan storage=DDS-4