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