summaryrefslogtreecommitdiff
path: root/ctdb/tests/simple/20_delip_iface_gc.sh
blob: 2756f64ceb1c195ad56d41ff44cf3066c78c20bd (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
#!/bin/bash

test_info()
{
    cat <<EOF
Verify that an interface is deleted when all IPs on it are deleted.
EOF
}

. "${TEST_SCRIPTS_DIR}/integration.bash"

ctdb_test_init

set -e

cluster_is_healthy

select_test_node_and_ips

# Find interfaces on test node
try_command_on_node $test_node "$CTDB ifaces -X"
ifaces=$(awk -F'|' 'NR > 1 { print $2 }' "$outfile")
echo "Node ${test_node} has interfaces: ${ifaces}"

# Delete all IPs on each interface...  deleting IPs from one interface
# can cause other interfaces to disappear, so we need to be careful...
for i in $ifaces ; do
    try_command_on_node $test_node "$CTDB ifaces -X"
    info=$(awk -F'|' -v iface="$i" '$2 == iface { print $0 }' "$outfile")

    if [ -z "$info" ] ; then
	echo "Interface ${i} missing... assuming already deleted!"
	continue
    fi

    echo "Deleting IPs on interface ${i}, with this information:"
    echo " $info"

    try_command_on_node $test_node "$CTDB ip -v -X | tail -n +2"
    awk -F'|' -v i="$i" \
	'$6 == i { print $2 }' "$outfile" |
    while read ip ; do
	echo "  $ip"
	try_command_on_node $test_node "$CTDB delip $ip"
    done
    try_command_on_node $test_node "$CTDB ipreallocate"

    try_command_on_node $test_node "$CTDB ifaces -X"
    info=$(awk -F'|' -v iface="$i" '$2 == iface { print $0 }' "$outfile")

    if [ -z "$info" ] ; then
	echo "GOOD: Interface ${i} has been garbage collected"
    else
	echo "BAD: Interface ${i} still exists"
	echo "$out"
	exit 1
    fi
done