]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/runscript-test
Tweak correct English in debug output of regress tests
[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 pool=Scratch
27 setdebug dir level=200
28 @$out ${cwd}/tmp/RUN_FD_WARNING.log
29 run job=RUN_FD_WARNING yes
30 wait
31 messages
32 @sleep 1
33 @$out ${cwd}/tmp/RUN_ALL_OK.log
34 run job=RUN_ALL_OK yes
35 wait
36 messages
37 @sleep 1
38 @$out ${cwd}/tmp/RUN_FD_FAILED.log
39 run job=RUN_FD_FAILED yes
40 wait
41 messages
42 @sleep 1
43 @$out ${cwd}/tmp/RUN_DIR_FAILED.log
44 run job=RUN_DIR_FAILED yes
45 wait
46 messages
47 @sleep 1
48 @$out ${cwd}/tmp/RUN_FD_FAILED2.log
49 run job=RUN_FD_FAILED2 yes
50 wait
51 messages
52 @sleep 1
53 @$out ${cwd}/tmp/RUN_RESTO.log
54 restore where=${cwd}/tmp/bacula-restores select all done yes
55 wait
56 messages
57 st dir
58 quit
59 END_OF_DATA
60
61 run_bacula
62 check_for_zombie_jobs storage=File
63 stop_bacula
64
65 dstat=0
66 bstat=0
67 rstat=0
68 export dstat
69 export bstat
70 export rstat
71
72 grep 'shell command: run BeforeJob "/bin/echo RunBeforeJob"' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null
73 a=$?
74 grep 'ClientRunBeforeJob: ClientRunBeforeJob' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null
75 b=$?
76 grep 'shell command: run ClientAfterJob "/bin/echo ClientRunAfterJob' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null
77 c=$?
78 grep 'shell command: run AfterJob "/bin/echo RunAfterJob' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null
79 d=$?
80 grep 'ClientRunBefore1' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null && \
81 grep 'ClientRunBefore2' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null && \
82 grep 'ClientRunBefore3' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null
83 e=$?
84
85 if [ $a = 0 -a $b = 0 -a $c = 0 -a $d = 0 -a $e = 0 ]
86 then
87    [ "$debug" = 1 ] && echo RUN_ALL_OK ok
88 else
89    echo "RUN_ALL_OK in error"
90    bstat=1
91 fi
92
93 grep 'shell command: run BeforeJob "/bin/false RUN_DIR_FAILED"' ${cwd}/tmp/RUN_DIR_FAILED.log >/dev/null
94 a=$?
95 grep 'AfterJob: RunAfterFailedJob' ${cwd}/tmp/RUN_DIR_FAILED.log >/dev/null
96 b=$?
97 if [ $a = 0 -a $b = 0 ]
98 then
99    [ "$debug" = 1 ] && echo RUN_DIR_FAILED ok
100 else
101    echo "RUN_DIR_FAILED in error"
102    bstat=1
103 fi
104
105 grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED1"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null
106 a=$?
107 grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED2"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null
108 b=$?
109 grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED3"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null
110 c=$?
111 grep 'shell command: run AfterJob "/bin/echo RunAfterFailedJob"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null
112 d=$?
113 grep 'touching' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null
114 e=$?
115 grep '*** Backup Error ***' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null
116 f=$?
117 if [ $a = 0 -a $b = 0 -a $c = 0 -a $d = 0 -a $e = 0 -a $f = 0 ]
118 then
119    [ "$debug" = 1 ] && echo RUN_FD_FAILED ok
120 else
121    echo "RUN_FD_FAILED in error a=$a b=$b c=$c d=$d e=$e f=$f"
122    bstat=1
123 fi
124
125 grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED1"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null
126 a=$?
127 grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED2"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null
128 b=$?
129 grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED3"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null
130 c=$?
131 grep 'shell command: run AfterJob "/bin/echo RunAfterFailedJob"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null
132 d=$?
133 grep  '*** Backup Error ***' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null
134 e=$?
135 grep 'RUN_FD_FAILED4' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null
136 f=$?
137 if [ $a = 0 -a $b != 0 -a $c = 0 -a $d = 0 -a $e = 0 -a $f != 0 ]
138 then
139    [ "$debug" = 1 ] && echo RUN_FD_FAILED ok
140 else
141    echo "RUN_FD_FAILED2 in error a=$a b=$b c=$d d=$d e=$e"
142    bstat=1
143 fi
144
145 grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_WARNING"' ${cwd}/tmp/RUN_FD_WARNING.log >/dev/null
146 a=$?
147 grep 'RunAfterFailedJob' ${cwd}/tmp/RUN_FD_WARNING.log >/dev/null
148 b=$?
149 grep 'Backup OK -- with warnings' ${cwd}/tmp/RUN_FD_WARNING.log >/dev/null
150 c=$?
151 if [ $a = 0 -a $b != 0 -a $c = 0 ]
152 then
153    [ "$debug" = 1 ] && echo RUN_FD_WARNING ok
154 else
155    echo "RUN_FD_WARNING in error"
156    bstat=1
157 fi
158
159 grep 'ClientBeforeRestore' ${cwd}/tmp/RUN_RESTO.log >/dev/null
160 a=$?
161 grep 'ClientAfterRestore' ${cwd}/tmp/RUN_RESTO.log >/dev/null
162 b=$?
163 grep 'DirBeforeRestore' ${cwd}/tmp/RUN_RESTO.log >/dev/null
164 c=$?
165 grep 'DirAfterRestore' ${cwd}/tmp/RUN_RESTO.log >/dev/null
166 d=$?
167 if [ $a = 0 -a $b = 0 -a $c = 0 -a $d = 0 ]
168 then
169    [ "$debug" = 1 ] && echo RUN_RESTO ok
170 else
171    echo "RUN_RESTO in error"
172    rstat=1
173 fi
174
175
176 end_test