]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/action-on-purge-test
regress: update 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 @# Test ActionOnPurge=Truncate Volume size should be small
46 @#########################################################
47 purge volume=TestVolume001
48 @#########################################################
49 @# Test ActionOnPurge=Truncate, then update it to None
50 @# Volume size should be normal
51 @#########################################################
52 update volume=TestVolume002 actiononpurge=none
53 purge volume=TestVolume002
54 @#########################################################
55 @# Display catalog settings for Pool and Media
56 @#########################################################
57 @$out $tmp/log4.out
58 sql
59 select VolumeName, ActionOnPurge FROM Media;
60 select Name, ActionOnPurge FROM Pool;
61
62 quit
63 END_OF_DATA
64
65 run_bacula
66 check_for_zombie_jobs storage=File 
67 stop_bacula
68
69 check_two_logs
70 check_restore_diff
71
72 perl -e "die 'Volume size too big' if (-s '$tmp/TestVolume001' > 4096)"
73 if [ $? != 0 ]; then
74     print_debug `ls -l $tmp/TestVolume001`
75     bstat=2
76 fi
77
78 perl -e "die 'Volume size too small' if (-s '$tmp/TestVolume002' < 4096)"
79 if [ $? != 0 ]; then
80     print_debug `ls -l $tmp/TestVolume002`
81     bstat=2
82 fi
83
84 print_debug "Test if Pool record is ok"
85 r=`awk '/Default/ { print $4 }' $tmp/log4.out`
86 if [ "$r" != 1 ]; then
87     print_debug "ActionOnPurge on Pool record should be 1"
88     bstat=2
89 fi
90
91 print_debug "Test TestVolume001 if Media record is ok"
92 r=`awk '/TestVolume001/ { print $4 }' $tmp/log4.out`
93 if [ "$r" != 1 ]; then
94     print_debug "ActionOnPurge on Media record should be 1"
95     bstat=2
96 fi
97
98 print_debug "Test TestVolume002 if Media record is ok"
99 r=`awk '/TestVolume002/ { print $4 }' $tmp/log4.out`
100 if [ "$r" != 0 ]; then
101     print_debug "ActionOnPurge on Media record should be 0"
102     bstat=2
103 fi
104
105 end_test