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