]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/runscript-test
Add new more stringent maxvol2 test
[bacula/bacula] / regress / tests / runscript-test
1 #!/bin/sh
2 #
3 #  Test RunScript
4 #
5
6 TestName="runscript-test"
7 JobName=backup
8
9 . scripts/functions
10 copy_test_confs
11
12 rm -f bin/bacula-dir.conf
13 rm -f ${cwd}/tmp/RUN*log
14 rm -f ${cwd}/tmp/RUN_FD_FAILED
15
16 touch ${cwd}/tmp/log1.out
17 /bin/cp -f scripts/bacula-dir.conf.testrunscript bin/bacula-dir.conf
18
19 echo "${cwd}/build/po" >${cwd}/tmp/file-list
20
21 start_test
22
23 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
24 @$out /dev/null
25 messages
26 label volume=TestVolume001
27 @$out ${cwd}/tmp/RUN_FD_WARNING.log
28 run job=RUN_FD_WARNING yes
29 wait
30 messages
31 @sleep 1
32 @$out ${cwd}/tmp/RUN_ALL_OK.log
33 run job=RUN_ALL_OK yes
34 wait
35 messages
36 @sleep 1
37 @$out ${cwd}/tmp/RUN_FD_FAILED.log
38 run job=RUN_FD_FAILED yes
39 wait
40 messages
41 @sleep 1
42 @$out ${cwd}/tmp/RUN_DIR_FAILED.log
43 run job=RUN_DIR_FAILED yes
44 wait
45 messages
46 @sleep 1
47 @$out ${cwd}/tmp/RUN_FD_FAILED2.log
48 run job=RUN_FD_FAILED2 yes
49 wait
50 messages
51 st dir
52 quit
53 END_OF_DATA
54
55 run_bacula
56 check_for_zombie_jobs storage=File
57 stop_bacula
58
59 dstat=0
60 bstat=0
61 rstat=0
62 export dstat
63 export bstat
64 export rstat
65
66 grep 'dir: BeforeJob: run command "/bin/echo RunBeforeJob"' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null 2>&1 
67 a=$?
68 grep 'fd: ClientRunBeforeJob: ClientRunBeforeJob' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null 2>&1
69 b=$?
70 grep 'fd: ClientAfterJob: run command "/bin/echo ClientRunAfterJob' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null 2>&1
71 c=$?
72 grep 'dir: AfterJob: run command "/bin/echo RunAfterJob' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null 2>&1
73 d=$?
74 if [ $a = 0 -a $b = 0 -a $c = 0 -a $d = 0 ]
75 then
76    [ "$debug" = 1 ] && echo RUN_ALL_OK ok
77 else
78    echo "RUN_ALL_OK in error"
79    rstat=1
80 fi
81
82 grep 'dir: BeforeJob: run command "/bin/false RUN_DIR_FAILED"' ${cwd}/tmp/RUN_DIR_FAILED.log >/dev/null 2>&1
83 a=$?
84 grep 'dir: AfterJob: RunAfterFailedJob' ${cwd}/tmp/RUN_DIR_FAILED.log >/dev/null 2>&1
85 b=$?
86 if [ $a = 0 -a $b = 0 ]
87 then
88    [ "$debug" = 1 ] && echo RUN_DIR_FAILED ok
89 else
90    echo "RUN_DIR_FAILED in error"
91    rstat=1
92 fi
93
94 grep 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED1"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null 2>&1
95 a=$?
96 grep 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED2"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null 2>&1
97 b=$?
98 grep 'dir: AfterJob: run command "/bin/echo RunAfterFailedJob"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null 2>&1
99 c=$?
100 #grep 'touching' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null 2>&1
101 test -f ${cwd}/tmp/RUN_FD_FAILED
102 d=$?
103 grep '*** Backup Error ***' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null 2>&1
104 e=$?
105 if [ $a = 0 -a $b = 0 -a $c = 0 -a $d = 0 -a $e = 0 ]
106 then
107    [ "$debug" = 1 ] && echo RUN_FD_FAILED ok
108 else
109    echo "RUN_FD_FAILED in error"
110    rstat=1
111 fi
112
113 grep 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED1"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null 2>&1
114 a=$?
115 grep 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED2"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null 2>&1
116 b=$?
117 grep 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED3"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null 2>&1
118 c=$?
119 grep 'dir: AfterJob: run command "/bin/echo RunAfterFailedJob"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null 2>&1
120 d=$?
121 grep  '*** Backup Error ***' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null 2>&1
122 e=$?
123 if [ $a = 0 -a $b != 0 -a $c = 0 -a $d = 0 -a $e = 0 ]
124 then
125    [ "$debug" = 1 ] && echo RUN_FD_FAILED ok
126 else
127    echo "RUN_FD_FAILED2 in error"
128    rstat=1
129 fi
130
131 grep 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_WARNING"' ${cwd}/tmp/RUN_FD_WARNING.log >/dev/null 2>&1
132 a=$?
133 grep 'RunAfterFailedJob' ${cwd}/tmp/RUN_FD_WARNING.log >/dev/null 2>&1
134 b=$?
135 grep 'Backup OK -- with warnings' ${cwd}/tmp/RUN_FD_WARNING.log >/dev/null 2>&1
136 c=$?
137 if [ $a = 0 -a $b != 0 -a $c = 0 ]
138 then
139    [ "$debug" = 1 ] && echo RUN_FD_WARNING ok
140 else
141    echo "RUN_FD_WARNING in error"
142    rstat=1
143 fi
144
145 end_test