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