Merge branch 'master' of ctdb into 'master' of samba
[samba.git] / ctdb / tests / eventscripts / 10.interface.releaseip.011.sh
1 #!/bin/sh
2
3 . "${TEST_SCRIPTS_DIR}/unit.sh"
4
5 define_test "Release 1 IP, 10 connections killed, 1 fails"
6
7 setup_ctdb
8
9 ctdb_get_1_public_address |
10 while read dev ip bits ; do
11     ip addr add "${ip}/${bits}" dev "$dev"
12
13     # Setup 10 fake connections...
14     count=10
15     out=""
16     nl="
17 "
18     i=0
19     while [ $i -lt $count ] ; do
20         echo "${ip}:445 10.254.254.1:1230${i}"
21         # Expected output for killing this connection
22         out="${out}${out:+${nl}}Killing TCP connection 10.254.254.1:1230${i} ${ip}:445"
23         i=$(($i + 1))
24     done >"$FAKE_NETSTAT_TCP_ESTABLISHED_FILE"
25
26     # Note that the fake TCP killing done by the "ctdb killtcp" stub
27     # can only kill conections in the file, so killing this connection
28     # will never succeed so it will look like a time out.
29     FAKE_NETSTAT_TCP_ESTABLISHED="${ip}:445|10.254.254.1:43210"
30
31     ok <<EOF
32 Killing TCP connection 10.254.254.1:43210 ${ip}:445
33 $out
34 Waiting for 1 connections to be killed for IP ${ip}
35 Waiting for 1 connections to be killed for IP ${ip}
36 Waiting for 1 connections to be killed for IP ${ip}
37 Timed out killing tcp connections for IP $ip
38 EOF
39
40     simple_test $dev $ip $bits
41 done