]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/duplicate-job-test
regress: Check for errors in deplicate-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 @#####################################################################################
75 @# Run two jobs with the different level and see wich one is canceled (reversed order)
76 @#####################################################################################
77 run comment="Should work" level=Full job=CancelLowerLevelDuplicatesYes yes
78 @sleep 2
79 run comment="Should fail" level=Incremental job=CancelLowerLevelDuplicatesYes yes
80 wait
81 messages
82 @$out $tmp/log4.out
83 @####################################################################
84 @# Run two jobs, the second one can't cancel the 1st, and should fail
85 @####################################################################
86 run comment="Should work" level=Full job=CancelQueueDuplicatesYes yes
87 @sleep 2
88 run comment="Should fail" level=Full job=CancelQueueDuplicatesYes yes
89 wait
90 messages
91 @#################################################################
92 @# The first job should stay queued, the second one will cancel it
93 @#################################################################
94 run comment="Should fail" level=Full job=CancelQueueDuplicatesYes when="$when" yes
95 @sleep 2
96 run comment="Should work" level=Full job=CancelQueueDuplicatesYes yes
97 wait
98 messages
99 @$out $tmp/log5.out
100 @########################################
101 @# The second job will kill the first one
102 @########################################
103 run comment="Should fail" level=Full job=CancelRunningDuplicatesYes yes
104 @sleep 2
105 run comment="Should work" level=Full job=CancelRunningDuplicatesYes yes
106 wait
107 messages
108 @$out $tmp/log6.out
109 @##########################
110 @# The second job won't run
111 @##########################
112 run comment="Should work" level=Full job=CancelRunningDuplicatesNo yes
113 @sleep 2
114 run comment="Should fail" level=Full job=CancelRunningDuplicatesNo yes
115 wait
116 messages
117 @$out $tmp/log7.out
118 sql
119 SELECT JobId, Name, Level, Comment, JobStatus from Job 
120 WHERE Comment='Should fail' and JobStatus='T' ORDER By JobId;
121
122 @$out $tmp/log8.out
123 sql
124 SELECT JobId, Name, Level, Comment, JobStatus from Job
125 WHERE Comment='Should work' and JobStatus != 'T' ORDER By JobId;
126
127 @$out $tmp/log9.out
128 sql
129 SELECT JobId, Name, Level, Comment, JobStatus from Job order by JobId;
130
131 quit
132 END_OF_DATA
133
134 run_bacula
135 check_for_zombie_jobs storage=File
136 stop_bacula
137
138 touch $tmp/log2.out
139 check_two_logs
140
141 grep '^| [0-9]' $tmp/log7.out > /dev/null
142 if [ $? = 0 ]; then
143     print_debug "E: Found errors in $tmp/log7.out"
144     print_debug `cat $tmp/log7.out`
145     estat=1
146 fi
147
148 grep '^| [0-9]' $tmp/log8.out > /dev/null
149 if [ $? = 0 ]; then
150     print_debug "E: Found errors in $tmp/log8.out"
151     print_debug `cat $tmp/log8.out`
152     estat=1
153 fi
154
155 end_test