]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/scratchpool-pool-test
Tweak more debug for FreeBSD to verify-data-test
[bacula/bacula] / regress / tests / scratchpool-pool-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
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
12 #   Pool automatically.
13 #
14 #  Note we use the viritual disk autochanger
15 #
16 TestName="scratchpool-pool-test"
17 JobName=scratchpool-pool
18 . scripts/functions
19
20 # This test hangs so disable it
21 #exit
22
23 cwd=`pwd`
24 scripts/cleanup
25 scripts/copy-2disk-confs
26 scripts/prepare-disk-changer
27  
28 echo "${cwd}/build" >${cwd}/tmp/file-list
29
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
34
35 change_jobname NightlySave $JobName
36 start_test
37
38 # Write out bconsole commands
39 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
40 @output /dev/null
41 messages
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
47 show pool=Default
48 show pool=Special
49 @########################
50 @# Verify catalog entries
51 @$out ${cwd}/tmp/pool.out
52 sql
53 SELECT Name, ScratchPoolId, RecyclePoolId FROM Pool WHERE Name IN ('Default', 'Special');
54
55 @$out ${cwd}/tmp/log1.out
56 @########################
57 @# Use SpecialScratch
58 run job=$JobName pool=Special yes
59 wait
60 messages
61 run job=$JobName pool=Special level=Full yes
62 wait
63 messages
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
69 @#wait mount
70 @sleep 10
71 @# At this point jobid=3 should be blocked waiting for 
72 @#  the sysop to create a new Volume, so cancel the job
73 cancel jobid=3
74 wait
75 messages
76 @$out ${cwd}/tmp/log4.out
77 list volume pool=Special
78 @# 
79 @# now do a restore
80 @#
81 @$out ${cwd}/tmp/log2.out
82 restore where=${cwd}/tmp/bacula-restores select all storage=tape done
83 yes
84 wait
85 messages
86 quit
87 END_OF_DATA
88
89 run_bacula
90 check_for_zombie_jobs storage=tape
91 stop_bacula
92
93 check_two_logs
94 check_restore_diff
95
96
97 ################################################################
98 # Check Catalog definition for ScratchPool and RecyclePool
99 awk '
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
103
104 grep ERR tmp/res
105 if [ $? -eq 0 ]; then
106     print_debug "Found ERR about ScratchPoolId/RecyclePoolId in catalog"
107     dstat=2
108 fi
109
110 if [ `cat tmp/res | wc -l` -ne 2 ]; then
111     print_debug "Can't find all pool records in catalog"
112     dstat=2
113 fi
114
115 ################################################################
116 # Check for the third job that must fail because the SpecialScratch is empty
117
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!!"
121     dstat=2
122 fi
123
124 grep 'Backup Canceled' tmp/log3.out > /dev/null
125 if [ $? -ne 0 ]; then
126     print_debug "Job 3 should be in error"
127     dstat=2
128 fi
129
130 ################################################################
131 # Check Special pool
132
133 if [ `grep TestVolume00 tmp/log4.out | wc -l` -ne 2 ]; then
134     print_debug "Special pool should contain 2 vols"
135     dstat=2
136 fi
137
138 end_test