]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/source-addr-test
ebl Apply Steve Polyack patch to add DirSourceAddress and FDSourceAddress
[bacula/bacula] / regress / tests / source-addr-test
1 #!/bin/sh
2 #
3 # Run a simple backup of the Bacula build directory
4 #   then restore it.
5 #
6 TestName="source-addr-test"
7 JobName=backup
8 . scripts/functions
9
10 scripts/cleanup
11 scripts/copy-confs
12
13 #
14 # Zap out any schedule in default conf file so that
15 #  it doesn't start during our test
16 #
17 outf="tmp/sed_tmp"
18 echo "s%  Schedule =%# Schedule =%g" >${outf}
19 cp $scripts/bacula-dir.conf $tmp/1
20 sed -f ${outf} $tmp/1 >$scripts/bacula-dir.conf
21
22 PATH=$PATH:/sbin:/usr/sbin
23 #
24 # Deduce a primary IP address by examining
25 #  the interface defined by INTERFACE=
26 #
27 os=`uname`
28 if [ $os = 'FreeBSD' ]; then
29    INTERFACE=bge0
30    IP=`ifconfig ${INTERFACE} | perl -ne '/inet (.+?) / && print $1'`
31 elif [ $os = 'Linux' ]; then
32    INTERFACE=eth0
33    IP=`ifconfig ${INTERFACE} | perl -ne '/inet addr:(.+?) / && print $1'`
34 else
35    echo "Can't run this test on $os"
36    exit 0
37 fi
38 outf="tmp/sed_tmp"
39 echo "s/PidDirectory/DirSourceAddress=$IP; PidDirectory/g" > $outf
40 echo "s/Address =/Address = 127.0.0.1 #/g" >> $outf 
41 cp $scripts/bacula-dir.conf $tmp/1
42 sed -f ${outf} ${cwd}/tmp/1 > $scripts/bacula-dir.conf 
43
44 # Set source address on the FD as well
45 echo "s/Pid Directory/FDSourceAddress=$IP; Pid Directory/g" >$outf
46 cp $scripts/bacula-fd.conf $tmp/2
47 sed -f ${outf} ${cwd}/tmp/2 > $scripts/bacula-fd.conf
48
49 DIRPORT=$BASEPORT
50 FDPORT=$(($BASEPORT + 1))
51 SDPORT=$(($BASEPORT + 2))
52
53 change_jobname Client1 $JobName
54 start_test
55
56 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
57 @output /dev/null
58 messages
59 @$out ${cwd}/tmp/log1.out
60 @#label volume=TestVolume001 storage=File pool=Default
61 @#setdebug level=100 storage=File
62 run job=$JobName yes
63 @sleep 3
64 messages
65 quit
66 END_OF_DATA
67
68 run_bacula
69
70 print_debug "Connections to SD sourced from ${IP}:"
71 netstat -tan | grep -e "127.0.0.1(.|:)$SDPORT .* ${IP}" > $tmp/log3.out
72 if [ $? -ne 0 ]; then
73    bstat=2
74    print_debug "Couldn't detect a connection to the SD sourced from SourceAddress ${IP}" 
75 fi
76
77 print_debug "Connections to FD sourced from ${IP}:"
78 netstat -tan | grep -e "127.0.0.1(.|:)$FDPORT .* ${IP}" >> $tmp/log3.out
79 if [ $? -ne 0 ]; then
80    bstat=2
81    print_debug "Couldn't detect a connection to the FD sourced from SourceAddress ${IP}"
82 fi
83
84
85 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
86 @output /dev/null
87 messages
88 @$out ${cwd}/tmp/log1.out
89 label volume=TestVolume001 storage=File pool=Default
90 @#setdebug level=100 storage=File
91 wait
92 messages
93 @# 
94 @# now do a restore
95 @#
96 @$out ${cwd}/tmp/log2.out  
97 restore where=${cwd}/tmp/bacula-restores select all done
98 yes
99 wait
100 messages
101 @$out
102 quit
103 END_OF_DATA
104
105 run_bconsole
106 check_for_zombie_jobs storage=File
107 stop_bacula
108 check_two_logs
109 check_restore_diff
110 end_test