]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/scratchpool-pool-test
ebl Add test for new ScratchPool directive
[bacula/bacula] / regress / tests / scratchpool-pool-test
1 #!/bin/sh
2 #
3 # Run a simple backup of the Bacula build directory 
4 #  to two tapes where the maximum tape file size is set to 1M
5 #  Note, this test simulates the tape filling and writing to
6 #   the next tape. One minor wrinkle: we create the two tapes
7 #   in the special ScratchPool defined in pool, so they should
8 #   be switched to the Special
9 #   Pool automatically.
10 #
11 #  Note we use the viritual disk autochanger
12 #
13 TestName="scratchpool-pool-test"
14 JobName=scratchpool-pool
15 . scripts/functions
16
17 cwd=`pwd`
18 scripts/cleanup
19 scripts/copy-2disk-confs
20 scripts/prepare-disk-changer
21  
22 echo "${cwd}/build" >${cwd}/tmp/file-list
23
24 outf="${cwd}/tmp/sed_tmp"
25 echo "s%# Maximum File Size%  Maximum File Size%g" >${outf}
26 cp ${cwd}/bin/bacula-sd.conf ${cwd}/tmp/1
27 sed -f ${outf} ${cwd}/tmp/1 >${cwd}/bin/bacula-sd.conf
28
29 change_jobname NightlySave $JobName
30 start_test
31
32 # Write out bconsole commands
33 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
34 @$out /dev/null
35 messages
36 @$out ${cwd}/tmp/log1.out
37 label storage=DDS-4 volume=TestVolume001 slot=1 pool=SpecialScratch drive=0
38 label storage=DDS-4 volume=TestVolume002 slot=2 pool=SpecialScratch drive=0
39 label storage=DDS-4 volume=TestVolume003 slot=3 pool=Scratch drive=0
40 show pool=Default
41 show pool=Special
42 @########################
43 @# Verify catalog entries
44 @$out ${cwd}/tmp/pool.out
45 sql
46 SELECT Name, ScratchPoolId, RecyclePoolId FROM Pool WHERE Name IN ('Default', 'Special');
47
48 @$out ${cwd}/tmp/log1.out
49 @########################
50 @# Use SpecialScratch
51 run job=$JobName pool=Special yes
52 wait
53 messages
54 run job=$JobName pool=Special level=Full yes
55 wait
56 messages
57 @$out ${cwd}/tmp/log3.out
58 @########################
59 @# no more volume in SpecialScratch (but Scrach have one)
60 run job=$JobName pool=Special level=Full yes
61 @sleep 10
62 cancel jobid=3
63 wait
64 messages
65 @$out ${cwd}/tmp/log4.out
66 list volume pool=Special
67 @# 
68 @# now do a restore
69 @#
70 @$out ${cwd}/tmp/log2.out
71 restore where=${cwd}/tmp/bacula-restores select all storage=DDS-4 done
72 yes
73 wait
74 messages
75 @$out
76 quit
77 END_OF_DATA
78
79 run_bacula
80 check_for_zombie_jobs storage=DDS-4
81 stop_bacula
82
83 check_two_logs
84 check_restore_diff
85
86
87 ################################################################
88 # Check Catalog definition for ScratchPool and RecyclePool
89 awk '
90  / Default/ { if ($4 == 0 && $6 != 0) {print "OK"} else { print "Default ERR"} }
91  / Special/ { if ($4 != 0 && $6 == 0) {print "OK"} else { print "Special ERR"} }
92 ' tmp/pool.out > tmp/res
93
94 grep ERR tmp/res
95 if [ $? -eq 0 ]; then
96     print_debug "Found ERR about ScratchPoolId/RecyclePoolId in catalog"
97     dstat=2
98 fi
99
100 if [ `cat tmp/res | wc -l` -ne 2 ]; then
101     print_debug "Can't find all pool records in catalog"
102     dstat=2
103 fi
104
105 ################################################################
106 # Check for the third job that must fail because the SpecialScratch is empty
107
108 grep 'Cannot find any appendable volumes' tmp/log3.out > /dev/null
109 if [ $? -ne 0 ]; then
110     print_debug "Job 3 should request a manual intervention!!"
111     dstat=2
112 fi
113
114 grep 'Backup Error' tmp/log3.out > /dev/null
115 if [ $? -ne 0 ]; then
116     print_debug "Job 3 should be in error"
117     dstat=2
118 fi
119
120 ################################################################
121 # Check Special pool
122
123 if [ `grep TestVolume00 tmp/log4.out | wc -l` -ne 2 ]; then
124     print_debug "Special pool should contain 2 vols"
125     dstat=2
126 fi
127
128 end_test