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