2008-11-20 20:40:01 +11:00
#!/bin/bash
2008-11-24 17:47:09 +11:00
test_info( )
{
cat <<EOF
Verify that 'ctdb ip' shows the correct output.
Prerequisites:
* An active CTDB cluster with at least 2 active nodes.
Steps:
1. Verify that the status on all of the ctdb nodes is 'OK' .
2. Run 'ctdb ip' on one of the nodes and verify the list of IP
addresses displayed ( cross check the result with the output of
'ip addr show' on the node) .
2014-11-20 15:03:25 +11:00
3. Verify that pipe-separated output is generated with the -X option.
2008-11-24 17:47:09 +11:00
Expected results:
* 'ctdb ip' shows the list of public IPs being served by a node.
EOF
}
2012-04-18 14:55:21 +10:00
. " ${ TEST_SCRIPTS_DIR } /integration.bash "
2008-11-20 20:40:01 +11:00
2008-11-24 17:47:09 +11:00
ctdb_test_init " $@ "
2008-11-20 20:40:01 +11:00
set -e
2009-07-06 17:52:11 +10:00
cluster_is_healthy
2008-11-20 20:40:01 +11:00
echo "Getting list of public IPs..."
2010-02-10 20:27:53 +11:00
try_command_on_node -v 1 " $CTDB ip -n all | tail -n +2 "
2010-01-15 10:53:14 +01:00
ips = $( echo " $out " | sed \
2010-01-16 10:36:35 +01:00
-e 's@ node\[@ @' \
2010-02-10 20:27:53 +11:00
-e 's@\].*$@@' )
machineout = $( echo " $out " | sed -r \
2014-11-20 15:03:25 +11:00
-e 's@^| |$@\|@g' \
2010-02-10 20:27:53 +11:00
-e 's@[[:alpha:]]+\[@@g' \
-e 's@\]@@g' )
2008-11-20 20:40:01 +11:00
2012-07-02 14:05:21 +10:00
if [ -z " $TEST_LOCAL_DAEMONS " ] ; then
2012-03-28 13:51:25 +11:00
while read ip pnn ; do
try_command_on_node $pnn "ip addr show"
2014-11-20 15:03:25 +11:00
if [ " ${ out /inet* ${ ip } \/ } " != " $out " ] ; then
2012-03-28 13:51:25 +11:00
echo " GOOD: node $pnn appears to have $ip assigned "
else
echo " BAD: node $pnn does not appear to have $ip assigned "
testfailures = 1
fi
done <<< " $ips " # bashism to avoid problem setting variable in pipeline.
fi
2008-11-20 20:40:01 +11:00
[ " $testfailures " != 1 ] && echo "Looks good!"
2014-11-20 15:03:25 +11:00
cmd = " $CTDB -X ip -n all | tail -n +2 "
2008-11-20 20:40:01 +11:00
echo " Checking that \" $cmd \" produces expected output... "
try_command_on_node 1 " $cmd "
2010-01-15 10:53:14 +01:00
if [ " $out " = " $machineout " ] ; then
2008-11-20 20:40:01 +11:00
echo "Yep, looks good!"
else
echo "Nope, it looks like this:"
echo " $out "
2010-01-15 10:53:14 +01:00
echo "Should be like this:"
echo " $machineout "
2008-11-20 20:40:01 +11:00
testfailures = 1
fi