]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/duplicate-job-test
Make out of freespace non-fatal for removable devices -- i.e. behaves like tape
[bacula/bacula] / regress / tests / 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="duplicate-job-test"
10 . scripts/functions
11
12 scripts/cleanup
13 scripts/copy-test-confs
14
15
16 echo "${cwd}/build/ChangeLog" >${cwd}/tmp/file-list
17
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)'
22
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
27
28
29 outf="$tmp/sed_tmp"
30 echo 's%CompressedTest%AllowDuplicateYes%' > $outf
31 echo 's%Backup%Backup; AllowDuplicateJobs = yes%' >> $outf
32 sed -f $outf $tmp/1 >> $conf/bacula-dir.conf
33
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
37
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
41
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
45
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
49
50 when=`perl -Mscripts::functions -e "get_time(300)"`
51
52 start_test
53       
54 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
55 @output /dev/null
56 messages
57 @$out ${cwd}/tmp/log1.out
58 messages
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
65 @sleep 2
66 run comment="Should work" level=Full job=AllowDuplicateYes yes
67 wait
68 messages
69 @$out $tmp/log3.out
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
74 @sleep 2
75 run comment="Should fail" level=Full job=CancelLowerLevelDuplicatesYes yes
76 wait
77 messages
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
82 @sleep 2
83 run comment="Should work" level=Full job=CancelLowerLevelDuplicatesYes yes
84 wait
85 messages
86 run comment="Should fail" level=Differential job=CancelLowerLevelDuplicatesYes yes
87 @sleep 2
88 run comment="Should work" level=Full job=CancelLowerLevelDuplicatesYes yes
89 wait
90 messages
91 run comment="Should work" level=Differential job=CancelLowerLevelDuplicatesYes yes
92 @sleep 2
93 run comment="Should fail" level=Incremental job=CancelLowerLevelDuplicatesYes yes
94 wait
95 messages
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
100 @sleep 2
101 run comment="Should fail" level=Incremental job=CancelLowerLevelDuplicatesYes yes
102 wait
103 messages
104 @$out $tmp/log4.out
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
109 @sleep 2
110 run comment="Should fail" level=Full job=CancelQueueDuplicatesYes yes
111 wait
112 messages
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
117 @sleep 2
118 run comment="Should work" level=Full job=CancelQueueDuplicatesYes yes
119 wait
120 messages
121 @$out $tmp/log5.out
122 @########################################
123 @# The second job will kill the first one
124 @########################################
125 run comment="Should fail" level=Full job=CancelRunningDuplicatesYes yes
126 @sleep 2
127 run comment="Should work" level=Full job=CancelRunningDuplicatesYes yes
128 wait
129 messages
130 @$out $tmp/log6.out
131 @##########################
132 @# The second job won't run
133 @##########################
134 run comment="Should work" level=Full job=CancelRunningDuplicatesNo yes
135 @sleep 2
136 run comment="Should fail" level=Full job=CancelRunningDuplicatesNo yes
137 wait
138 messages
139 @$out $tmp/log7.out
140 sql
141 SELECT JobId, Name, Level, Comment, JobStatus from Job 
142 WHERE Comment='Should fail' and JobStatus='T' ORDER By JobId;
143
144 @$out $tmp/log8.out
145 sql
146 SELECT JobId, Name, Level, Comment, JobStatus from Job
147 WHERE Comment='Should work' and JobStatus != 'T' ORDER By JobId;
148
149 @$out $tmp/log9.out
150 sql
151 SELECT JobId, Name, Level, Comment, JobStatus from Job order by JobId;
152
153 quit
154 END_OF_DATA
155
156 run_bacula
157 check_for_zombie_jobs storage=File
158 stop_bacula
159
160 touch $tmp/log2.out
161 check_two_logs
162
163 grep '^| *[0-9]' $tmp/log7.out > /dev/null
164 if [ $? = 0 ]; then
165     print_debug "ERROR: Found errors in $tmp/log7.out"
166     print_debug `cat $tmp/log7.out`
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"
173     print_debug `cat $tmp/log8.out`
174     estat=1
175 fi
176
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`
181     estat=1
182 fi
183
184 end_test