summaryrefslogtreecommitdiff
path: root/ctdb/tests/INTEGRATION/failover/pubips.040.NoIPTakeover.sh
blob: a39e48d0883023b56f306ce9ca9f31cf76299b46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash

# Verify that 'ctdb setvar NoIPTakeover 1' stops IP addresses being taken over

. "${TEST_SCRIPTS_DIR}/integration.bash"

set -e

ctdb_test_init

try_command_on_node 0 "$CTDB listnodes | wc -l"
num_nodes="$out"
echo "There are $num_nodes nodes..."

if [ $num_nodes -lt 2 ] ; then
    echo "Less than 2 nodes!"
    exit 1
fi


echo "Wait until the ips are reallocated"
sleep_for 30
try_command_on_node 0 "$CTDB ipreallocate"

num=`try_command_on_node -v 1 "$CTDB ip" | grep -v Public | egrep " 1$" | wc -l`
echo "Number of addresses on node 1 : $num"


echo "Turning on NoIPTakeover on all nodes"
try_command_on_node all "$CTDB setvar NoIPTakeover 1"
try_command_on_node 1 "$CTDB ipreallocate"

echo Disable node 1
try_command_on_node 1 "$CTDB disable"
try_command_on_node 1 "$CTDB ipreallocate"
num=`try_command_on_node -v 1 "$CTDB ip" | grep -v Public | egrep " 1$" | wc -l`
echo "Number of addresses on node 1 : $num"
[ "$num" != "0" ] && {
    echo "BAD: node 1 still hosts ip addresses"
    exit 1
}


echo "Enable node 1 again"
try_command_on_node 1 "$CTDB enable"
sleep_for 30
try_command_on_node 1 "$CTDB ipreallocate"
try_command_on_node 1 "$CTDB ipreallocate"
num=`try_command_on_node -v 1 "$CTDB ip" | grep -v Public | egrep " 1$" | wc -l`
echo "Number of addresses on node 1 : $num"
[ "$num" != "0" ] && {
    echo "BAD: node took over ip addresses"
    exit 1
}


echo "OK. ip addresses were not taken over"
exit 0