From 4f5791ebd03eaec1c7da0865a383175b05102712 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 5 May 2024 19:47:29 +0200 Subject: Adding upstream version 2:4.17.12+dfsg. Signed-off-by: Daniel Baumann --- ctdb/tests/local_daemons.sh | 506 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 506 insertions(+) create mode 100755 ctdb/tests/local_daemons.sh (limited to 'ctdb/tests/local_daemons.sh') diff --git a/ctdb/tests/local_daemons.sh b/ctdb/tests/local_daemons.sh new file mode 100755 index 0000000..334acd5 --- /dev/null +++ b/ctdb/tests/local_daemons.sh @@ -0,0 +1,506 @@ +#!/bin/sh + +set -u + +export CTDB_TEST_MODE="yes" + +# Following 2 lines may be modified by installation script +CTDB_TESTS_ARE_INSTALLED=false +CTDB_TEST_DIR=$(dirname "$0") +export CTDB_TESTS_ARE_INSTALLED CTDB_TEST_DIR + +export TEST_SCRIPTS_DIR="${CTDB_TEST_DIR}/scripts" + +. "${TEST_SCRIPTS_DIR}/common.sh" + +if ! $CTDB_TESTS_ARE_INSTALLED ; then + 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" +fi + +######################################## + +# If the given IP is hosted then print 2 items: maskbits and iface +have_ip () +{ + _addr="$1" + + case "$_addr" in + *:*) _bits=128 ;; + *) _bits=32 ;; + esac + + _t=$(ip addr show to "${_addr}/${_bits}") + [ -n "$_t" ] +} + +setup_nodes () +{ + _num_nodes="$1" + _use_ipv6="$2" + + _have_all_ips=true + for _i in $(seq 0 $((_num_nodes - 1)) ) ; do + if $_use_ipv6 ; then + _j=$(printf "%04x" $((0x5f00 + 1 + _i)) ) + _node_ip="fd00::5357:${_j}" + if have_ip "$_node_ip" ; then + echo "$_node_ip" + else + cat >&2 <&2 < setup [ ... ] + +Options: + -C Comment out given config item (default: item uncommented) + -F Disable failover (default: failover enabled) + -N Nodes file (default: automatically generated) + -n Number of nodes (default: 3) + -P Public addresses file (default: automatically generated) + -R Use a command for the cluster lock (default: use a file) + -r