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