]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/action-on-purge-test
Tweak action-on-purge test
[bacula/bacula] / regress / tests / action-on-purge-test
1 #!/bin/sh
2 #
3 #
4 TestName="action-on-purge-test"
5 JobName=AOP
6 . scripts/functions
7
8 cwd=`pwd`
9 scripts/cleanup
10 scripts/copy-test-confs
11
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
15
16 change_jobname CompressedTest $JobName
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 label storage=File volume=TestVolume002
25 run level=full job=$JobName yes
26 wait
27 messages
28 @$out $tmp/log2.out
29 restore where=${cwd}/tmp/bacula-restores select all storage=File done
30 yes
31 wait
32 messages
33 @#########################################################
34 @# Run a second job on TestVolume002
35 @#########################################################
36 @$out $tmp/log3.out
37 update volume=TestVolume001 volstatus=Used
38 messages
39 show pool
40 @$out $tmp/log1.out
41 run level=full job=$JobName yes
42 wait
43 messages
44 @#########################################################
45 @# Run a third job that will wait, and purge volume
46 @#########################################################
47 @$out $tmp/log3.out
48 update volume=TestVolume002 volstatus=Used
49 messages
50 @$out $tmp/log1.out
51 run level=full job=$JobName yes
52 @#wait mount
53 @sleep 5
54 messages
55 list volume
56 @# should continue on TestVolume001
57 sql
58 select VolumeName, ActionOnPurge FROM Media;
59
60 setdebug level=400 director
61 purge volume=TestVolume001
62 list volume
63 sql
64 select VolumeName, ActionOnPurge FROM Media;
65
66 mount storage=File
67 wait
68 @#########################################################
69 @# Test ActionOnPurge=Truncate Volume size should be small
70 @#########################################################
71 purge volume=TestVolume001
72 list volume
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 @#########################################################
82 @$out $tmp/log4.out
83 sql
84 select VolumeName, ActionOnPurge FROM Media;
85 select Name, ActionOnPurge FROM Pool;
86
87 quit
88 END_OF_DATA
89
90 run_bacula
91 check_for_zombie_jobs storage=File 
92 stop_bacula
93
94 check_two_logs
95 check_restore_diff
96
97 perl -e "die 'Volume size too big' if (-s '$tmp/TestVolume001' > 4096)"
98 if [ $? != 0 ]; then
99     print_debug `ls -l $tmp/TestVolume001`
100     bstat=2
101 fi
102
103 perl -e "die 'Volume size too small' if (-s '$tmp/TestVolume002' < 4096)"
104 if [ $? != 0 ]; then
105     print_debug `ls -l $tmp/TestVolume002`
106     bstat=2
107 fi
108
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"
113     bstat=2
114 fi
115
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"
120     bstat=2
121 fi
122
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"
127     bstat=2
128 fi
129
130 end_test