]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/action-on-purge-test
regress: Update ActionOnPurge test
[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 echo $cwd/tmp/bfifo >> $tmp/file-list
14 rm -f ${cwd}/tmp/bfifo
15 mkfifo ${cwd}/tmp/bfifo
16 # send a file into the fifo
17 (
18 echo test1 >$cwd/tmp/bfifo
19 print_debug FIRST ECHO
20 /bin/sleep 5
21 echo test2 >$cwd/tmp/bfifo
22 print_debug SECOND ECHO
23 /bin/sleep 5
24 echo test2 >$cwd/tmp/bfifo
25 print_debug THIRD ECHO
26 /bin/sleep 5
27 cat > $cwd/tmp/bfifo &
28 )&
29
30 sed 's/Pool Type = Backup/Pool Type = Backup; ActionOnPurge = Truncate/' $conf/bacula-dir.conf > $tmp/1
31 cp $tmp/1 $conf/bacula-dir.conf
32
33 start_test
34
35 cat >tmp/bconcmds <<END_OF_DATA
36 @$out /dev/null
37 messages
38 @$out $tmp/log1.out
39 label storage=File volume=TestVolume001
40 @########################################################
41 @# Run a first job on TestVolume001
42 @########################################################
43 run level=full job=$JobName yes
44 wait
45 messages
46 @#@$out $tmp/log2.out
47 @#restore where=${cwd}/tmp/bacula-restores select all storage=File done
48 @#yes
49 @#wait
50 @#messages
51 @#########################################################
52 @# Run a second job on TestVolume002
53 @#########################################################
54 @$out $tmp/log3.out
55 label storage=File volume=TestVolume002
56 update volume=TestVolume001 volstatus=Used
57 messages
58 show pool
59 @$out $tmp/log1.out
60 run level=full job=$JobName yes
61 wait
62 messages
63 @#########################################################
64 @# Run a 3th job on TestVolume003
65 @#########################################################
66 @$out $tmp/log3.out
67 update volume=TestVolume002 volstatus=Used
68 label storage=File volume=TestVolume003
69 messages
70 show pool
71 @$out $tmp/log1.out
72 run level=full job=$JobName yes
73 wait
74 messages
75 @#########################################################
76 @# Run a 4th job that will wait on fifo, and try to purge volume
77 @#########################################################
78 @$out $tmp/log5.out
79 update volume=TestVolume003 volstatus=Used
80 label storage=File volume=TestVolume004
81 messages
82 @$out $tmp/log1.out
83 run level=full job=$JobName yes
84 @#wait mount
85 @sleep 5
86 messages
87 list volume
88 setdebug level=100 storage=File
89 @# try to purge TestVolume004 (should fail, in use)
90 purge volume=TestVolume004 
91 @# try to purge TestVolume003 (should fail, drive busy)
92 purge volume=TestVolume003
93 setdebug level=0 storage=File
94 list volume
95 sql
96 select VolumeName, VolStatus, ActionOnPurge FROM Media;
97
98 wait
99 @#########################################################
100 @# Test ActionOnPurge=Truncate Volume size should be small
101 @#########################################################
102 purge volume=TestVolume001
103 list volume
104 @#########################################################
105 @# Test ActionOnPurge=Truncate, then update it to None
106 @# Volume size should be normal
107 @#########################################################
108 update volume=TestVolume002 actiononpurge=none
109 purge volume=TestVolume002
110 @#########################################################
111 @# Display catalog settings for Pool and Media
112 @#########################################################
113 @$out $tmp/log4.out
114 sql
115 select VolumeName, ActionOnPurge FROM Media;
116 select Name, ActionOnPurge FROM Pool;
117
118 wait
119 quit
120 END_OF_DATA
121
122 run_bacula
123 check_for_zombie_jobs storage=File 
124 stop_bacula
125
126 touch $tmp/log2.out
127 check_two_logs
128
129 print_debug "Test TestVolume001 size"
130 perl -e "die 'Volume size too big' if (-s '$tmp/TestVolume001' > 4096)"
131 if [ $? != 0 ]; then
132     print_debug `ls -l $tmp/TestVolume001`
133     estat=2
134 fi
135
136 print_debug "Test TestVolume002 size"
137 perl -e "die 'Volume size too small' if (-s '$tmp/TestVolume002' < 4096)"
138 if [ $? != 0 ]; then
139     print_debug `ls -l $tmp/TestVolume002`
140     estat=2
141 fi
142
143 print_debug "Test TestVolume003 size (drive busy)"
144 perl -e "die 'Volume size too small' if (-s '$tmp/TestVolume003' < 4096)"
145 if [ $? != 0 ]; then
146     print_debug `ls -l $tmp/TestVolume003`
147     estat=2
148 fi
149
150 print_debug "Test if Pool record is ok"
151 r=`awk '/Default/ { print $4 }' $tmp/log4.out`
152 if [ "$r" != 1 ]; then
153     print_debug "ActionOnPurge on Pool record should be 1 ($r)"
154     estat=2
155 fi
156
157 print_debug "Test TestVolume001 if Media record is ok"
158 r=`awk '/TestVolume001/ { print $4 }' $tmp/log4.out`
159 if [ "$r" != 1 ]; then
160     print_debug "ActionOnPurge on Media record should be 1"
161     estat=2
162 fi
163
164 print_debug "Test TestVolume002 if Media record is ok"
165 r=`awk '/TestVolume002/ { print $4 }' $tmp/log4.out`
166 if [ "$r" != 0 ]; then
167     print_debug "ActionOnPurge on Media record should be 0"
168     estat=2
169 fi
170
171 end_test