3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
6 # Run a simple backup of the Bacula build directory
7 # to two tapes where the maximum tape file size is set to 1M
8 # Note, this test simulates the tape filling and writing to
9 # the next tape. One minor wrinkle: we create the two tapes
10 # in the special ScratchPool defined in pool, so they should
11 # be switched to the Special
14 # Note we use the viritual disk autochanger
16 TestName="scratchpool-pool-test"
17 JobName=scratchpool-pool
20 # This test hangs so disable it
25 scripts/copy-2disk-confs
26 scripts/prepare-disk-changer
28 echo "${cwd}/build" >${cwd}/tmp/file-list
30 outf="${cwd}/tmp/sed_tmp"
31 echo "s%# Maximum File Size% Maximum File Size%g" >${outf}
32 cp ${cwd}/bin/bacula-sd.conf ${cwd}/tmp/1
33 sed -f ${outf} ${cwd}/tmp/1 >${cwd}/bin/bacula-sd.conf
35 change_jobname NightlySave $JobName
38 # Write out bconsole commands
39 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
42 @$out ${cwd}/tmp/log1.out
43 label storage=tape volume=TestVolume001 slot=1 pool=SpecialScratch drive=0
44 label storage=tape volume=TestVolume002 slot=2 pool=SpecialScratch drive=0
45 @#label storage=tape volume=TestVolume003 slot=3 pool=SpecialScratch drive=0
46 label storage=tape volume=TestVolume004 slot=4 pool=Scratch drive=0
49 @########################
50 @# Verify catalog entries
51 @$out ${cwd}/tmp/pool.out
53 SELECT Name, ScratchPoolId, RecyclePoolId FROM Pool WHERE Name IN ('Default', 'Special');
55 @$out ${cwd}/tmp/log1.out
56 @########################
58 run job=$JobName pool=Special yes
61 run job=$JobName pool=Special level=Full yes
64 @$out ${cwd}/tmp/log3.out
65 @########################
66 @# no more volume in SpecialScratch (but Scrach have one)
67 run job=$JobName pool=Special level=Full yes
68 @# Wait mount seems to be broken so use sleep instead
71 @# At this point jobid=3 should be blocked waiting for
72 @# the sysop to create a new Volume, so cancel the job
76 @$out ${cwd}/tmp/log4.out
77 list volume pool=Special
81 @$out ${cwd}/tmp/log2.out
82 restore where=${cwd}/tmp/bacula-restores select all storage=tape done
90 check_for_zombie_jobs storage=tape
97 ################################################################
98 # Check Catalog definition for ScratchPool and RecyclePool
100 / Default/ { if ($4 == 0 && $6 != 0) {print "OK"} else { print "Default ERR"} }
101 / Special/ { if ($4 != 0 && $6 == 0) {print "OK"} else { print "Special ERR"} }
102 ' tmp/pool.out > tmp/res
105 if [ $? -eq 0 ]; then
106 print_debug "Found ERR about ScratchPoolId/RecyclePoolId in catalog"
110 if [ `cat tmp/res | wc -l` -ne 2 ]; then
111 print_debug "Can't find all pool records in catalog"
115 ################################################################
116 # Check for the third job that must fail because the SpecialScratch is empty
118 grep 'Cannot find any appendable volumes' tmp/log3.out > /dev/null
119 if [ $? -ne 0 ]; then
120 print_debug "Job 3 should request a manual intervention!!"
124 grep 'Backup Canceled' tmp/log3.out > /dev/null
125 if [ $? -ne 0 ]; then
126 print_debug "Job 3 should be in error"
130 ################################################################
133 if [ `grep TestVolume00 tmp/log4.out | wc -l` -ne 2 ]; then
134 print_debug "Special pool should contain 2 vols"