]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/action-on-purge-test
Make wait longer for better recycling
[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 run job=$JobName yes
25 wait
26 messages
27 @$out $tmp/log2.out
28 restore where=${cwd}/tmp/bacula-restores select all storage=File done
29 yes
30 wait
31 messages
32 @#########################################################
33 @# Test ActionOnPurge=Truncate Volume size should be small
34 @#########################################################
35 @$out $tmp/log3.out
36 purge volume=TestVolume001
37 messages
38 show pool
39 update volume=TestVolume001 volstatus=Read-Only
40 @$out $tmp/log1.out
41 label storage=File volume=TestVolume002
42 run job=$JobName yes
43 wait
44 messages
45 @#########################################################
46 @# Test ActionOnPurge=Truncate, then update it to None
47 @# Volume size should be normal
48 @#########################################################
49 update volume=TestVolume002 actiononpurge=none
50 purge volume=TestVolume002
51 @#########################################################
52 @# Display catalog settings for Pool and Media
53 @#########################################################
54 @$out $tmp/log4.out
55 sql
56 select VolumeName, ActionOnPurge FROM Media;
57 select Name, ActionOnPurge FROM Pool;
58
59 quit
60 END_OF_DATA
61
62 run_bacula
63 check_for_zombie_jobs storage=File 
64 stop_bacula
65
66 check_two_logs
67 check_restore_diff
68
69 perl -e "die 'Volume size too big' if (-s '$tmp/TestVolume001' > 4096)"
70 if [ $? != 0 ]; then
71     print_debug `ls -l $tmp/TestVolume001`
72     bstat=2
73 fi
74
75 perl -e "die 'Volume size too small' if (-s '$tmp/TestVolume002' < 4096)"
76 if [ $? != 0 ]; then
77     print_debug `ls -l $tmp/TestVolume002`
78     bstat=2
79 fi
80
81 print_debug "Test if Pool record is ok"
82 r=`awk '/Default/ { print $4 }' $tmp/log4.out`
83 if [ "$r" != 1 ]; then
84     print_debug "ActionOnPurge on Pool record should be 1"
85     bstat=2
86 fi
87
88 print_debug "Test TestVolume001 if Media record is ok"
89 r=`awk '/TestVolume001/ { print $4 }' $tmp/log4.out`
90 if [ "$r" != 1 ]; then
91     print_debug "ActionOnPurge on Media record should be 1"
92     bstat=2
93 fi
94
95 print_debug "Test TestVolume002 if Media record is ok"
96 r=`awk '/TestVolume002/ { print $4 }' $tmp/log4.out`
97 if [ "$r" != 0 ]; then
98     print_debug "ActionOnPurge on Media record should be 0"
99     bstat=2
100 fi
101
102 end_test