3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
9 TestName="tls-duplicate-job-test"
13 scripts/copy-tls-confs
14 echo "${cwd}/build/ChangeLog" >${cwd}/tmp/file-list
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)'
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
28 echo 's%CompressedTest%AllowDuplicateYes%' > $outf
29 echo 's%Backup%Backup; AllowDuplicateJobs = yes%' >> $outf
30 sed -f $outf $tmp/1 >> $conf/bacula-dir.conf
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
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
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
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
48 when=`perl -Mscripts::functions -e "get_time(300)"`
52 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
55 @$out ${cwd}/tmp/log1.out
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
64 run comment="Should work" level=Full job=AllowDuplicateYes yes
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
73 run comment="Should fail" level=Full job=CancelLowerLevelDuplicatesYes yes
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
81 run comment="Should work" level=Full job=CancelLowerLevelDuplicatesYes yes
84 run comment="Should fail" level=Differential job=CancelLowerLevelDuplicatesYes yes
86 run comment="Should work" level=Full job=CancelLowerLevelDuplicatesYes yes
89 run comment="Should work" level=Differential job=CancelLowerLevelDuplicatesYes yes
91 run comment="Should fail" level=Incremental job=CancelLowerLevelDuplicatesYes yes
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
99 run comment="Should fail" level=Incremental job=CancelLowerLevelDuplicatesYes yes
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
108 run comment="Should fail" level=Full job=CancelQueueDuplicatesYes yes
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
116 run comment="Should work" level=Full job=CancelQueueDuplicatesYes yes
120 @########################################
121 @# The second job will kill the first one
122 @########################################
123 run comment="Should fail" level=Full job=CancelRunningDuplicatesYes yes
125 run comment="Should work" level=Full job=CancelRunningDuplicatesYes yes
129 @##########################
130 @# The second job won't run
131 @##########################
132 run comment="Should work" level=Full job=CancelRunningDuplicatesNo yes
134 run comment="Should fail" level=Full job=CancelRunningDuplicatesNo yes
139 SELECT JobId, Name, Level, Comment, JobStatus from Job
140 WHERE Comment='Should fail' and JobStatus='T' ORDER By JobId;
144 SELECT JobId, Name, Level, Comment, JobStatus from Job
145 WHERE Comment='Should work' and JobStatus != 'T' ORDER By JobId;
149 SELECT JobId, Name, Level, Comment, JobStatus from Job order by JobId;
155 check_for_zombie_jobs storage=File
161 grep '^| *[0-9]' $tmp/log7.out > /dev/null
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
170 grep '^| *[0-9]' $tmp/log8.out > /dev/null
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
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