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