From: Martin Schwenke Date: Thu, 11 Oct 2018 10:55:10 +0000 (+1100) Subject: ctdb-tests: Use local_daemons.sh in local_daemons.bash X-Git-Tag: tdb-1.3.17~871 X-Git-Url: http://git.samba.org/?p=samba.git;a=commitdiff_plain;h=19de5f463d97673a15fecb97af84fc9c288af8ee 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 Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/tests/simple/etc-ctdb/events/legacy/00.test.script b/ctdb/tests/etc-ctdb/events/legacy/00.test.script similarity index 100% rename from ctdb/tests/simple/etc-ctdb/events/legacy/00.test.script rename to 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 <"$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" < " >&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',