summaryrefslogtreecommitdiff
path: root/ctdb/tests/eventscripts
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2016-04-08 16:21:08 +1000
committerAmitay Isaacs <amitay@samba.org>2016-04-15 05:57:17 +0200
commitce33a7cb1e6d91b56bc9261efb4bf6d53371f77e (patch)
tree7f8c3f918771814734c61b62272b9e3f77cea97d /ctdb/tests/eventscripts
parentb7376861cbbcdddff9764f622f8c0bc9526b6690 (diff)
downloadsamba-ce33a7cb1e6d91b56bc9261efb4bf6d53371f77e.tar.gz
ctdb-scripts: Call out to ctdb_lvs helper from 91.lvs
To keep this commit comprehensible, 91.lvs and the CTDB CLI tool are temporarily inconsistent. The tool will be made consistent in a subsequent commit. LVS now uses a configuration file specified by CTDB_LVS_NODES and supports the same slave-only syntax as CTDB_NATGW_NODES. LVS also uses new variable CTDB_LVS_PUBLIC_IFACE instead of CTDB_PUBLIC_INTERFACE. Update unit tests and documentation. Note that the --lvs and --single-public-ip daemon options are no longer used. These will be removed and relevant documentation updated in a subsequent commit. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/tests/eventscripts')
-rw-r--r--ctdb/tests/eventscripts/scripts/local.sh11
-rwxr-xr-xctdb/tests/eventscripts/stubs/ctdb36
-rwxr-xr-xctdb/tests/eventscripts/stubs/ctdb_lvs53
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