]> git.sur5r.net Git - bacula/bacula/commitdiff
ebl Add test with new Copy option
authorEric Bollengier <eric@eb.homelinux.org>
Fri, 17 Oct 2008 11:43:38 +0000 (11:43 +0000)
committerEric Bollengier <eric@eb.homelinux.org>
Fri, 17 Oct 2008 11:43:38 +0000 (11:43 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7827 91ce42f0-d328-0410-95d8-f526ca767f89

regress/tests/copy-volume-test [new file with mode: 0755]

diff --git a/regress/tests/copy-volume-test b/regress/tests/copy-volume-test
new file mode 100755 (executable)
index 0000000..dee1f8f
--- /dev/null
@@ -0,0 +1,205 @@
+#!/bin/sh
+#
+# Run a backup of the Bacula build directory on two Volumes
+#   then migrate it to another device.             
+#
+# This script uses the virtual disk autochanger and migration scripts
+#
+TestName="copy-volume-test"
+JobName=MigVolBackup
+. scripts/functions
+
+
+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
+
+change_jobname NightlySave $JobName
+sed -i 's/migrate/copy/g' ${cwd}/bin/bacula-dir.conf
+sed -i 's/Migrate/Copy/g' ${cwd}/bin/bacula-dir.conf
+rm -f ${cwd}/build/po/test.po >/dev/null
+
+start_test
+
+#
+# Note, we first backup into Pool Default, 
+#          then Copy into Pool Full. 
+#              Pool Default uses Storage=File
+#              Pool Full    uses Storage=DiskChanger
+
+# Write out bconsole commands
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@output
+messages
+@$out ${cwd}/tmp/log1.out
+label storage=File volume=FileVolume001 Pool=Default
+label storage=File volume=FileVolume002 Pool=Scratch
+update Volume=FileVolume001 MaxVolBytes=3000000 pool=Default
+label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Scratch drive=0
+label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Scratch drive=0
+@# 
+run job=$JobName yes
+wait
+run job=$JobName yes
+wait
+update volume=FileVolume001 VolStatus=Used
+update volume=FileVolume002 VolStatus=Used
+@#list volumes
+@#list jobs
+messages
+@$out ${cwd}/tmp/log11.out
+@############################################################
+@# should copy one job, and the second is empty
+@############################################################
+@# setdebug level=11 dir
+@echo "Run copy-volume Job"
+@#setdebug level=100 dir
+run job=copy-volume yes
+@sleep 5 
+list jobs
+llist jobid=1
+llist jobid=2
+llist jobid=3
+llist jobid=4
+llist jobid=5
+status storage=DiskChanger
+wait
+list volumes
+list jobs
+llist jobid=1
+llist jobid=2
+llist jobid=3
+llist jobid=4
+llist jobid=5
+sql
+select * from JobMedia where JobId=1;
+
+messages
+@$out ${cwd}/tmp/log2.out
+@############################################################
+@# now do a restore
+@# Expect: 
+@#  Check that copy uses JobId 1,2
+@#  Use File instead of DiskChanger
+@#  Files are there        
+@############################################################
+restore where=${cwd}/tmp/bacula-restores select storage=DiskChanger
+unmark *
+mark *
+done
+yes
+wait
+messages
+@output
+quit
+END_OF_DATA
+
+run_bacula
+check_for_zombie_jobs storage=File
+check_restore_diff
+
+# cleanup previous restore
+rm -rf ${cwd}/tmp/bacula-restores
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@############################################################
+@# Purge File backup, and restore again
+@# Expect:
+@#  Check that copy uses other JobId
+@#  Use DiskChanger
+@#  Files are there
+@############################################################
+@$out ${cwd}/tmp/log3.out
+purge volume=FileVolume001 yes
+purge volume=FileVolume002 yes
+restore where=${cwd}/tmp/bacula-restores select storage=DiskChanger
+unmark *
+mark *
+done
+yes
+wait
+messages
+quit
+END_OF_DATA
+
+run_bconsole
+
+check_for_zombie_jobs storage=DiskChanger
+check_restore_diff
+
+# cleanup previous restore
+rm -rf ${cwd}/tmp/bacula-restores
+touch ${cwd}/build/po/test.po
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@############################################################
+@# Run a new Incremental, restore melting Copy and Backup
+@# and copy the new job to Changer
+@# Expect:
+@#  Files are there
+@#  Copy OK
+@############################################################
+@$out ${cwd}/tmp/log4.out
+run job=$JobName yes
+wait
+messages
+restore where=${cwd}/tmp/bacula-restores select all
+done
+yes
+wait
+messages
+update volume=FileVolume001 VolStatus=Used
+update volume=FileVolume002 VolStatus=Used
+run job=copy-volume yes
+wait
+messages
+quit
+END_OF_DATA
+
+run_bconsole
+
+check_for_zombie_jobs storage=DiskChanger
+check_restore_diff
+
+stop_bacula
+
+################################################################
+# Get information from logs
+get_info()
+{
+    IDX=$1
+    LOG=$2
+    RET=`awk -v idx=$IDX -F: '/Prev Backup JobId/ { pbid[j++]=$2 } /New Backup JobId/  { nbid[i++]=$2 } END { print pbid[idx] " " nbid[idx] }' $LOG`
+}
+
+get_info 0 ${cwd}/tmp/log11.out
+set $RET
+
+if [ -z "$2" -o "$2" = 0 ]; then
+    bstat=2
+    print_debug "The first job must have been copied"
+fi
+
+get_info 1 ${cwd}/tmp/log11.out
+set $RET
+
+if [ -z "$2" -o "$2" != 0 ]; then
+    bstat=2
+    print_debug "The second job have no files, it can't have been copied"
+fi
+
+get_info 0 ${cwd}/tmp/log4.out
+set $RET
+
+if [ -z "$2" -o "$2" = 0 ]; then
+    bstat=2
+    print_debug "The new incremental job must have been copied"
+fi
+
+
+
+check_two_logs
+end_test