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