3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
9 TestName="duplicate-job-test"
13 scripts/copy-test-confs
16 echo "${cwd}/build/ChangeLog" >${cwd}/tmp/file-list
18 # increase the maximum concurrent jobs for FD, SD and DIR
19 perl -Mscripts::functions -e 'set_maximum_concurrent_jobs("$conf/bacula-dir.conf",100)'
20 perl -Mscripts::functions -e 'set_maximum_concurrent_jobs("$conf/bacula-sd.conf",100)'
21 perl -Mscripts::functions -e 'set_maximum_concurrent_jobs("$conf/bacula-fd.conf",100)'
23 # extract a Job and add a runscript on it
24 perl -Mscripts::functions \
25 -e "extract_resource('$conf/bacula-dir.conf', 'Job', 'CompressedTest')" \
26 | sed 's%Standard%Standard; ClientRunBeforeJob="sleep 6"%' > $tmp/1
30 echo 's%CompressedTest%AllowDuplicateYes%' > $outf
31 echo 's%Backup%Backup; AllowDuplicateJobs = yes%' >> $outf
32 sed -f $outf $tmp/1 >> $conf/bacula-dir.conf
34 echo 's%CompressedTest%CancelLowerLevelDuplicatesYes%' > $outf
35 echo 's%Backup%Backup; AllowDuplicateJobs = no; CancelLowerLevelDuplicates=yes%' >> $outf
36 sed -f $outf $tmp/1 >> $conf/bacula-dir.conf
38 echo 's%CompressedTest%CancelQueueDuplicatesYes%' > $outf
39 echo 's%Backup%Backup; AllowDuplicateJobs = no;CancelLowerLevelDuplicates=no;CancelQueuedDuplicates=yes %' >> $outf
40 sed -f $outf $tmp/1 >> $conf/bacula-dir.conf
42 echo 's%CompressedTest%CancelRunningDuplicatesYes%' > $outf
43 echo 's%Backup%Backup; AllowDuplicateJobs = no;CancelLowerLevelDuplicates=no;CancelQueuedDuplicates=no; CancelRunningDuplicates=yes%' >> $outf
44 sed -f $outf $tmp/1 >> $conf/bacula-dir.conf
46 echo 's%CompressedTest%CancelRunningDuplicatesNo%' > $outf
47 echo 's%Backup%Backup; AllowDuplicateJobs = no;CancelLowerLevelDuplicates=no;CancelQueuedDuplicates=no; CancelRunningDuplicates=no%' >> $outf
48 sed -f $outf $tmp/1 >> $conf/bacula-dir.conf
50 when=`perl -Mscripts::functions -e "get_time(300)"`
54 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
57 @$out ${cwd}/tmp/log1.out
59 label storage=File volume=TestVolume001 slot=1 drive=0
60 @#setdebug level=100 storage=File
61 @##############################################
62 @# AllowDuplicates = Yes, both jobs should work
63 @##############################################
64 run comment="Should work" level=Full job=AllowDuplicateYes yes
66 run comment="Should work" level=Full job=AllowDuplicateYes yes
70 @###############################################################
71 @# Run two jobs with the same level and see wich one is canceled
72 @###############################################################
73 run comment="Should work" level=Full job=CancelLowerLevelDuplicatesYes yes
75 run comment="Should fail" level=Full job=CancelLowerLevelDuplicatesYes yes
78 @####################################################################
79 @# Run two jobs with the different level and see wich one is canceled
80 @####################################################################
81 run comment="Should fail" level=Incremental job=CancelLowerLevelDuplicatesYes yes
83 run comment="Should work" level=Full job=CancelLowerLevelDuplicatesYes yes
86 run comment="Should fail" level=Differential job=CancelLowerLevelDuplicatesYes yes
88 run comment="Should work" level=Full job=CancelLowerLevelDuplicatesYes yes
91 run comment="Should work" level=Differential job=CancelLowerLevelDuplicatesYes yes
93 run comment="Should fail" level=Incremental job=CancelLowerLevelDuplicatesYes yes
96 @#####################################################################################
97 @# Run two jobs with the different level and see wich one is canceled (reversed order)
98 @#####################################################################################
99 run comment="Should work" level=Full job=CancelLowerLevelDuplicatesYes yes
101 run comment="Should fail" level=Incremental job=CancelLowerLevelDuplicatesYes yes
105 @####################################################################
106 @# Run two jobs, the second one can't cancel the 1st, and should fail
107 @####################################################################
108 run comment="Should work" level=Full job=CancelQueueDuplicatesYes yes
110 run comment="Should fail" level=Full job=CancelQueueDuplicatesYes yes
113 @#################################################################
114 @# The first job should stay queued, the second one will cancel it
115 @#################################################################
116 run comment="Should fail" level=Full job=CancelQueueDuplicatesYes when="$when" yes
118 run comment="Should work" level=Full job=CancelQueueDuplicatesYes yes
122 @########################################
123 @# The second job will kill the first one
124 @########################################
125 run comment="Should fail" level=Full job=CancelRunningDuplicatesYes yes
127 run comment="Should work" level=Full job=CancelRunningDuplicatesYes yes
131 @##########################
132 @# The second job won't run
133 @##########################
134 run comment="Should work" level=Full job=CancelRunningDuplicatesNo yes
136 run comment="Should fail" level=Full job=CancelRunningDuplicatesNo yes
141 SELECT JobId, Name, Level, Comment, JobStatus from Job
142 WHERE Comment='Should fail' and JobStatus='T' ORDER By JobId;
146 SELECT JobId, Name, Level, Comment, JobStatus from Job
147 WHERE Comment='Should work' and JobStatus != 'T' ORDER By JobId;
151 SELECT JobId, Name, Level, Comment, JobStatus from Job order by JobId;
157 check_for_zombie_jobs storage=File
163 grep '^| *[0-9]' $tmp/log7.out > /dev/null
165 print_debug "ERROR: Found errors in $tmp/log7.out"
166 print_debug `cat $tmp/log7.out`
170 grep '^| *[0-9]' $tmp/log8.out > /dev/null
172 print_debug "ERROR: Found errors in $tmp/log8.out"
173 print_debug `cat $tmp/log8.out`
177 nb=`grep '^| *[0-9]' $tmp/log9.out | wc -l`
178 if [ $nb -lt 10 ]; then
179 print_debug "ERROR: less than 10 lines of SQL output in $tmp/log9.out"
180 print_debug `cat $tmp/log9.out`