]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/action-on-purge-test
Make out of freespace non-fatal for removable devices -- i.e. behaves like tape
[bacula/bacula] / regress / tests / action-on-purge-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6 #
7 TestName="action-on-purge-test"
8 JobName=FIFOTest
9 . scripts/functions
10
11 cwd=`pwd`
12 scripts/cleanup
13 scripts/copy-test-confs
14
15 echo $src > $tmp/file-list
16
17 sed 's/Pool Type = Backup/Pool Type = Backup; ActionOnPurge = Truncate/' $conf/bacula-dir.conf > $tmp/1
18 cp $tmp/1 $conf/bacula-dir.conf
19
20 start_test
21
22 cat >tmp/bconcmds <<END_OF_DATA
23 @$out /dev/null
24 messages
25 @$out $tmp/log1.out
26 label storage=File volume=TestVolume001
27 @########################################################
28 @# Run a first job on TestVolume001
29 @########################################################
30 run level=full job=$JobName yes
31 wait
32 messages
33 @#@$out $tmp/log2.out
34 @#restore where=${cwd}/tmp/bacula-restores select all storage=File done
35 @#yes
36 @#wait
37 @#messages
38 @#########################################################
39 @# Run a second job on TestVolume002
40 @#########################################################
41 @$out $tmp/log3.out
42 label storage=File volume=TestVolume002
43 update volume=TestVolume001 volstatus=Used
44 messages
45 show pool
46 @$out $tmp/log1.out
47 run level=full job=$JobName yes
48 wait
49 messages
50 @#########################################################
51 @# Run a 3th job on TestVolume003
52 @#########################################################
53 @$out $tmp/log3.out
54 update volume=TestVolume002 volstatus=Used
55 label storage=File volume=TestVolume003
56 messages
57 show pool
58 @$out $tmp/log1.out
59 run level=full job=$JobName yes
60 wait
61 messages
62 @#########################################################
63 @# Run a 4th job
64 @#########################################################
65 @$out $tmp/log5.out
66 update volume=TestVolume003 volstatus=Used
67 label storage=File volume=TestVolume004
68 messages
69 @$out $tmp/log1.out
70 run level=full job=$JobName yes
71 wait
72 messages
73 list volume
74 @$out $tmp/log1.out
75 update volume=TestVolume004 volstatus=Used
76 label storage=File volume=TestVolume005
77 run level=full job=$JobName yes
78 wait
79 messages
80 @$out $tmp/log6.out
81 @#########################################################
82 @# tests
83 @#########################################################
84 update volume=TestVolume002 actiononpurge=none
85 purge volume=TestVolume001
86 purge volume=TestVolume002
87 purge volume=TestVolume003
88 purge volume=TestVolume004
89 list volume
90 sql
91 select VolumeName, VolStatus, ActionOnPurge FROM Media;
92
93 setdebug level=100 director
94 quit
95 END_OF_DATA
96
97 run_bacula
98 check_for_zombie_jobs storage=File
99
100 print_debug "Check all media"
101 for i in 1 2 3 4 5 ; do
102   size=`du -b $tmp/TestVolume00$i|cut -f1`
103   if test $size -lt 5000 ; then
104      print_debug "ERROR 2: Volume TestVolum00$i is too small $size"
105      ls -l $tmp/TestVolume00$i
106      estat=2
107   fi
108 done
109
110 echo "purge volume=TestVolume001 action storage=File" > $tmp/bconcmds
111 run_bconsole
112
113 for i in  2 3 4 5 ; do
114   size=`du -b $tmp/TestVolume00$i|cut -f1`
115   if test $size -lt 5000 ; then
116      print_debug "ERROR 3: Volume TestVolum00$i is too small $size"
117      ls -l $tmp/TestVolume00$i
118      estat=3
119   fi
120 done
121 for i in 1 ; do
122   size=`du -b $tmp/TestVolume00$i|cut -f1`
123   if test $size -gt 5000 ; then
124      print_debug "ERROR 4: Volume TestVolum00$i is not truncated (too big) $size"
125      ls -l $tmp/TestVolume00$i
126      estat=4
127   fi
128 done
129
130 echo "purge volume action storage=File" > $tmp/bconcmds
131 run_bconsole
132
133 for i in  2 5 ; do
134   size=`du -b $tmp/TestVolume00$i|cut -f1`
135   if test $size -lt 5000 ; then
136      print_debug "ERROR 5: Volume TestVolum00$i is too small $size"
137      ls -l $tmp/TestVolume00$i
138      estat=5
139   fi
140 done
141 for i in 1 3 4 ; do
142   size=`du -b $tmp/TestVolume00$i|cut -f1`
143   if test $size -gt 5000 ; then
144      print_debug "ERROR 6: Volume TestVolum00$i is not truncated (too big) $size"
145      ls -l $tmp/TestVolume00$i
146      estat=6
147   fi
148 done
149
150 cat <<END_OF_DATA > $tmp/bconcmds
151 @#########################################################
152 @# Display catalog settings for Pool and Media
153 @#########################################################
154 @$out $tmp/log4.out
155 setdebug level=0 director
156 sql
157 select VolumeName, ActionOnPurge FROM Media;
158 select Name, ActionOnPurge FROM Pool;
159
160 wait
161 quit
162 END_OF_DATA
163
164 run_bconsole
165
166 stop_bacula
167
168 touch $tmp/log2.out
169 check_two_logs
170
171 print_debug "Test if Pool record is ok"
172 r=`awk '/Default/ { print $4 }' $tmp/log4.out`
173 if [ "$r" != 1 ]; then
174     print_debug "ActionOnPurge on Pool record should be 1 ($r)"
175     estat=2
176 fi
177
178 print_debug "Test TestVolume001 if Media record is ok"
179 r=`awk '/TestVolume001/ { print $4 }' $tmp/log4.out`
180 if [ "$r" != 1 ]; then
181     print_debug "ActionOnPurge on Media record should be 1"
182     estat=2
183 fi
184
185 print_debug "Test TestVolume002 if Media record is ok"
186 r=`awk '/TestVolume002/ { print $4 }' $tmp/log4.out`
187 if [ "$r" != 0 ]; then
188     print_debug "ActionOnPurge on Media record should be 0"
189     estat=2
190 fi
191
192 end_test