]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/runscript-test
Update
[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 if grep -q 'dir: BeforeJob: run command "/bin/echo RunBeforeJob"'          tmp/RUN_ALL_OK.log   &&
65    grep -q 'fd: ClientRunBeforeJob: ClientRunBeforeJob'                    tmp/RUN_ALL_OK.log   &&
66    grep -q 'fd: ClientAfterJob: run command "/bin/echo ClientRunAfterJob'  tmp/RUN_ALL_OK.log   &&
67    grep -q 'dir: AfterJob: run command "/bin/echo RunAfterJob'             tmp/RUN_ALL_OK.log
68 then
69    [ "$debug" = 1 ] && echo RUN_ALL_OK ok
70 else
71    echo "RUN_ALL_OK in error"
72    rstat=1
73 fi
74
75 if grep -q 'dir: BeforeJob: run command "/bin/false RUN_DIR_FAILED"' tmp/RUN_DIR_FAILED.log   &&
76    grep -q 'dir: AfterJob: RunAfterFailedJob'                        tmp/RUN_DIR_FAILED.log   &&
77    true #   grep -q 'Backup OK -- with warnings'                              tmp/RUN_DIR_FAILED.log
78 then
79    [ "$debug" = 1 ] && echo RUN_DIR_FAILED ok
80 else
81    echo "RUN_DIR_FAILED in error"
82    rstat=1
83 fi
84
85 if grep -q 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED1"'  tmp/RUN_FD_FAILED.log   &&
86    grep -q 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED2"'  tmp/RUN_FD_FAILED.log   &&
87    grep -q 'dir: AfterJob: run command "/bin/echo RunAfterFailedJob"'      tmp/RUN_FD_FAILED.log   &&
88    grep -q '*** Backup Error ***'                                          tmp/RUN_FD_FAILED.log
89 then
90    [ "$debug" = 1 ] && echo RUN_FD_FAILED ok
91 else
92    echo "RUN_FD_FAILED in error"
93    rstat=1
94 fi
95
96 if grep -q 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED1"'   tmp/RUN_FD_FAILED2.log &&
97    ! grep -q 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED2"' tmp/RUN_FD_FAILED2.log &&
98    grep -q 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED3"'   tmp/RUN_FD_FAILED2.log &&
99    grep -q 'dir: AfterJob: run command "/bin/echo RunAfterFailedJob"'       tmp/RUN_FD_FAILED2.log &&
100    grep -q '*** Backup Error ***'                                           tmp/RUN_FD_FAILED2.log
101
102 then
103    [ "$debug" = 1 ] && echo RUN_FD_FAILED ok
104 else
105    echo "RUN_FD_FAILED2 in error"
106    rstat=1
107 fi
108
109 if grep -q 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_WARNING"' tmp/RUN_FD_WARNING.log   &&
110    ! grep -q 'RunAfterFailedJob'                                          tmp/RUN_FD_WARNING.log   &&
111    grep -q 'Backup OK -- with warnings'                                   tmp/RUN_FD_WARNING.log
112 then
113    [ "$debug" = 1 ] && echo RUN_FD_WARNING ok
114 else
115    echo "RUN_FD_WARNING in error"
116    rstat=1
117 fi
118
119 end_test