Merge remote branch 'martins/master'
[vlendec/samba-autobuild/.git] / ctdb / tests / eventscripts / 13.per_ip_routing.012.sh
1 #!/bin/sh
2
3 . "${TEST_SCRIPTS_DIR}/unit.sh"
4
5 define_test "1 IP configured, takeip, releaseip, ipreallocated"
6
7 # This partly tests the test infrastructure.  If the (stub) "ctdb
8 # moveip" doesn't do anything then the IP being released will still be
9 # on the node and the ipreallocated event will add the routes back.
10
11 setup_ctdb
12 setup_ctdb_policy_routing
13
14 ctdb_get_1_public_address |
15 {
16     read dev ip bits
17
18     net=$(ipv4_host_addr_to_net "$ip" "$bits")
19     gw="${net%.*}.1" # a dumb, calculated default
20
21     cat >"$CTDB_PER_IP_ROUTING_CONF" <<EOF
22 $ip $net
23 $ip 0.0.0.0/0 $gw
24 EOF
25
26     ok_null
27
28     simple_test_event "takeip" $dev $ip $bits
29
30     ok_null
31
32     ctdb moveip $ip 1
33     simple_test_event "releaseip" $dev $ip $bits
34
35     ok_null
36
37     # This will cause any
38     simple_test_event "ipreallocated"
39
40     ok <<EOF
41 # ip rule show
42 0:      from all lookup local 
43 32766:  from all lookup main 
44 32767:  from all lookup default 
45 EOF
46
47     simple_test_command dump_routes
48 }