]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/prune-test
regress: Add test that mixes mssql and systemstate
[bacula/bacula] / regress / tests / prune-test
1 #!/bin/sh
2 #
3 # This script will test prune algo 
4 #
5 . scripts/functions
6
7 TestName="prune-test"
8 JobName=NightlySave
9
10 scripts/cleanup
11 scripts/copy-test-confs
12
13 start_test
14
15 echo $PWD/build/po > tmp/file-list
16
17 # We want to have pruning only when doing prune command
18 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "AutoPrune", "No", "Client")'
19 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "Job Retention", "1s", "Client")'
20
21 cat <<EOF > ${cwd}/tmp/bconcmds
22 @$out /dev/null
23 messages
24 @$out $tmp/log1.out
25 label storage=File volume=TestVolume001
26 run job=$JobName level=full yes
27 wait
28 messages
29 @exec "touch $cwd/build/po/fr.po"
30 run job=$JobName level=incremental yes
31 wait
32 messages
33 @exec "touch $cwd/build/po/de.po"
34 run job=$JobName level=incremental yes
35 wait
36 messages
37 @sleep 2
38 @$out $tmp/log3.out
39 @################################################################
40 @# Should not prune anything
41 list jobs
42 prune jobs yes
43 list jobs
44 @$out $tmp/log4.out
45 @################################################################
46 @# Should prune the two firsts incrementals
47 run job=$JobName level=differential yes
48 wait
49 messages
50 @exec "touch $cwd/build/po/es.po"
51 run job=$JobName level=incremental yes
52 wait
53 messages
54 @sleep 2
55 list jobs
56 prune jobs yes
57 list jobs
58 @$out $tmp/log5.out
59 @################################################################
60 @# Should prune the first Full+Diff job
61 run job=$JobName level=full yes
62 wait
63 messages
64 @sleep 2
65 list jobs
66 prune jobs yes
67 list jobs
68 @$out $tmp/log6.out
69 @################################################################
70 run job=$JobName level=incremental yes
71 wait
72 messages
73 @$out $tmp/log2.out
74 restore where=${cwd}/tmp/bacula-restores select all storage=File done
75 yes
76 wait
77 messages
78 @sleep 2
79 @$out $tmp/log6.out
80 @################################################################
81 @# Should prune the restore job and the last incremental job (jobfiles=0)
82 list jobs
83 prune jobs yes
84 list jobs
85 quit
86 EOF
87
88 run_bacula
89
90 check_for_zombie_jobs storage=File
91 stop_bacula
92
93 check_two_logs
94
95 estat=0
96
97 ###############################################################################
98 # Now we will verify that the pruning code is working as expected.  Each time,
99 # we run 'list jobs', 'prune', 'list jobs'. check_prune_list ensures that jobids
100 # in argument are present in the first 'list jobs', the 'prune' command deletes
101 # them (same number), and checks that the last 'list jobs' doesn't contain them
102 # anymore. See scripts/functions.pm for details.
103
104 # nothing should be pruned
105 $bperl -e "check_prune_list('$tmp/log3.out')"
106 estat=$(($estat + $?))
107
108 # jobids 2 and 3 should be pruned
109 # (F I I D) -> (F D)
110 $bperl -e "check_prune_list('$tmp/log4.out',2,3)"
111 estat=$(($estat + $?))
112
113 # (F D I F) -> (F)
114 $bperl -e "check_prune_list('$tmp/log5.out',1,4,5)"
115 estat=$(($estat + $?))
116
117 # (F I R) -> (F)     -- Incremental have 0 file
118 $bperl -e "check_prune_list('$tmp/log6.out',7,8)"
119 estat=$(($estat + $?))
120
121 end_test