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