diff options
Diffstat (limited to 'ctdb/tests/eventscripts')
-rw-r--r-- | ctdb/tests/eventscripts/scripts/local.sh | 11 | ||||
-rwxr-xr-x | ctdb/tests/eventscripts/stubs/ctdb | 36 | ||||
-rwxr-xr-x | ctdb/tests/eventscripts/stubs/ctdb_lvs | 53 |
3 files changed, 65 insertions, 35 deletions
diff --git a/ctdb/tests/eventscripts/scripts/local.sh b/ctdb/tests/eventscripts/scripts/local.sh index 0f15be4edb9..51f38580f7e 100644 --- a/ctdb/tests/eventscripts/scripts/local.sh +++ b/ctdb/tests/eventscripts/scripts/local.sh @@ -543,9 +543,6 @@ EOF setup_ctdb_lvs () { - export CTDB_LVS_PUBLIC_IP="$1" - export CTDB_PUBLIC_INTERFACE="$2" - lvs_state_dir="${EVENTSCRIPTS_TESTS_VAR_DIR}/lvs" mkdir -p "$lvs_state_dir" @@ -554,8 +551,12 @@ setup_ctdb_lvs () lvs_header=$(ipvsadm -l -n) - # Not an official configuration file, just used by the ctdb - # tool stub + export CTDB_LVS_PUBLIC_IP="$1" + export CTDB_LVS_PUBLIC_IFACE="$2" + + [ -n "$CTDB_LVS_PUBLIC_IP" ] || return 0 + [ -n "$CTDB_LVS_PUBLIC_IFACE" ] || return 0 + export CTDB_LVS_NODES=$(mktemp --tmpdir="$lvs_state_dir") export FAKE_CTDB_LVS_MASTER="" diff --git a/ctdb/tests/eventscripts/stubs/ctdb b/ctdb/tests/eventscripts/stubs/ctdb index 44b934a6a41..4c4278dd5be 100755 --- a/ctdb/tests/eventscripts/stubs/ctdb +++ b/ctdb/tests/eventscripts/stubs/ctdb @@ -236,16 +236,16 @@ ctdb_shutdown () ###################################################################### -# This is only used by the NAT gateway code at the moment, so use a -# hack. Assume that $CTDB_NATGW_NODES contains all nodes in the -# cluster (which is what current tests assume). Use the PNN to find -# the address from this file. The NAT gateway code only used the -# address, so just mark the node healthy. +# This is only used by the NAT and LVS gateway code at the moment, so +# use a hack. Assume that $CTDB_NATGW_NODES or $CTDB_LVS_NODES +# contains all nodes in the cluster (which is what current tests +# assume). Use the PNN to find the address from this file. The NAT +# gateway code only used the address, so just mark the node healthy. ctdb_nodestatus () { echo '|Node|IP|Disconnected|Banned|Disabled|Unhealthy|Stopped|Inactive|PartiallyOnline|ThisNode|' _line=$(( $FAKE_CTDB_PNN + 1 )) - _ip=$(sed -e "${_line}p" "$CTDB_NATGW_NODES") + _ip=$(sed -e "${_line}p" "${CTDB_NATGW_NODES:-${CTDB_LVS_NODES}}") echo "|${FAKE_CTDB_PNN}|${_ip}|0|0|0|0|0|0|0|Y|" } @@ -358,28 +358,6 @@ EOF ###################################################################### -ctdb_lvs_master () -{ - if [ -n "$FAKE_CTDB_LVS_MASTER" ] ; then - echo "Node ${FAKE_CTDB_LVS_MASTER} is LVS master" - return 0 - else - echo "This is no LVS master" - return 255 - fi -} - -ctdb_lvs () -{ - _pnn=0 - while read _ip _opts ; do - echo "${_pnn}:${_ip}" - _pnn=$(($_pnn + 1)) - done <"$CTDB_LVS_NODES" -} - -###################################################################### - case "$1" in gettickles) setup_tickles @@ -477,7 +455,5 @@ case "$1" in shutdown) ctdb_shutdown "$@";; setvar) ctdb_setvar "$@" ;; nodestatus) ctdb_nodestatus "$@" ;; - lvsmaster) ctdb_lvs_master "$@" ;; - lvs) ctdb_lvs "$@" ;; *) not_implemented "$1" ;; esac diff --git a/ctdb/tests/eventscripts/stubs/ctdb_lvs b/ctdb/tests/eventscripts/stubs/ctdb_lvs new file mode 100755 index 00000000000..daca8e229fa --- /dev/null +++ b/ctdb/tests/eventscripts/stubs/ctdb_lvs @@ -0,0 +1,53 @@ +#!/bin/sh + +prog="ctdb_lvs" + +# Print a message and exit. +die () +{ + echo "$1" >&2 ; exit ${2:-1} +} + +not_implemented_exit_code=1 + +usage () +{ + cat >&2 <<EOF +Usage: $prog { master | list } +EOF + exit 1 +} + +not_implemented () +{ + echo "${prog}: command \"$1\" not implemented in stub" >&2 + exit $not_implemented_exit_code +} + +ctdb_lvs_master () +{ + if [ -n "$FAKE_CTDB_LVS_MASTER" ] ; then + echo "Node ${FAKE_CTDB_LVS_MASTER} is LVS master" + return 0 + else + echo "This is no LVS master" + return 255 + fi +} + +ctdb_lvs_list () +{ + _pnn=0 + while read _ip _opts ; do + echo "${_pnn}:${_ip}" + _pnn=$(($_pnn + 1)) + done <"$CTDB_LVS_NODES" +} + +###################################################################### + +case "$1" in + master) ctdb_lvs_master "$@" ;; + list) ctdb_lvs_list "$@" ;; + *) not_implemented "$1" ;; +esac |