]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/tls-duplicate-job-test
Backport from Bacula Enterprise
[bacula/bacula] / regress / tests / tls-duplicate-job-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 #
9 TestName="tls-duplicate-job-test"
10 . scripts/functions
11
12 scripts/cleanup
13 scripts/copy-tls-confs
14 echo "${cwd}/build/ChangeLog" >${cwd}/tmp/file-list
15
16 # increase the maximum concurrent jobs for FD, SD and DIR
17 perl -Mscripts::functions -e 'set_maximum_concurrent_jobs("$conf/bacula-dir.conf",100)'
18 perl -Mscripts::functions -e 'set_maximum_concurrent_jobs("$conf/bacula-sd.conf",100)'
19 perl -Mscripts::functions -e 'set_maximum_concurrent_jobs("$conf/bacula-fd.conf",100)'
20
21 # extract a Job and add a runscript on it
22 perl -Mscripts::functions \
23     -e "extract_resource('$conf/bacula-dir.conf', 'Job', 'CompressedTest')" \
24     | sed 's%Standard%Standard; ClientRunBeforeJob="sleep 6"%' > $tmp/1
25
26
27 outf="$tmp/sed_tmp"
28 echo 's%CompressedTest%AllowDuplicateYes%' > $outf
29 echo 's%Backup%Backup; AllowDuplicateJobs = yes%' >> $outf
30 sed -f $outf $tmp/1 >> $conf/bacula-dir.conf
31
32 echo 's%CompressedTest%CancelLowerLevelDuplicatesYes%' > $outf
33 echo 's%Backup%Backup; AllowDuplicateJobs = no; CancelLowerLevelDuplicates=yes%' >> $outf
34 sed -f $outf $tmp/1 >> $conf/bacula-dir.conf
35
36 echo 's%CompressedTest%CancelQueueDuplicatesYes%' > $outf
37 echo 's%Backup%Backup; AllowDuplicateJobs = no;CancelLowerLevelDuplicates=no;CancelQueuedDuplicates=yes %' >> $outf
38 sed -f $outf $tmp/1 >> $conf/bacula-dir.conf
39
40 echo 's%CompressedTest%CancelRunningDuplicatesYes%' > $outf
41 echo 's%Backup%Backup; AllowDuplicateJobs = no;CancelLowerLevelDuplicates=no;CancelQueuedDuplicates=no; CancelRunningDuplicates=yes%' >> $outf
42 sed -f $outf $tmp/1 >> $conf/bacula-dir.conf
43
44 echo 's%CompressedTest%CancelRunningDuplicatesNo%' > $outf
45 echo 's%Backup%Backup; AllowDuplicateJobs = no;CancelLowerLevelDuplicates=no;CancelQueuedDuplicates=no; CancelRunningDuplicates=no%' >> $outf
46 sed -f $outf $tmp/1 >> $conf/bacula-dir.conf
47
48 when=`perl -Mscripts::functions -e "get_time(300)"`
49
50 start_test
51       
52 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
53 @output /dev/null
54 messages
55 @$out ${cwd}/tmp/log1.out
56 messages
57 label storage=File volume=TestVolume001
58 @#setdebug level=100 storage=File
59 @##############################################
60 @# AllowDuplicates = Yes, both jobs should work
61 @##############################################
62 run comment="Should work" level=Full job=AllowDuplicateYes yes
63 @sleep 2
64 run comment="Should work" level=Full job=AllowDuplicateYes yes
65 wait
66 messages
67 @$out $tmp/log3.out
68 @###############################################################
69 @# Run two jobs with the same level and see wich one is canceled
70 @###############################################################
71 run comment="Should work" level=Full job=CancelLowerLevelDuplicatesYes yes
72 @sleep 2
73 run comment="Should fail" level=Full job=CancelLowerLevelDuplicatesYes yes
74 wait
75 messages
76 @####################################################################
77 @# Run two jobs with the different level and see wich one is canceled
78 @####################################################################
79 run comment="Should fail" level=Incremental job=CancelLowerLevelDuplicatesYes yes
80 @sleep 2
81 run comment="Should work" level=Full job=CancelLowerLevelDuplicatesYes yes
82 wait
83 messages
84 run comment="Should fail" level=Differential job=CancelLowerLevelDuplicatesYes yes
85 @sleep 2
86 run comment="Should work" level=Full job=CancelLowerLevelDuplicatesYes yes
87 wait
88 messages
89 run comment="Should work" level=Differential job=CancelLowerLevelDuplicatesYes yes
90 @sleep 2
91 run comment="Should fail" level=Incremental job=CancelLowerLevelDuplicatesYes yes
92 wait
93 messages
94 @#####################################################################################
95 @# Run two jobs with the different level and see wich one is canceled (reversed order)
96 @#####################################################################################
97 run comment="Should work" level=Full job=CancelLowerLevelDuplicatesYes yes
98 @sleep 2
99 run comment="Should fail" level=Incremental job=CancelLowerLevelDuplicatesYes yes
100 wait
101 messages
102 @$out $tmp/log4.out
103 @####################################################################
104 @# Run two jobs, the second one can't cancel the 1st, and should fail
105 @####################################################################
106 run comment="Should work" level=Full job=CancelQueueDuplicatesYes yes
107 @sleep 2
108 run comment="Should fail" level=Full job=CancelQueueDuplicatesYes yes
109 wait
110 messages
111 @#################################################################
112 @# The first job should stay queued, the second one will cancel it
113 @#################################################################
114 run comment="Should fail" level=Full job=CancelQueueDuplicatesYes when="$when" yes
115 @sleep 2
116 run comment="Should work" level=Full job=CancelQueueDuplicatesYes yes
117 wait
118 messages
119 @$out $tmp/log5.out
120 @########################################
121 @# The second job will kill the first one
122 @########################################
123 run comment="Should fail" level=Full job=CancelRunningDuplicatesYes yes
124 @sleep 2
125 run comment="Should work" level=Full job=CancelRunningDuplicatesYes yes
126 wait
127 messages
128 @$out $tmp/log6.out
129 @##########################
130 @# The second job won't run
131 @##########################
132 run comment="Should work" level=Full job=CancelRunningDuplicatesNo yes
133 @sleep 2
134 run comment="Should fail" level=Full job=CancelRunningDuplicatesNo yes
135 wait
136 messages
137 @$out $tmp/log7.out
138 sql
139 SELECT JobId, Name, Level, Comment, JobStatus from Job 
140 WHERE Comment='Should fail' and JobStatus='T' ORDER By JobId;
141
142 @$out $tmp/log8.out
143 sql
144 SELECT JobId, Name, Level, Comment, JobStatus from Job
145 WHERE Comment='Should work' and JobStatus != 'T' ORDER By JobId;
146
147 @$out $tmp/log9.out
148 sql
149 SELECT JobId, Name, Level, Comment, JobStatus from Job order by JobId;
150
151 quit
152 END_OF_DATA
153
154 run_bacula
155 check_for_zombie_jobs storage=File
156 stop_bacula
157
158 touch $tmp/log2.out
159 check_two_logs
160
161 grep '^| *[0-9]' $tmp/log7.out > /dev/null
162 if [ $? = 0 ]; then
163     print_debug "ERROR: Found errors in $tmp/log7.out. Jobs that 'Should fail' are OK (T) and/or Jobs that 'Should work' are in Error (A, a, f, ...)"
164     if [ "$debug" -eq 1 ]; then
165         cat $tmp/log7.out
166     fi
167     estat=1
168 fi
169
170 grep '^| *[0-9]' $tmp/log8.out > /dev/null
171 if [ $? = 0 ]; then
172     print_debug "ERROR: Found errors in $tmp/log8.out. Jobs that 'Should fail' are OK (T) and/or Jobs that 'Should work' are in Error (A, a, f, ...)"
173     if [ "$debug" -eq 1 ]; then
174         cat $tmp/log8.out
175     fi
176     estat=1
177 fi
178
179 nb=`grep '^| *[0-9]' $tmp/log9.out | wc -l`
180 if [ $nb -lt 10 ]; then
181     print_debug "ERROR: less than 10 lines of SQL output in $tmp/log9.out. Jobs that 'Should fail' are OK (T) and/or Jobs that 'Should work' are in Error (A, a, f, ...)"
182     if [ "$debug" -eq 1 ]; then
183         cat $tmp/log9.out
184     fi
185
186     estat=1
187 fi
188
189 end_test