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