diff options
author | Martin Schwenke <martin@meltin.net> | 2018-10-11 21:55:10 +1100 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2018-11-06 07:16:17 +0100 |
commit | 19de5f463d97673a15fecb97af84fc9c288af8ee (patch) | |
tree | b1db2e868d5902bda09cc5ba86d547121f314d1c /ctdb | |
parent | 46fd4f144e7c881887db0deca0ae3b340e19afb3 (diff) | |
download | samba-19de5f463d97673a15fecb97af84fc9c288af8ee.tar.gz |
ctdb-tests: Use local_daemons.sh in local_daemons.bash
The etc-ctdb/ subdirectory containing the event script moves into the
top-level tests/ directory because the subdirectory is really now
owned by local_daemons.sh instead of simple/.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb')
-rwxr-xr-x | ctdb/tests/etc-ctdb/events/legacy/00.test.script (renamed from ctdb/tests/simple/etc-ctdb/events/legacy/00.test.script) | 0 | ||||
-rw-r--r-- | ctdb/tests/simple/scripts/local_daemons.bash | 184 | ||||
-rwxr-xr-x | ctdb/tests/simple/scripts/ssh_local_daemons.sh | 48 | ||||
-rw-r--r-- | ctdb/wscript | 1 |
4 files changed, 27 insertions, 206 deletions
diff --git a/ctdb/tests/simple/etc-ctdb/events/legacy/00.test.script b/ctdb/tests/etc-ctdb/events/legacy/00.test.script index c6797da28d7..c6797da28d7 100755 --- a/ctdb/tests/simple/etc-ctdb/events/legacy/00.test.script +++ b/ctdb/tests/etc-ctdb/events/legacy/00.test.script diff --git a/ctdb/tests/simple/scripts/local_daemons.bash b/ctdb/tests/simple/scripts/local_daemons.bash index 116fa40f424..cf6671757b3 100644 --- a/ctdb/tests/simple/scripts/local_daemons.bash +++ b/ctdb/tests/simple/scripts/local_daemons.bash @@ -1,164 +1,45 @@ -# If we're not running on a real cluster then we need a local copy of -# ctdb (and other stuff) in $PATH and we will use local daemons. +# Hey Emacs, this is a -*- shell-script -*- !!! :-) hdir="$CTDB_SCRIPTS_HELPER_BINDIR" -export CTDB_EVENTD="${hdir}/ctdb-eventd" export CTDB_EVENT_HELPER="${hdir}/ctdb-event" -export CTDB_LOCK_HELPER="${hdir}/ctdb_lock_helper" -export CTDB_RECOVERY_HELPER="${hdir}/ctdb_recovery_helper" -export CTDB_TAKEOVER_HELPER="${hdir}/ctdb_takeover_helper" -export CTDB_CLUSTER_MUTEX_HELPER="${hdir}/ctdb_mutex_fcntl_helper" - -if [ -n "$TEST_SOCKET_WRAPPER_SO_PATH" ] ; then - export LD_PRELOAD="$TEST_SOCKET_WRAPPER_SO_PATH" - export SOCKET_WRAPPER_DIR="${SIMPLE_TESTS_VAR_DIR}/sw" - mkdir -p "$SOCKET_WRAPPER_DIR" + +if $CTDB_TESTS_ARE_INSTALLED ; then + # Find it in $PATH + helper="ctdb_local_daemons" +else + helper="${CTDB_TEST_DIR}/local_daemons.sh" fi +ctdb_local_daemons="${helper} ${SIMPLE_TESTS_VAR_DIR}" + # onnode will execute this, which fakes ssh against local daemons -export ONNODE_SSH="${TEST_SUBDIR}/scripts/ssh_local_daemons.sh" +export ONNODE_SSH="${ctdb_local_daemons} ssh" ####################################### -# If the given IP is hosted then print 2 items: maskbits and iface -have_ip () -{ - local addr="$1" - local bits t - - case "$addr" in - *:*) bits=128 ;; - *) bits=32 ;; - esac - - t=$(ip addr show to "${addr}/${bits}") - [ -n "$t" ] -} - -setup_nodes () -{ - local have_all_ips=true - local i - for i in $(seq 0 $((TEST_LOCAL_DAEMONS - 1)) ) ; do - if [ -n "$CTDB_USE_IPV6" ]; then - local j=$(printf "%04x" $((0x5f00 + 1 + i)) ) - local node_ip="fd00::5357:${j}" - if have_ip "$node_ip" ; then - echo "$node_ip" - else - cat >&2 <<EOF -ERROR: ${node_ip} not on an interface, please add it -EOF - have_all_ips=false - fi - else - local c=$(( i / 100 )) - local d=$(( 1 + (i % 100) )) - echo "127.0.${c}.${d}" - fi - done - - # Fail if we don't have all of the IPv6 addresses assigned - $have_all_ips -} - -setup_public_addresses () -{ - local pnn_no_ips="$1" - - local i - for i in $(seq 0 $((TEST_LOCAL_DAEMONS - 1)) ) ; do - if [ $i -eq $pnn_no_ips ] ; then - continue - fi - - # 2 public addresses on most nodes, just to make - # things interesting - if [ -n "$CTDB_USE_IPV6" ]; then - printf "fc00:10::1:%x/64 lo\n" $((1 + i)) - printf "fc00:10::2:%x/64 lo\n" $((1 + i)) - else - local c1=$(( 100 + (i / 100) )) - local c2=$(( 200 + (i / 100) )) - local d=$(( 1 + (i % 100) )) - printf "192.168.${c1}.${d}/24 lo\n" - printf "192.168.${c2}.${d}/24 lo\n" - fi - done -} - setup_ctdb () { - local no_public_addresses=false + local public_addresses="" local no_event_scripts=false - local disable_failover=false + local disable_failover="" case "$1" in - --no-public-addresses) no_public_addresses=true ;; + --no-public-addresses) public_addresses="/dev/null" ;; --no-event-scripts) no_event_scripts=true ;; - --disable-failover) disable_failover=true ;; + --disable-failover) disable_failover="yes" ;; esac - nodes_file="${SIMPLE_TESTS_VAR_DIR}/nodes" - setup_nodes >"$nodes_file" || return 1 - - # If there are (strictly) greater than 2 nodes then we'll - # randomly choose a node to have no public addresses - local pnn_no_ips=-1 - if [ $TEST_LOCAL_DAEMONS -gt 2 ] ; then - pnn_no_ips=$((RANDOM % TEST_LOCAL_DAEMONS)) - fi - - local public_addresses_all="${SIMPLE_TESTS_VAR_DIR}/public_addresses" - setup_public_addresses $pnn_no_ips >"$public_addresses_all" + $ctdb_local_daemons setup \ + -n "$TEST_LOCAL_DAEMONS" \ + ${disable_failover:+-F} \ + ${public_addresses:+-P} ${public_addresses} \ + ${CTDB_USE_IPV6:+-6} \ + ${TEST_SOCKET_WRAPPER_SO_PATH:+-S} ${TEST_SOCKET_WRAPPER_SO_PATH} local pnn for pnn in $(seq 0 $(($TEST_LOCAL_DAEMONS - 1))) ; do - setup_ctdb_base "$SIMPLE_TESTS_VAR_DIR" "node.${pnn}" \ - functions notify.sh debug-hung-script.sh - - cp "$nodes_file" "${CTDB_BASE}/nodes" - - local public_addresses="${CTDB_BASE}/public_addresses" - - if $no_public_addresses || [ $pnn_no_ips -eq $pnn ] ; then - echo "Node ${pnn} will have no public IPs." - : >"$public_addresses" - else - cp "$public_addresses_all" "$public_addresses" - fi - - local node_ip=$(sed -n -e "$(($pnn + 1))p" "$nodes_file") - - local db_dir="${CTDB_BASE}/db" - local d - for d in "volatile" "persistent" "state" ; do - mkdir -p "${db_dir}/${d}" - done - if $no_event_scripts ; then rm -vf "${CTDB_BASE}/events/legacy/"* fi - - cat >"${CTDB_BASE}/ctdb.conf" <<EOF -[logging] - location = file:${CTDB_BASE}/log.ctdb - log level = INFO - -[cluster] - recovery lock = ${SIMPLE_TESTS_VAR_DIR}/rec.lock - node address = ${node_ip} - -[database] - volatile database directory = ${db_dir}/volatile - persistent database directory = ${db_dir}/persistent - state database directory = ${db_dir}/state - -[failover] - disabled = ${disable_failover} - -[event] - debug script = debug-hung-script.sh -EOF done } @@ -166,28 +47,24 @@ start_ctdb_1 () { local pnn="$1" - onnode "$pnn" $VALGRIND ctdbd + $ctdb_local_daemons start "$pnn" } ctdb_start_all () { - echo "Starting $TEST_LOCAL_DAEMONS ctdb daemons..." - - onnode all $VALGRIND ctdbd + $ctdb_local_daemons start "all" } stop_ctdb_1 () { local pnn="$1" - onnode "$pnn" $CTDB shutdown + $ctdb_local_daemons stop "$pnn" } ctdb_stop_all () { - echo "Stopping $TEST_LOCAL_DAEMONS ctdb daemons..." - - onnode -p all $CTDB shutdown + $ctdb_local_daemons stop "all" } restart_ctdb_1 () @@ -196,14 +73,5 @@ restart_ctdb_1 () start_ctdb_1 "$1" } -# onnode will use CTDB_BASES to help the ctdb tool connection to each -# daemon -export CTDB_BASES="" -for i in $(seq 0 $(($TEST_LOCAL_DAEMONS - 1))) ; do - b="${SIMPLE_TESTS_VAR_DIR}/node.${i}" - CTDB_BASES="${CTDB_BASES}${CTDB_BASES:+ }${b}" -done - -# Need a default CTDB_BASE for onnode (to find the functions file). -# Any node will do, so pick the 1st... -export CTDB_BASE="${CTDB_BASES%% *}" +# onnode just needs the nodes file, so use the common one +export CTDB_BASE="$SIMPLE_TESTS_VAR_DIR" diff --git a/ctdb/tests/simple/scripts/ssh_local_daemons.sh b/ctdb/tests/simple/scripts/ssh_local_daemons.sh deleted file mode 100755 index 6defd99795b..00000000000 --- a/ctdb/tests/simple/scripts/ssh_local_daemons.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh - -nodes="${CTDB_BASE}/nodes" - -# Only try to respect ssh -n option, others can't be used so discard them -close_stdin=false -while : ; do - case "$1" in - -n) close_stdin=true ; shift ;; - -*) shift ;; - *) break ;; - esac -done - -if [ $# -ne 2 ] ; then - echo "usage: $0 <ip> <command>" >&2 - exit 1 -fi - -# IP adress of node. onnode can pass hostnames but not in these tests -ip="$1" -# Complete command is provide by onnode as a single argument -command="$2" - -num=$(awk -v ip="$ip" '$1 == ip { print NR }' "$nodes") -pnn=$((num - 1)) - -# Determine the correct CTDB base directory -export CTDB_BASE="" -n=0 -for b in $CTDB_BASES ; do - if [ $n -eq $pnn ] ; then - CTDB_BASE="$b" - break - fi - n=$((n + 1)) -done - -if [ -z "$CTDB_BASE" ] ; then - echo "$0: Unable to find base for node ${ip}" >&2 - exit 1 -fi - -if $close_stdin ; then - exec sh -c "$command" <&- -else - exec sh -c "$command" -fi diff --git a/ctdb/wscript b/ctdb/wscript index e8e8e4d290e..baf660fadf6 100644 --- a/ctdb/wscript +++ b/ctdb/wscript @@ -1051,6 +1051,7 @@ def build(bld): 'complex', 'ctdb_eventd', 'cunit', + 'etc-ctdb', 'eventd', 'eventscripts', 'onnode', |