]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/duplicate-job-test
regress: Add test for duplicate job
[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 10"%' > $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 run comment="Should work" level=Full job=AllowDuplicateYes yes
50 @sleep 2
51 run comment="Should work" level=Full job=AllowDuplicateYes yes
52 wait
53 messages
54 @$out $tmp/log3.out
55 run comment="Should work" level=Full job=CancelLowerLevelDuplicatesYes yes
56 @sleep 2
57 run comment="Should fail" level=Full job=CancelLowerLevelDuplicatesYes yes
58 wait
59 messages
60 run comment="Should fail" level=Incremental job=CancelLowerLevelDuplicatesYes yes
61 @sleep 2
62 run comment="Should work" level=Full job=CancelLowerLevelDuplicatesYes yes
63 wait
64 messages
65 run comment="Should work" level=Full job=CancelLowerLevelDuplicatesYes yes
66 @sleep 2
67 run comment="Should fail" level=Incremental job=CancelLowerLevelDuplicatesYes yes
68 wait
69 messages
70 @$out $tmp/log4.out
71 run comment="Should work" level=Full job=CancelQueueDuplicatesYes yes
72 @sleep 2
73 run comment="Should fail" level=Full job=CancelQueueDuplicatesYes yes
74 wait
75 messages
76 run comment="Should fail" level=Full job=CancelQueueDuplicatesYes when="$when" yes
77 @sleep 2
78 run comment="Should work" level=Full job=CancelQueueDuplicatesYes yes
79 wait
80 messages
81 @$out $tmp/log5.out
82 run comment="Should work" level=Full job=CancelRunningDuplicatesYes yes
83 @sleep 2
84 run comment="Should fail" level=Full job=CancelRunningDuplicatesYes yes
85 wait
86 messages
87 @$out $tmp/log6.out
88 run comment="Should work" level=Full job=CancelRunningDuplicatesNo yes
89 @sleep 2
90 run comment="Should fail" level=Full job=CancelRunningDuplicatesNo yes
91 wait
92 messages
93 @$out $tmp/log2.out
94 sql
95 SELECT JobId, Name, Level, Comment, JobStatus from Job 
96 WHERE Comment='Should fail' and JobStatus='T';
97
98 sql
99 SELECT JobId, Name, Level, Comment, JobStatus from Job order by JobId
100 WHERE Comment="Should work' and JobStatus != 'T';
101
102 sql
103 SELECT JobId, Name, Level, Comment, JobStatus from Job order by JobId;
104
105 quit
106 END_OF_DATA
107
108 run_bacula
109 check_for_zombie_jobs storage=File
110 stop_bacula
111
112 check_two_logs
113 check_restore_diff
114 end_test