]> git.sur5r.net Git - bacula/bacula/blobdiff - regress/scripts/functions
Minor tweaks
[bacula/bacula] / regress / scripts / functions
index 3a0ac0022949f23282785739c89d16eb83222de1..715f6fb4cb0dd5deed3d08ac8d8543bb77325457 100644 (file)
@@ -10,11 +10,11 @@ start_test()
    echo "s%  mail =%# mail = %g" >${outf}
    echo "s%  operator =%# operator =%g" >>${outf}
    cp bin/bacula-dir.conf tmp/1
-   sed -f ${outf} tmp/1 >bin/bacula-dir.conf
+   sed -f ${outf} tmp/1 > bin/bacula-dir.conf
    echo " "
    echo " "
    echo " === Starting $TestName at `date +%R:%S` ==="
-   echo " === Starting $TestName at `date +%R:%S` ===" >>working/log
+   echo " === Starting $TestName at `date +%R:%S` ===" >> working/log
    echo " "
    export zstat
 }
@@ -110,6 +110,34 @@ check_files_written()
     fi
 }
 
+################################################################
+# Get information from logs
+get_mig_info()
+{
+    # Prev Backup JobId
+    JOBID=$1
+    LOG=$2
+    RET=`awk -F: "BEGIN { jobid=$JOBID } "'/Prev Backup JobId/ { cjid=$2 } /New Backup JobId/  { if (cjid == jobid) { print $2 } }' $LOG`
+}
+
+get_duration()
+{
+   LOG=$1
+   RET=`awk 'BEGIN {t["secs"]=1;t["sec"]=1;t["min"]=60;t["mins"]=60}; /Elapsed time:/ { last=$3*t[$4] } END { print last }' $LOG`
+}
+
+check_duration()
+{
+   LOG=$1
+   TIME=$2
+   OP=${3-gt}
+
+   get_duration $LOG
+   if [ "$RET" -$OP "$TIME" ]; then
+       print_debug "Expect $OP than $TIME sec, get $RET"
+       bstat=2
+   fi
+}
 
 run_bacula()
 {
@@ -119,39 +147,40 @@ run_bacula()
      bin/bacula-ctl-sd start
      bin/bacula-ctl-fd start $1
      bin/bacula-ctl-dir start
-     cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
+     cat tmp/bconcmds | $bin/bconsole -c bin/bconsole.conf
      return $?
    else
-     bin/bacula start 2>&1 >/dev/null
-     cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
+     bin/bacula start >/dev/null 2>&1
+     cat tmp/bconcmds | $bin/bconsole -c bin/bconsole.conf >/dev/null 2>&1
      return $?
    fi
 }
 
 run_bconsole()
 {
+   bconsole_file=${1:-tmp/bconcmds}
    if test "$debug" -eq 1 ; then
-     cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
+     cat $bconsole_file | $bin/bconsole -c bin/bconsole.conf
    else
-     cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
+     cat $bconsole_file | $bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
    fi
 }
 
 run_btape()
 {
    if test "$debug" -eq 1 ; then
-     cat tmp/bconcmds | bin/btape -c bin/bacula-sd.conf DDS-4 | tee tmp/log1.out
+     cat tmp/bconcmds | $bin/btape -c bin/bacula-sd.conf DDS-4 | tee tmp/log1.out
    else
-     cat tmp/bconcmds | bin/btape -c bin/bacula-sd.conf DDS-4 2>&1 >tmp/log1.out
+     cat tmp/bconcmds | $bin/btape -c bin/bacula-sd.conf DDS-4 >tmp/log1.out 2>&1
    fi
 }
 
 run_bscan()
 {
    if test "$debug" -eq 1 ; then
-      bin/bscan $* | tee tmp/log.out
+      $bin/bscan $* | tee tmp/log.out
    else
-      bin/bscan $* 2>&1 >/dev/null
+      $bin/bscan $* 2>&1 >/dev/null
    fi
 }
 
@@ -174,6 +203,10 @@ bscan_libdbi()
 stop_bacula()
 {
    bin/bacula stop 2>&1 >/dev/null
+   zstat=0
+   bstat=0
+   rstat=0
+   dstat=0
 }
 
 check_for_zombie_jobs()
@@ -200,13 +233,13 @@ change_jobname()
 check_two_logs()
 {
    grep "^  Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
-   bstat=${bstat-$?}
+   bstat=${bstat:-$?}
    grep "^  Termination: .*Backup Error" tmp/log1.out 2>&1 >/dev/null
    if test $? -eq 0; then
       bstat=2
    fi
    grep "^  Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
-   rstat=${rstat-$?}
+   rstat=${rstat:-$?}
    grep "^  Termination: .*Restore Error" tmp/log2.out 2>&1 >/dev/null
    if test $? -eq 0; then
       rstat=2
@@ -219,6 +252,11 @@ check_two_logs()
    if test $? -eq 0; then
       rstat=4
    fi
+   grep "Encoding error for database" tmp/log1.out > /dev/null
+   if test $? -eq 0; then
+      print_debug "Found database encoding error"
+      bstat=2
+   fi
 }
 
 check_restore_diff()
@@ -246,6 +284,7 @@ end_test()
    if [ $zstat != 0 ] ; then
       echo " "
       echo "  !!!!! $TestName failed!!! `date +%R:%S` !!!!! "
+      echo "   Status: zombie=$zstat backup=$bstat restore=$rstat diff=$dstat"
       echo "  !!!!! $TestName failed!!! `date +%R:%S` !!!!! " >>test.out
       echo "   Status: zombie=$zstat backup=$bstat restore=$rstat diff=$dstat" >>test.out
       echo " "
