]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/console-dotcmd-test
98f2238cd1c6877c3fe942487eac768cb39967ed
[bacula/bacula] / regress / tests / console-dotcmd-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6 # Run a couple of tests with bconsole and dotcommands
7 #
8 TestName="console-dotcmd-test"
9 JobName=backup
10 . scripts/functions
11
12 scripts/cleanup
13 scripts/copy-test-confs
14
15 #
16 # Zap out any schedule in default conf file so that
17 #  it doesn't start during our test
18 #
19 outf="$tmp/sed_tmp"
20 echo "s%  Schedule =%# Schedule =%g" >${outf}
21 cp $scripts/bacula-dir.conf $tmp/1
22 sed -f ${outf} $tmp/1 >$scripts/bacula-dir.conf
23
24 echo "$cwd/build/po" > $tmp/file-list
25
26 change_jobname NightlySave $JobName
27
28 perl -Mscripts::functions \
29     -e "extract_resource('$conf/bacula-dir.conf', 'Client', '$HOST-fd')" \
30     > $tmp/1
31
32 OUT=$conf/bacula-dir.conf
33 for i in `seq 0 254`
34 do
35
36   sed "s/$HOST-fd/test$i-1-fd/" $tmp/1   | sed "s/Address.*/Address = 127.0.0.$i/" >> $OUT
37   sed "s/$HOST-fd/test$i-2-fd/" $tmp/1   | sed "s/Address.*/Address = 127.0.2.$i/" >> $OUT
38   sed "s/$HOST-fd/test$i-rst-fd/" $tmp/1 | sed "s/Address.*/Address = 127.0.3.$i/" >> $OUT
39   sed "s/$HOST-fd/test$i-err-fd/" $tmp/1 | sed "s/Address.*/Address = something.lan.xx.baculasystems.com/" >> $tmp/bad-fd
40 done
41
42 start_test
43
44 # We create hundred of clients in this test, the director startup can be long
45 # specially on MySQL and Ubuntu
46 touch $tmp/bconcmds
47 run_bacula
48
49 ok=1
50 retry=0
51
52 while [ $ok -ne 0 -a $retry -lt 5 ]; do
53     echo quit | $bin/bconsole -c $conf/bconsole.conf | grep quit
54     ok=$?
55     retry=`expr $retry + 1`
56 done
57     
58 cat <<EOF > $tmp/bconcmds
59 @out /dev/null
60 reload
61 messages
62 @$out $tmp/log1.out
63 .client
64 @$out $tmp/log2.out
65 time
66 .client address=127.0.0.50
67 time
68 @$out $tmp/log3.out
69 time
70 .client address=x.x.x.x
71 time
72 @echo done
73 @exec "touch $tmp/log.done"
74 EOF
75
76 run_bconsole
77
78 # Put some bad FDs in the list
79 cat $tmp/bad-fd >> $conf/bacula-dir.conf
80 sed s/log/logerr/ $tmp/bconcmds > $tmp/bconcmds.err
81
82 # With DNS errors, it will take more times
83 (run_bconsole $tmp/bconcmds.err)&
84
85 sleep 2
86
87 cat <<EOF > $tmp/bconcmds.sametime
88 @out /dev/null
89 reload
90 messages
91 @$out $tmp/log1.out
92 .client
93 @exec "touch $tmp/logsametime.done"
94 EOF
95
96 run_bconsole $tmp/bconcmds.sametime
97
98 wait
99
100 $bperl -e '(-M "$tmp/logsametime.done" < -M "$tmp/logerr.done") && exit 1'
101 if [ $? -ne 0 ]; then
102     print_debug "ERROR: The timestamp of $tmp/logsametime.done should be smaller than $tmp/logerr.done"
103     estat=1
104 fi
105
106 nb=`grep test50-1-fd $tmp/log2.out $tmp/logerr2.out | wc -l`
107 if [ $nb != 2 ]; then
108     print_debug "ERROR: Should find the client test50-1-fd in the $tmp/log2.out and $tmp/logerr2.out files"
109     estat=1
110 fi
111
112 stop_bacula
113 end_test