]> git.sur5r.net Git - bacula/bacula/commitdiff
ebl Add test for new ScratchPool directive
authorEric Bollengier <eric@eb.homelinux.org>
Tue, 27 Jan 2009 16:43:14 +0000 (16:43 +0000)
committerEric Bollengier <eric@eb.homelinux.org>
Tue, 27 Jan 2009 16:43:14 +0000 (16:43 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8405 91ce42f0-d328-0410-95d8-f526ca767f89

regress/tests/scratchpool-pool-test [new file with mode: 0755]

diff --git a/regress/tests/scratchpool-pool-test b/regress/tests/scratchpool-pool-test
new file mode 100755 (executable)
index 0000000..6a299e4
--- /dev/null
@@ -0,0 +1,128 @@
+#!/bin/sh
+#
+# Run a simple backup of the Bacula build directory 
+#  to two tapes where the maximum tape file size is set to 1M
+#  Note, this test simulates the tape filling and writing to
+#   the next tape. One minor wrinkle: we create the two tapes
+#   in the special ScratchPool defined in pool, so they should
+#   be switched to the Special
+#   Pool automatically.
+#
+#  Note we use the viritual disk autochanger
+#
+TestName="scratchpool-pool-test"
+JobName=scratchpool-pool
+. scripts/functions
+
+cwd=`pwd`
+scripts/cleanup
+scripts/copy-2disk-confs
+scripts/prepare-disk-changer
+echo "${cwd}/build" >${cwd}/tmp/file-list
+
+outf="${cwd}/tmp/sed_tmp"
+echo "s%# Maximum File Size%  Maximum File Size%g" >${outf}
+cp ${cwd}/bin/bacula-sd.conf ${cwd}/tmp/1
+sed -f ${outf} ${cwd}/tmp/1 >${cwd}/bin/bacula-sd.conf
+
+change_jobname NightlySave $JobName
+start_test
+
+# Write out bconsole commands
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@$out /dev/null
+messages
+@$out ${cwd}/tmp/log1.out
+label storage=DDS-4 volume=TestVolume001 slot=1 pool=SpecialScratch drive=0
+label storage=DDS-4 volume=TestVolume002 slot=2 pool=SpecialScratch drive=0
+label storage=DDS-4 volume=TestVolume003 slot=3 pool=Scratch drive=0
+show pool=Default
+show pool=Special
+@########################
+@# Verify catalog entries
+@$out ${cwd}/tmp/pool.out
+sql
+SELECT Name, ScratchPoolId, RecyclePoolId FROM Pool WHERE Name IN ('Default', 'Special');
+
+@$out ${cwd}/tmp/log1.out
+@########################
+@# Use SpecialScratch
+run job=$JobName pool=Special yes
+wait
+messages
+run job=$JobName pool=Special level=Full yes
+wait
+messages
+@$out ${cwd}/tmp/log3.out
+@########################
+@# no more volume in SpecialScratch (but Scrach have one)
+run job=$JobName pool=Special level=Full yes
+@sleep 10
+cancel jobid=3
+wait
+messages
+@$out ${cwd}/tmp/log4.out
+list volume pool=Special
+@# 
+@# now do a restore
+@#
+@$out ${cwd}/tmp/log2.out
+restore where=${cwd}/tmp/bacula-restores select all storage=DDS-4 done
+yes
+wait
+messages
+@$out
+quit
+END_OF_DATA
+
+run_bacula
+check_for_zombie_jobs storage=DDS-4
+stop_bacula
+
+check_two_logs
+check_restore_diff
+
+
+################################################################
+# Check Catalog definition for ScratchPool and RecyclePool
+awk '
+ / Default/ { if ($4 == 0 && $6 != 0) {print "OK"} else { print "Default ERR"} }
+ / Special/ { if ($4 != 0 && $6 == 0) {print "OK"} else { print "Special ERR"} }
+' tmp/pool.out > tmp/res
+
+grep ERR tmp/res
+if [ $? -eq 0 ]; then
+    print_debug "Found ERR about ScratchPoolId/RecyclePoolId in catalog"
+    dstat=2
+fi
+
+if [ `cat tmp/res | wc -l` -ne 2 ]; then
+    print_debug "Can't find all pool records in catalog"
+    dstat=2
+fi
+
+################################################################
+# Check for the third job that must fail because the SpecialScratch is empty
+
+grep 'Cannot find any appendable volumes' tmp/log3.out > /dev/null
+if [ $? -ne 0 ]; then
+    print_debug "Job 3 should request a manual intervention!!"
+    dstat=2
+fi
+
+grep 'Backup Error' tmp/log3.out > /dev/null
+if [ $? -ne 0 ]; then
+    print_debug "Job 3 should be in error"
+    dstat=2
+fi
+
+################################################################
+# Check Special pool
+
+if [ `grep TestVolume00 tmp/log4.out | wc -l` -ne 2 ]; then
+    print_debug "Special pool should contain 2 vols"
+    dstat=2
+fi
+
+end_test