3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
6 # Run a couple of tests with bconsole and dotcommands
8 TestName="console-dotcmd-test"
13 scripts/copy-test-confs
16 # Zap out any schedule in default conf file so that
17 # it doesn't start during our test
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
24 echo "$cwd/build/po" > $tmp/file-list
26 change_jobname NightlySave $JobName
28 perl -Mscripts::functions \
29 -e "extract_resource('$conf/bacula-dir.conf', 'Client', '$HOST-fd')" \
32 OUT=$conf/bacula-dir.conf
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
44 # We create hundred of clients in this test, the director startup can be long
45 # specially on MySQL and Ubuntu
52 while [ $ok -ne 0 -a $retry -lt 5 ]; do
53 echo quit | $bin/bconsole -c $conf/bconsole.conf | grep quit
55 retry=`expr $retry + 1`
58 cat <<EOF > $tmp/bconcmds
66 .client address=127.0.0.50
70 .client address=x.x.x.x
73 @exec "touch $tmp/log.done"
78 # Put some bad FDs in the list
79 cat $tmp/bad-fd >> $conf/bacula-dir.conf
81 # At the end of the bconsole session, touch $tmp/logerr.done instead of $tmp/log.done
82 sed s/log/logerr/ $tmp/bconcmds > $tmp/bconcmds.err
84 # With DNS errors, it will take more times
85 (run_bconsole $tmp/bconcmds.err)&
89 cat <<EOF > $tmp/bconcmds.sametime
95 @exec "touch $tmp/logsametime.done"
98 run_bconsole $tmp/bconcmds.sametime
102 $bperl -e '(-M "$tmp/logsametime.done" < -M "$tmp/logerr.done") && exit 1'
103 if [ $? -ne 0 ]; then
104 print_debug "ERROR: The timestamp of $tmp/logsametime.done should be smaller than $tmp/logerr.done"
105 stat $tmp/logsametime.done
106 stat $tmp/logerr.done
107 # I am not convinced that these timestamps will always be correct -- KES
111 nb=`grep test50-1-fd $tmp/log2.out $tmp/logerr2.out | wc -l`
112 if [ $nb != 2 ]; then
113 print_debug "ERROR: Should find the client test50-1-fd in the $tmp/log2.out and $tmp/logerr2.out files"