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