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