]> git.sur5r.net Git - bacula/bacula/blobdiff - regress/tests/copy-uncopied-test
Big backport from Enterprise
[bacula/bacula] / regress / tests / copy-uncopied-test
index e4dfb240179b23e0f9ecd3f801c0afdf29b75ed2..29c98cc4d8aa18474391a1826e01a9c604595c8d 100755 (executable)
@@ -1,5 +1,8 @@
 #!/bin/sh
 #
+# Copyright (C) 2000-2017 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
 # Run a backup of the Bacula build directory on two Volumes
 #   then copy it to another device.             
 #
@@ -12,7 +15,6 @@ JobName=MigVolBackup
 
 scripts/cleanup
 scripts/copy-migration-confs
-scripts/prepare-disk-changer
 echo "${cwd}/build" >${cwd}/tmp/file-list
 #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
@@ -24,6 +26,8 @@ rm -f ${cwd}/build/po/test.po >/dev/null
 
 touch ${cwd}/tmp/log2.out
 
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "Allow Duplicate Jobs", "no", "Job", "MigVolBackup")'
+
 start_test
 
 #
@@ -34,7 +38,7 @@ start_test
 
 # Write out bconsole commands
 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
-@output
+@output /dev/null
 messages
 @$out ${cwd}/tmp/log1.out
 label storage=File volume=FileVolume001 Pool=Default
@@ -55,7 +59,7 @@ messages
 @# should copy job 1,2,3
 @# Expect: 3 copies (1,2,3)
 @############################################################
-@#setdebug level=100 dir
+setdebug level=200 dir
 run job=copy-uncopied yes
 @sleep 5 
 wait
@@ -103,54 +107,17 @@ rstat=0
 dstat=0
 zstat=0
 
-for i in tmp/log1[0-9].out; do
-    awk -F '|' '
- /list copies/ { ok=1; delete already }
- /^[|][ ]+[0-9]+/ {
-   if (ok) {
-      jobid=$2
-      copyid=$4
-
-      if (already[jobid]) {
-        print "ERROR: " jobid " " copyid " " already[jobid]
-      } else {
-        print "OK: " jobid " " copyid
-      }
-
-      already[jobid]=copyid
-   }
-}' $i > $i.result
-done
-
-grep ERROR tmp/log*result
-if [ $? -eq 0 ]; then
-    print_debug "Found multiple copies"
-    bstat=2
-fi
-
-n=`wc -l tmp/log11.out.result | awk '{ print $1 }'`
-if [ $n -ne 3 ]; then
-    print_debug "log11: Bad copies number"
-    bstat=3
-fi
+perl -Mscripts::functions -e 'check_multiple_copies(3)' tmp/log11.out
+bstat=`expr $bstat + $?`
 
-n=`wc -l tmp/log12.out.result| awk '{ print $1 }'`
-if [ $n -ne 3 ]; then
-    print_debug "log12: Bad copies number"
-    bstat=3
-fi
+perl -Mscripts::functions -e 'check_multiple_copies(3)' tmp/log12.out
+bstat=`expr $bstat + $?`
 
-n=`wc -l tmp/log13.out.result| awk '{ print $1 }'`
-if [ $n -ne 2 ]; then
-    print_debug "log13: Bad copies number"
-    bstat=3
-fi
+perl -Mscripts::functions -e 'check_multiple_copies(2)' tmp/log13.out
+bstat=`expr $bstat + $?`
 
-n=`wc -l tmp/log14.out.result| awk '{ print $1 }'`
-if [ $n -ne 2 ]; then
-    print_debug "log14: Bad copies number"
-    bstat=3
-fi
+perl -Mscripts::functions -e 'check_multiple_copies(2)' tmp/log14.out
+bstat=`expr $bstat + $?`
 
 check_two_logs
 end_test