]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/maxtime-test
Simplify restart regress because of one-shot hangup
[bacula/bacula] / regress / tests / maxtime-test
1 #!/bin/sh
2 #
3 #  Test MaxWaitTime, MaxRunTime and MaxStartDelay
4 #
5
6 TestName="maxtime-test"
7 JobName=backup
8
9 . scripts/functions
10
11 copy_test_confs
12
13 rm -f ${cwd}/tmp/RUN*log
14 cp -f ${cwd}/scripts/bacula-dir.conf.maxtime ${cwd}/bin/bacula-dir.conf
15 WHEN=`date '+%Y-%m-%d %H:%M:%S'`
16
17 echo "${cwd}/build/po" >${cwd}/tmp/file-list
18
19 start_test
20
21 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
22 @$out ${cwd}/tmp/log1.out
23 messages
24 label volume=TestVolume001 pool=PoolA
25 @$out ${cwd}/tmp/RUN_MAXTIME.log
26 @# no media => have to wait
27 run job=RUN_MAXWAITTIME comment="Should fail" pool=Default yes
28 @sleep 2
29 @# storage is used by RUN_MAXWAITTIME => have to wait
30 run job=RUN_MAXSTARTDELAY comment="Should fail" pool=PoolA when="$WHEN" yes
31 @sleep 2
32 @# storage is used by the first MAXWAITTIME, but should work
33 run job=RUN_MAXWAITTIME comment="Should work" pool=PoolA yes
34 @sleep 60
35 label volume=TestVolume002 pool=Default
36 mount
37 @sleep 2
38 mount
39 wait
40 messages
41 run job=RUN_MAXRUNTIME comment="Should fail" pool=PoolA yes
42 wait
43 messages
44 st dir
45 quit
46 END_OF_DATA
47
48 (mkfifo ${cwd}/tmp/fifo 
49  mkfifo ${cwd}/tmp/fifo2
50  mkfifo ${cwd}/tmp/fifo3) 2> /dev/null
51
52 run_bacula
53 check_for_zombie_jobs storage=File
54 stop_bacula
55
56 rm -f ${cwd}/tmp/fifo ${cwd}/tmp/fifo2 ${cwd}/tmp/fifo3
57
58 dstat=0
59 bstat=0
60 rstat=0
61 touch ${cwd}/tmp/log2.out
62
63 grep -e '1: Fatal error: Max wait time exceeded. Job canceled.' ${cwd}/tmp/RUN_MAXTIME.log >/dev/null
64 if [ $? -eq 0 ]
65 then
66     [ "$debug" = 1 ] && echo MAXWAITTIME ok
67 else
68    echo "MAXWAITTIME in error"
69    bstat=1
70 fi
71
72 grep -e '2: Fatal error: Job canceled because max start delay time exceeded.' ${cwd}/tmp/RUN_MAXTIME.log > /dev/null
73 f=$?
74
75 grep -e 'NEVER start this' ${cwd}/tmp/RUN_MAXTIME.log >/dev/null
76 s=$?
77
78 if [ $f -eq 0 -a $s -ne 0 ]
79 then
80     [ "$debug" = 1 ] && echo MAXSTARTDELAY ok
81 else
82    echo "MAXSTARTDELAY in error"
83    bstat=1
84 fi
85
86 grep -e '4: Fatal error: Max run time exceeded. Job canceled.' ${cwd}/tmp/RUN_MAXTIME.log >/dev/null 
87 if [ $? -eq 0 ]
88 then
89     [ "$debug" = 1 ] && echo MAXRUNTIME ok
90 else
91    echo "MAXRUNTIME in error"
92    bstat=1
93 fi
94
95 grep 'Termination: *Backup OK' ${cwd}/tmp/RUN_MAXTIME.log >/dev/null
96 if [ $? -eq 0 ]
97 then
98     [ "$debug" = 1 ] && echo MAXRUNTIME2 ok
99 else
100    echo "MAXRUNTIME2 in error"
101    bstat=1
102 fi
103
104
105 end_test