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