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