]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/restart-reschedule-test
Big backport from Enterprise
[bacula/bacula] / regress / tests / restart-reschedule-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6 # Test the RescheduleOnError function
7 #
8 TestName="restart-reschedule-test"
9 JobName=backup
10 . scripts/functions
11
12 scripts/cleanup
13 scripts/copy-migration-confs
14 scripts/prepare-disk-changer
15
16 echo "${cwd}/build" >${cwd}/tmp/file-list
17 sed 's/migrate/copy/g' ${cwd}/bin/bacula-dir.conf > ${cwd}/tmp/1
18 sed 's/Migrate/Copy/g' ${cwd}/tmp/1 > ${cwd}/bin/bacula-dir.conf
19
20 #
21 # Zap out any schedule in default conf file so that
22 #  it doesn't start during our test
23 #
24 outf="$tmp/sed_tmp"
25 echo "s%  Schedule =%# Schedule =%g" >${outf}
26 cp $scripts/bacula-dir.conf $tmp/1
27 sed -f ${outf} $tmp/1 >$scripts/bacula-dir.conf
28
29 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "RescheduleOnError", "yes", "Job")'
30 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "RescheduleInterval", "10", "Job")'
31 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "RescheduleTimes", "3", "Job")'
32 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "LabelFormat", "Vol", "Pool")'
33 $bperl -e 'add_attribute("$conf/bacula-sd.conf", "LabelMedia", "Yes", "Device", "FileStorage")'
34
35 change_jobname NightlySave $JobName
36 start_test
37
38 cat <<END_OF_DATA >$tmp/bconcmds
39 @$out /dev/null
40 messages
41 @$out $tmp/log1.out
42 label volume=TestVolume001 pool=Scratch storage=DiskChanger slot=1 drive=0
43 label volume=TestVolume002 pool=Scratch storage=DiskChanger slot=2 drive=0
44 label volume=TestVolume003 pool=Scratch storage=DiskChanger slot=3 drive=0
45 setdebug hangup=200 level=0 client
46 run job=$JobName yes
47 messages
48 @# Wait for the incomplete job
49 @sleep 5
50 status dir
51 messages
52 @# Wait for the reschedule
53 wait
54 messages
55 @# 
56 @# now do a restore
57 @#
58 @$out $tmp/log2.out  
59 restore where=$tmp/bacula-restores select all done
60 yes
61 wait
62 messages
63 @$out $tmp/log3.out 
64 @#setdebug hangup=200 level=0 storage
65 @# Test Reschedule with copy jobs
66 run job=copy-job jobid=1 yes
67 wait
68 messages
69 quit
70 END_OF_DATA
71
72 run_bacula
73
74 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "RescheduleIncompleteJobs", "no", "Job")'
75
76 cat <<END_OF_DATA >$tmp/bconcmds
77 @$out $tmp/log3.out 
78 reload
79 @# Test stop/resume with incomplete
80 setbandwidth limit=1000 client
81 run job=$JobName jobid=1 level=full yes
82 @sleep 5
83 stop jobid=5
84 wait
85 setbandwidth limit=10000000 client
86 @sleep 2
87 wait
88 messages
89 @# 
90 @# now do a restore
91 @#
92 @$out $tmp/log5.out  
93 restore where=$tmp/bacula-restores4
94 3
95 4
96 m *
97 done
98 yes
99 wait
100 messages
101 @$out $tmp/log4.out 
102 list jobs
103 status dir
104 quit
105 END_OF_DATA
106
107 run_bconsole
108 check_for_zombie_jobs storage=File1
109 stop_bacula
110
111 check_two_logs
112 $rscripts/diff.pl -s $cwd/build -d $tmp/bacula-restores/$cwd/build
113 bstat=`expr $bstat + $?`
114 $rscripts/diff.pl -s $cwd/build -d $tmp/bacula-restores4/$cwd/build
115 bstat=`expr $bstat + $?`
116
117 nb=`grep Incomplete $tmp/log4.out | wc -l`
118 if [ "$nb" -ne 1 ]; then
119     print_debug "ERROR: Expected 1 incomplete job in status dir output $tmp/log4.out, got $nb"
120     estat=1
121 fi
122
123 nb=`grep ' 5.* I ' $tmp/log4.out | wc -l`
124 if [ "$nb" -ne 1 ]; then
125     print_debug "ERROR: Expected 1 incomplete job in status dir output $tmp/log4.out, got $nb"
126     estat=1
127 fi
128
129
130 end_test