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