@@ -255,7 +294,9 @@ end_test()
       echo " "
       echo " "
       echo "  !!!!! $TestName failed!!! `date +%R:%S` !!!!! "
+      echo "   Status: zombie=$zstat backup=$bstat restore=$rstat diff=$dstat"
       echo "  !!!!! $TestName failed!!! `date +%R:%S` !!!!! " >>test.out
+      echo "   Status: zombie=$zstat backup=$bstat restore=$rstat diff=$dstat" >>test.out
       if [ $bstat != 0 -o $rstat != 0 ] ; then
          echo "  !!!!! Bad termination status       !!!!! "
          echo "  !!!!! Bad termination status       !!!!! " >>test.out
@@ -328,10 +369,10 @@ rewind_drive()
 load_slot1() 
 {
 # Get a tape from slot1
-slot=`bin/$MTX ${AUTOCHANGER} loaded 0 ${TAPE_DRIVE} $DRIVE1`
+slot=`$scripts/$MTX ${AUTOCHANGER} loaded 0 ${TAPE_DRIVE} $DRIVE1`
 case $slot in
  0)
-    bin/$MTX ${AUTOCHANGER} load $SLOT1 ${TAPE_DRIVE} $DRIVE1
+    $scripts/$MTX ${AUTOCHANGER} load $SLOT1 ${TAPE_DRIVE} $DRIVE1
     slot=$SLOT1
     ;;
  $SLOT1)
@@ -339,8 +380,8 @@ case $slot in
     ;;
  *)
     rewind_drive ${TAPE_DRIVE}
-    bin/$MTX ${AUTOCHANGER} unload $slot  ${TAPE_DRIVE} $DRIVE1
-    bin/$MTX ${AUTOCHANGER} load   $SLOT1 ${TAPE_DRIVE} $DRIVE1
+    $scripts/$MTX ${AUTOCHANGER} unload $slot  ${TAPE_DRIVE} $DRIVE1
+    $scripts/$MTX ${AUTOCHANGER} load   $SLOT1 ${TAPE_DRIVE} $DRIVE1
     slot=$SLOT1
     ;;
 esac
@@ -355,17 +396,17 @@ load_other_slot()
 rewind_drive ${TAPE_DRIVE}
 case $1 in
  0)
-    bin/${AUTOCHANGER_SCRIPT} ${AUTOCHANGER} load $SLOT1 ${TAPE_DRIVE} $DRIVE1
+    $scripts/${AUTOCHANGER_SCRIPT} ${AUTOCHANGER} load $SLOT1 ${TAPE_DRIVE} $DRIVE1
     slot=1
     ;;
  $SLOT1)
-    bin/${AUTOCHANGER_SCRIPT} ${AUTOCHANGER} unload $1 ${TAPE_DRIVE} $DRIVE1
-    bin/${AUTOCHANGER_SCRIPT} ${AUTOCHANGER} load $SLOT2 ${TAPE_DRIVE} $DRIVE1
+    $scripts/${AUTOCHANGER_SCRIPT} ${AUTOCHANGER} unload $1 ${TAPE_DRIVE} $DRIVE1
+    $scripts/${AUTOCHANGER_SCRIPT} ${AUTOCHANGER} load $SLOT2 ${TAPE_DRIVE} $DRIVE1
     slot=2
     ;;
  $SLOT2)
-    bin/${AUTOCHANGER_SCRIPT} ${AUTOCHANGER} unload $1 ${TAPE_DRIVE} $DRIVE1
-    bin/${AUTOCHANGER_SCRIPT} ${AUTOCHANGER} load $SLOT1 ${TAPE_DRIVE} $DRIVE1
+    $scripts/${AUTOCHANGER_SCRIPT} ${AUTOCHANGER} unload $1 ${TAPE_DRIVE} $DRIVE1
+    $scripts/${AUTOCHANGER_SCRIPT} ${AUTOCHANGER} load $SLOT1 ${TAPE_DRIVE} $DRIVE1
     slot=1
     ;;
  *)
@@ -375,7 +416,6 @@ case $1 in
 esac
 }
 
-
 # Save current directory
 cwd=`pwd`
 if test "x${REGRESS_DEBUG}" = "x1"; then
@@ -390,16 +430,23 @@ fi
 db_name=${db_name:-"regress"}
 db_user=${db_user:-"regress"}
 db_password=${db_password:-""}
+working=${working:-"$cwd/working"}
+bin=${bin:-"$cwd/bin"}
+scripts=${scripts:-"$bin"}
+
+export bin
+export working
+export scripts
 
 CLIENT=${HOST}-fd
 
 if [ x$USE_VTAPE = xyes ]; then
-   mkdir -p $cwd/working/ach
+   mkdir -p $working/ach
    SLOT1=1
    SLOT2=2
-   TAPE_DRIVE=$cwd/working/ach/drive1
-   TAPE_DRIVE1=$cwd/working/ach/drive1
-   AUTOCHANGER=$cwd/working/ach/config
+   TAPE_DRIVE=$working/ach/drive1
+   TAPE_DRIVE1=$working/ach/drive1
+   AUTOCHANGER=$working/ach/config
    AUTOCHANGER_SCRIPT=disk-changer
    DRIVE1=0
    DRIVE2=1
@@ -410,3 +457,5 @@ EOF
 fi
 
 AUTOCHANGER_SCRIPT=${AUTOCHANGER_SCRIPT:-mtx-changer}
+LD_LIBRARY_PATH=$bin:$LD_LIBRARY_PATH
+export LD_LIBRARY_PATH