4 TestName="action-on-purge-test"
10 scripts/copy-test-confs
12 echo $src > $tmp/file-list
13 sed 's/Pool Type = Backup/Pool Type = Backup; ActionOnPurge = Truncate/' $conf/bacula-dir.conf > $tmp/1
14 cp $tmp/1 $conf/bacula-dir.conf
16 change_jobname CompressedTest $JobName
19 cat >tmp/bconcmds <<END_OF_DATA
23 label storage=File volume=TestVolume001
24 label storage=File volume=TestVolume002
25 run level=full job=$JobName yes
29 restore where=${cwd}/tmp/bacula-restores select all storage=File done
33 @#########################################################
34 @# Run a second job on TestVolume002
35 @#########################################################
37 update volume=TestVolume001 volstatus=Used
41 run level=full job=$JobName yes
44 @#########################################################
45 @# Run a third job that will wait, and purge volume
46 @#########################################################
48 update volume=TestVolume002 volstatus=Used
51 run level=full job=$JobName yes
56 @# should continue on TestVolume001
58 select VolumeName, ActionOnPurge FROM Media;
60 setdebug level=400 director
61 purge volume=TestVolume001
64 select VolumeName, ActionOnPurge FROM Media;
68 @#########################################################
69 @# Test ActionOnPurge=Truncate Volume size should be small
70 @#########################################################
71 purge volume=TestVolume001
73 @#########################################################
74 @# Test ActionOnPurge=Truncate, then update it to None
75 @# Volume size should be normal
76 @#########################################################
77 update volume=TestVolume002 actiononpurge=none
78 purge volume=TestVolume002
79 @#########################################################
80 @# Display catalog settings for Pool and Media
81 @#########################################################
84 select VolumeName, ActionOnPurge FROM Media;
85 select Name, ActionOnPurge FROM Pool;
91 check_for_zombie_jobs storage=File
97 perl -e "die 'Volume size too big' if (-s '$tmp/TestVolume001' > 4096)"
99 print_debug `ls -l $tmp/TestVolume001`
103 perl -e "die 'Volume size too small' if (-s '$tmp/TestVolume002' < 4096)"
105 print_debug `ls -l $tmp/TestVolume002`
109 print_debug "Test if Pool record is ok"
110 r=`awk '/Default/ { print $4 }' $tmp/log4.out`
111 if [ "$r" != 1 ]; then
112 print_debug "ActionOnPurge on Pool record should be 1"
116 print_debug "Test TestVolume001 if Media record is ok"
117 r=`awk '/TestVolume001/ { print $4 }' $tmp/log4.out`
118 if [ "$r" != 1 ]; then
119 print_debug "ActionOnPurge on Media record should be 1"
123 print_debug "Test TestVolume002 if Media record is ok"
124 r=`awk '/TestVolume002/ { print $4 }' $tmp/log4.out`
125 if [ "$r" != 0 ]; then
126 print_debug "ActionOnPurge on Media record should be 0"