ctdb-tests: Update integration tests to use ctdb -X
[Samba.git] / ctdb / tests / simple / 20_delip_iface_gc.sh
blob83de49595abaf5880e652f0488a7a169e9c085cc
1 #!/bin/bash
3 test_info()
5 cat <<EOF
6 Verify that an interface is deleted when all IPs on it are deleted.
7 EOF
10 . "${TEST_SCRIPTS_DIR}/integration.bash"
12 ctdb_test_init "$@"
14 set -e
16 cluster_is_healthy
18 # Reset configuration
19 ctdb_restart_when_done
21 echo "Getting public IPs information..."
22 try_command_on_node -v any "$CTDB ip -v -n all -X | tail -n +2"
23 ip_info="$out"
25 # Select the first node and find out its interfaces
26 test_node=$(awk -F'|' 'NR == 1 { print $3}' <<<"$ip_info")
27 ifaces=$(awk -F'|' -v tn=$test_node '$3 == tn { print $6 }' <<<"$ip_info" | sed 's@, @ @g' | xargs -n 1 | sort -u)
28 echo "Selected test node ${test_node} with interfaces: ${ifaces}"
30 # Delete all IPs on each interface... deleting IPs from one interface
31 # can cause other interfaces to disappear, so we need to be careful...
32 for i in $ifaces ; do
33 try_command_on_node $test_node "$CTDB ifaces -X"
34 info=$(awk -F'|' -v iface="$i" '$2 == iface { print $0 }' <<<"$out")
36 if [ -z "$info" ] ; then
37 echo "Interface ${i} missing... assuming already deleted!"
38 continue
41 echo "Deleting IPs on interface ${i}, with this information:"
42 echo " $info"
44 try_command_on_node $test_node "$CTDB ip -v -X | tail -n +2"
45 awk -F'|' -v i="$i" \
46 '$6 == i { print $2 }' <<<"$out" |
47 while read ip ; do
48 echo " $ip"
49 try_command_on_node $test_node "$CTDB delip $ip"
50 done
52 try_command_on_node $test_node "$CTDB ifaces -X"
53 info=$(awk -F'|' -v iface="$i" '$2 == iface { print $0 }' <<<"$out")
55 if [ -z "$info" ] ; then
56 echo "GOOD: Interface ${i} has been garbage collected"
57 else
58 echo "BAD: Interface ${i} still exists"
59 echo "$out"
60 exit 1
62 done