]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/runscript-test
ebl tweak tests to show #897
[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 run_bacula
53 check_for_zombie_jobs storage=File
54 stop_bacula
55
56 dstat=0
57 bstat=0
58 rstat=0
59 export dstat
60 export bstat
61 export rstat
62
63 grep 'dir: BeforeJob: run command "/bin/echo RunBeforeJob"' tmp/RUN_ALL_OK.log >/dev/null 2>&1 
64 a=$?
65 grep 'fd: ClientRunBeforeJob: ClientRunBeforeJob' tmp/RUN_ALL_OK.log >/dev/null 2>&1
66 b=$?
67 grep 'fd: ClientAfterJob: run command "/bin/echo ClientRunAfterJob' tmp/RUN_ALL_OK.log >/dev/null 2>&1
68 c=$?
69 grep 'dir: AfterJob: run command "/bin/echo RunAfterJob' tmp/RUN_ALL_OK.log >/dev/null 2>&1
70 d=$?
71 if [ $a = 0 -a $b = 0 -a $c = 0 -a $d = 0 ]
72 then
73    [ "$debug" = 1 ] && echo RUN_ALL_OK ok
74 else
75    echo "RUN_ALL_OK in error"
76    rstat=1
77 fi
78
79 grep 'dir: BeforeJob: run command "/bin/false RUN_DIR_FAILED"' tmp/RUN_DIR_FAILED.log >/dev/null 2>&1
80 a=$?
81 grep 'dir: AfterJob: RunAfterFailedJob' tmp/RUN_DIR_FAILED.log >/dev/null 2>&1
82 b=$?
83 if [ $a = 0 -a $b = 0 ]
84 then
85    [ "$debug" = 1 ] && echo RUN_DIR_FAILED ok
86 else
87    echo "RUN_DIR_FAILED in error"
88    rstat=1
89 fi
90
91 grep 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED1"' tmp/RUN_FD_FAILED.log >/dev/null 2>&1
92 a=$?
93 grep 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED2"' tmp/RUN_FD_FAILED.log >/dev/null 2>&1
94 b=$?
95 grep 'dir: AfterJob: run command "/bin/echo RunAfterFailedJob"' tmp/RUN_FD_FAILED.log >/dev/null 2>&1
96 c=$?
97 grep 'touching' tmp/RUN_FD_FAILED.log >/dev/null 2>&1
98 d=$?
99 grep '*** Backup Error ***' tmp/RUN_FD_FAILED.log >/dev/null 2>&1
100 e=$?
101 if [ $a = 0 -a $b = 0 -a $c = 0 -a $d = 0 -a $e = 0 ]
102 then
103    [ "$debug" = 1 ] && echo RUN_FD_FAILED ok
104 else
105    echo "RUN_FD_FAILED in error"
106    rstat=1
107 fi
108
109 grep 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED1"' tmp/RUN_FD_FAILED2.log >/dev/null 2>&1
110 a=$?
111 grep 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED2"' tmp/RUN_FD_FAILED2.log >/dev/null 2>&1
112 b=$?
113 grep 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED3"' tmp/RUN_FD_FAILED2.log >/dev/null 2>&1
114 c=$?
115 grep 'dir: AfterJob: run command "/bin/echo RunAfterFailedJob"' tmp/RUN_FD_FAILED2.log >/dev/null 2>&1
116 d=$?
117 grep  '*** Backup Error ***' tmp/RUN_FD_FAILED2.log >/dev/null 2>&1
118 e=$?
119 if [ $a = 0 -a $b != 0 -a $c = 0 -a $d = 0 -a $e = 0 ]
120 then
121    [ "$debug" = 1 ] && echo RUN_FD_FAILED ok
122 else
123    echo "RUN_FD_FAILED2 in error"
124    rstat=1
125 fi
126
127 grep 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_WARNING"' tmp/RUN_FD_WARNING.log >/dev/null 2>&1
128 a=$?
129 grep 'RunAfterFailedJob' tmp/RUN_FD_WARNING.log >/dev/null 2>&1
130 b=$?
131 grep 'Backup OK -- with warnings' tmp/RUN_FD_WARNING.log >/dev/null 2>&1
132 c=$?
133 if [ $a = 0 -a $b != 0 -a $c = 0 ]
134 then
135    [ "$debug" = 1 ] && echo RUN_FD_WARNING ok
136 else
137    echo "RUN_FD_WARNING in error"
138    rstat=1
139 fi
140
141 end_test