]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/runscript-test
f4c3658e3994a10974bd48e6fa37956df939818c
[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 'BeforeJob: run command "/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 'ClientAfterJob: run command "/bin/echo ClientRunAfterJob' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null 2>&1
71 c=$?
72 grep 'AfterJob: run command "/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 'BeforeJob: run command "/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 'ClientBeforeJob: run command "/bin/false RUN_FD_FAILED1"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null 2>&1
95 a=$?
96 grep 'ClientBeforeJob: run command "/bin/false RUN_FD_FAILED2"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null 2>&1
97 b=$?
98 grep 'AfterJob: run command "/bin/echo RunAfterFailedJob"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null 2>&1
99 c=$?
100 grep 'touching' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null 2>&1
101 d=$?
102 grep '*** Backup Error ***' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null 2>&1
103 e=$?
104 if [ $a = 0 -a $b = 0 -a $c = 0 -a $d = 0 -a $e = 0 ]
105 then
106    [ "$debug" = 1 ] && echo RUN_FD_FAILED ok
107 else
108    echo "RUN_FD_FAILED in error"
109    rstat=1
110 fi
111
112 grep 'ClientBeforeJob: run command "/bin/false RUN_FD_FAILED1"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null 2>&1
113 a=$?
114 grep 'ClientBeforeJob: run command "/bin/false RUN_FD_FAILED2"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null 2>&1
115 b=$?
116 grep 'ClientBeforeJob: run command "/bin/false RUN_FD_FAILED3"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null 2>&1
117 c=$?
118 grep 'AfterJob: run command "/bin/echo RunAfterFailedJob"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null 2>&1
119 d=$?
120 grep  '*** Backup Error ***' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null 2>&1
121 e=$?
122 if [ $a = 0 -a $b != 0 -a $c = 0 -a $d = 0 -a $e = 0 ]
123 then
124    [ "$debug" = 1 ] && echo RUN_FD_FAILED ok
125 else
126    echo "RUN_FD_FAILED2 in error"
127    rstat=1
128 fi
129
130 grep 'ClientBeforeJob: run command "/bin/false RUN_FD_WARNING"' ${cwd}/tmp/RUN_FD_WARNING.log >/dev/null 2>&1
131 a=$?
132 grep 'RunAfterFailedJob' ${cwd}/tmp/RUN_FD_WARNING.log >/dev/null 2>&1
133 b=$?
134 grep 'Backup OK -- with warnings' ${cwd}/tmp/RUN_FD_WARNING.log >/dev/null 2>&1
135 c=$?
136 if [ $a = 0 -a $b != 0 -a $c = 0 ]
137 then
138    [ "$debug" = 1 ] && echo RUN_FD_WARNING ok
139 else
140    echo "RUN_FD_WARNING in error"
141    rstat=1
142 fi
143
144 end_test