3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
11 TestName="runscript-test"
17 rm -f bin/bacula-dir.conf
18 rm -f ${cwd}/tmp/RUN*log
19 rm -f ${cwd}/tmp/RUN_FD_FAILED
21 touch ${cwd}/tmp/log1.out
22 /bin/cp -f scripts/bacula-dir.conf.testrunscript bin/bacula-dir.conf
24 echo "${cwd}/build/po" >${cwd}/tmp/file-list
28 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
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
38 @$out ${cwd}/tmp/RUN_ALL_OK.log
39 run job=RUN_ALL_OK yes
43 @$out ${cwd}/tmp/RUN_FD_FAILED.log
44 run job=RUN_FD_FAILED yes
48 @$out ${cwd}/tmp/RUN_DIR_FAILED.log
49 run job=RUN_DIR_FAILED yes
53 @$out ${cwd}/tmp/RUN_FD_FAILED2.log
54 run job=RUN_FD_FAILED2 yes
58 @$out ${cwd}/tmp/RUN_RESTO.log
59 restore where=${cwd}/tmp/bacula-restores select all done yes
67 check_for_zombie_jobs storage=File
77 grep 'shell command: run BeforeJob "/bin/echo RunBeforeJob"' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null
79 grep 'ClientRunBeforeJob: ClientRunBeforeJob' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null
81 grep 'shell command: run ClientAfterJob "/bin/echo ClientRunAfterJob' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null
83 grep 'shell command: run AfterJob "/bin/echo RunAfterJob' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null
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
90 if [ $a = 0 -a $b = 0 -a $c = 0 -a $d = 0 -a $e = 0 ]
92 [ "$debug" = 1 ] && echo RUN_ALL_OK ok
94 echo "RUN_ALL_OK in error"
98 grep 'shell command: run BeforeJob "/bin/false RUN_DIR_FAILED"' ${cwd}/tmp/RUN_DIR_FAILED.log >/dev/null
100 grep 'AfterJob: RunAfterFailedJob' ${cwd}/tmp/RUN_DIR_FAILED.log >/dev/null
102 if [ $a = 0 -a $b = 0 ]
104 [ "$debug" = 1 ] && echo RUN_DIR_FAILED ok
106 echo "RUN_DIR_FAILED in error"
110 grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED1"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null
112 grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED2"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null
114 grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED3"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null
116 grep 'shell command: run AfterJob "/bin/echo RunAfterFailedJob"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null
118 grep 'touching' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null
120 grep '*** Backup Error ***' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null
122 if [ $a = 0 -a $b = 0 -a $c = 0 -a $d = 0 -a $e = 0 -a $f = 0 ]
124 [ "$debug" = 1 ] && echo RUN_FD_FAILED ok
126 echo "RUN_FD_FAILED in error a=$a b=$b c=$c d=$d e=$e f=$f"
130 grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED1"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null
132 grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED2"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null
134 grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED3"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null
136 grep 'shell command: run AfterJob "/bin/echo RunAfterFailedJob"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null
138 grep '*** Backup Error ***' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null
140 grep 'RUN_FD_FAILED4' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null
142 if [ $a = 0 -a $b != 0 -a $c = 0 -a $d = 0 -a $e = 0 -a $f != 0 ]
144 [ "$debug" = 1 ] && echo RUN_FD_FAILED ok
146 echo "RUN_FD_FAILED2 in error a=$a b=$b c=$d d=$d e=$e"
150 grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_WARNING"' ${cwd}/tmp/RUN_FD_WARNING.log >/dev/null
152 grep 'RunAfterFailedJob' ${cwd}/tmp/RUN_FD_WARNING.log >/dev/null
154 grep 'Backup OK -- with warnings' ${cwd}/tmp/RUN_FD_WARNING.log >/dev/null
156 if [ $a = 0 -a $b != 0 -a $c = 0 ]
158 [ "$debug" = 1 ] && echo RUN_FD_WARNING ok
160 echo "RUN_FD_WARNING in error"
164 grep 'ClientBeforeRestore' ${cwd}/tmp/RUN_RESTO.log >/dev/null
166 grep 'ClientAfterRestore' ${cwd}/tmp/RUN_RESTO.log >/dev/null
168 grep 'DirBeforeRestore' ${cwd}/tmp/RUN_RESTO.log >/dev/null
170 grep 'DirAfterRestore' ${cwd}/tmp/RUN_RESTO.log >/dev/null
172 if [ $a = 0 -a $b = 0 -a $c = 0 -a $d = 0 ]
174 [ "$debug" = 1 ] && echo RUN_RESTO ok
176 echo "RUN_RESTO in error"