mirror of
https://github.com/samba-team/samba.git
synced 2025-08-26 01:49:31 +03:00
ctdb-tests: Reformat with "shfmt -w -p -i 0 -fn"
Best reviewed with "git show -w". Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
committed by
Martin Schwenke
parent
7813c979ed
commit
cbda1a78dc
@ -1,4 +1,4 @@
|
|||||||
setup ()
|
setup()
|
||||||
{
|
{
|
||||||
setup_dbdir
|
setup_dbdir
|
||||||
setup_date
|
setup_date
|
||||||
@ -15,7 +15,7 @@ setup ()
|
|||||||
"
|
"
|
||||||
}
|
}
|
||||||
|
|
||||||
result_filter ()
|
result_filter()
|
||||||
{
|
{
|
||||||
_date="[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"
|
_date="[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"
|
||||||
_time="[0-9][0-9][0-9][0-9][0-9][0-9]"
|
_time="[0-9][0-9][0-9][0-9][0-9][0-9]"
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
setup ()
|
setup()
|
||||||
{
|
{
|
||||||
if [ $# -eq 1 ] ; then
|
if [ $# -eq 1 ]; then
|
||||||
reclock="$1"
|
reclock="$1"
|
||||||
else
|
else
|
||||||
reclock="${CTDB_TEST_TMP_DIR}/reclock_subdir/rec.lock"
|
reclock="${CTDB_TEST_TMP_DIR}/reclock_subdir/rec.lock"
|
||||||
fi
|
fi
|
||||||
CTDB_RECOVERY_LOCK="$reclock"
|
CTDB_RECOVERY_LOCK="$reclock"
|
||||||
|
|
||||||
if [ -n "$CTDB_RECOVERY_LOCK" ] ; then
|
if [ -n "$CTDB_RECOVERY_LOCK" ]; then
|
||||||
cat >>"${CTDB_BASE}/ctdb.conf" <<EOF
|
cat >>"${CTDB_BASE}/ctdb.conf" <<EOF
|
||||||
[cluster]
|
[cluster]
|
||||||
recovery lock = $CTDB_RECOVERY_LOCK
|
recovery lock = $CTDB_RECOVERY_LOCK
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
set_mem_usage ()
|
set_mem_usage()
|
||||||
{
|
{
|
||||||
_mem_usage="${1:-10}" # Default is 10%
|
_mem_usage="${1:-10}" # Default is 10%
|
||||||
_swap_usage="${2:-0}" # Default is 0%
|
_swap_usage="${2:-0}" # Default is 0%
|
||||||
|
|
||||||
_swap_total=5857276
|
_swap_total=5857276
|
||||||
_swap_free=$(( (100 - $_swap_usage) * $_swap_total / 100 ))
|
_swap_free=$(((100 - $_swap_usage) * $_swap_total / 100))
|
||||||
|
|
||||||
_mem_total=3940712
|
_mem_total=3940712
|
||||||
_mem_free=225268
|
_mem_free=225268
|
||||||
_mem_buffers=146120
|
_mem_buffers=146120
|
||||||
_mem_cached=$(( $_mem_total * (100 - $_mem_usage) / 100 -
|
_mem_cached=$(($_mem_total * (100 - $_mem_usage) / 100 - \
|
||||||
$_mem_free - $_mem_buffers ))
|
$_mem_free - $_mem_buffers))
|
||||||
|
|
||||||
export FAKE_PROC_MEMINFO="\
|
export FAKE_PROC_MEMINFO="\
|
||||||
MemTotal: ${_mem_total} kB
|
MemTotal: ${_mem_total} kB
|
||||||
@ -31,12 +31,12 @@ SwapFree: ${_swap_free} kB
|
|||||||
..."
|
..."
|
||||||
}
|
}
|
||||||
|
|
||||||
set_fs_usage ()
|
set_fs_usage()
|
||||||
{
|
{
|
||||||
export FAKE_FS_USE="${1:-10}" # Default is 10% usage
|
export FAKE_FS_USE="${1:-10}" # Default is 10% usage
|
||||||
}
|
}
|
||||||
|
|
||||||
setup ()
|
setup()
|
||||||
{
|
{
|
||||||
setup_dbdir
|
setup_dbdir
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
setup ()
|
setup()
|
||||||
{
|
{
|
||||||
:
|
:
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
setup ()
|
setup()
|
||||||
{
|
{
|
||||||
setup_public_addresses
|
setup_public_addresses
|
||||||
}
|
}
|
||||||
|
|
||||||
_tcp_connections ()
|
_tcp_connections()
|
||||||
{
|
{
|
||||||
_count="$1"
|
_count="$1"
|
||||||
_sip="$2"
|
_sip="$2"
|
||||||
@ -14,7 +14,7 @@ _tcp_connections ()
|
|||||||
_cip_prefix="${_cip_base%.*}"
|
_cip_prefix="${_cip_base%.*}"
|
||||||
_cip_suffix="${_cip_base##*.}"
|
_cip_suffix="${_cip_base##*.}"
|
||||||
|
|
||||||
for _i in $(seq 1 $_count) ; do
|
for _i in $(seq 1 $_count); do
|
||||||
_cip_last=$((_cip_suffix + _i))
|
_cip_last=$((_cip_suffix + _i))
|
||||||
_cip="${_cip_prefix}.${_cip_last}"
|
_cip="${_cip_prefix}.${_cip_last}"
|
||||||
_cport=$((_cport_base + _i))
|
_cport=$((_cport_base + _i))
|
||||||
@ -22,14 +22,14 @@ _tcp_connections ()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_tcp_connections ()
|
setup_tcp_connections()
|
||||||
{
|
{
|
||||||
_t="${FAKE_NETWORK_STATE}/tcp-established"
|
_t="${FAKE_NETWORK_STATE}/tcp-established"
|
||||||
export FAKE_NETSTAT_TCP_ESTABLISHED_FILE="$_t"
|
export FAKE_NETSTAT_TCP_ESTABLISHED_FILE="$_t"
|
||||||
_tcp_connections "$@" >"$FAKE_NETSTAT_TCP_ESTABLISHED_FILE"
|
_tcp_connections "$@" >"$FAKE_NETSTAT_TCP_ESTABLISHED_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_tcp_connections_unkillable ()
|
setup_tcp_connections_unkillable()
|
||||||
{
|
{
|
||||||
# These connections are listed by the "ss" stub but are not
|
# These connections are listed by the "ss" stub but are not
|
||||||
# killed by the "ctdb killtcp" stub. So killing these
|
# killed by the "ctdb killtcp" stub. So killing these
|
||||||
@ -44,7 +44,7 @@ setup_tcp_connections_unkillable ()
|
|||||||
|
|
||||||
# arg1 is interface name, arg2 is currently active slave (use "None"
|
# arg1 is interface name, arg2 is currently active slave (use "None"
|
||||||
# if none), arg3 is MII status ("up" or "down").
|
# if none), arg3 is MII status ("up" or "down").
|
||||||
setup_bond ()
|
setup_bond()
|
||||||
{
|
{
|
||||||
_iface="$1"
|
_iface="$1"
|
||||||
_slave="${2:-${_iface}_sl_0}"
|
_slave="${2:-${_iface}_sl_0}"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
setup ()
|
setup()
|
||||||
{
|
{
|
||||||
debug "Setting up NAT gateway"
|
debug "Setting up NAT gateway"
|
||||||
|
|
||||||
@ -9,10 +9,10 @@ setup ()
|
|||||||
|
|
||||||
# A separate function for this makes sense because it can be done
|
# A separate function for this makes sense because it can be done
|
||||||
# multiple times per test
|
# multiple times per test
|
||||||
setup_ctdb_natgw ()
|
setup_ctdb_natgw()
|
||||||
{
|
{
|
||||||
# Read from stdin
|
# Read from stdin
|
||||||
while read _ip _opts ; do
|
while read _ip _opts; do
|
||||||
case "$_opts" in
|
case "$_opts" in
|
||||||
leader)
|
leader)
|
||||||
export FAKE_CTDB_NATGW_LEADER="$_ip"
|
export FAKE_CTDB_NATGW_LEADER="$_ip"
|
||||||
@ -43,11 +43,11 @@ CTDB_NATGW_DEFAULT_GATEWAY="10.1.1.254"
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
ok_natgw_leader_ip_addr_show ()
|
ok_natgw_leader_ip_addr_show()
|
||||||
{
|
{
|
||||||
_mac=$(echo "$CTDB_NATGW_PUBLIC_IFACE" |
|
_mac=$(echo "$CTDB_NATGW_PUBLIC_IFACE" |
|
||||||
cksum |
|
cksum |
|
||||||
sed -r -e 's@(..)(..)(..).*@fe:fe:fe:\1:\2:\3@')
|
sed -r -e 's@(..)(..)(..).*@fe:fe:fe:\1:\2:\3@')
|
||||||
|
|
||||||
# This is based on CTDB_NATGW_PUBLIC_IP
|
# This is based on CTDB_NATGW_PUBLIC_IP
|
||||||
_brd="10.1.1.255"
|
_brd="10.1.1.255"
|
||||||
@ -60,11 +60,11 @@ ok_natgw_leader_ip_addr_show ()
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
ok_natgw_follower_ip_addr_show ()
|
ok_natgw_follower_ip_addr_show()
|
||||||
{
|
{
|
||||||
_mac=$(echo "$CTDB_NATGW_PUBLIC_IFACE" |
|
_mac=$(echo "$CTDB_NATGW_PUBLIC_IFACE" |
|
||||||
cksum |
|
cksum |
|
||||||
sed -r -e 's@(..)(..)(..).*@fe:fe:fe:\1:\2:\3@')
|
sed -r -e 's@(..)(..)(..).*@fe:fe:fe:\1:\2:\3@')
|
||||||
|
|
||||||
ok <<EOF
|
ok <<EOF
|
||||||
1: ${CTDB_NATGW_PUBLIC_IFACE}: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
|
1: ${CTDB_NATGW_PUBLIC_IFACE}: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
|
||||||
@ -72,12 +72,12 @@ ok_natgw_follower_ip_addr_show ()
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
ok_natgw_leader_static_routes ()
|
ok_natgw_leader_static_routes()
|
||||||
{
|
{
|
||||||
_nl="
|
_nl="
|
||||||
"
|
"
|
||||||
_t=""
|
_t=""
|
||||||
for _i in $CTDB_NATGW_STATIC_ROUTES ; do
|
for _i in $CTDB_NATGW_STATIC_ROUTES; do
|
||||||
# This is intentionally different to the code in 11.natgw ;-)
|
# This is intentionally different to the code in 11.natgw ;-)
|
||||||
case "$_i" in
|
case "$_i" in
|
||||||
*@*)
|
*@*)
|
||||||
@ -87,6 +87,7 @@ ok_natgw_leader_static_routes ()
|
|||||||
*)
|
*)
|
||||||
_net="$_i"
|
_net="$_i"
|
||||||
_gw="$CTDB_NATGW_DEFAULT_GATEWAY"
|
_gw="$CTDB_NATGW_DEFAULT_GATEWAY"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
[ -n "$_gw" ] || continue
|
[ -n "$_gw" ] || continue
|
||||||
@ -97,12 +98,12 @@ ok_natgw_leader_static_routes ()
|
|||||||
ok "$_t"
|
ok "$_t"
|
||||||
}
|
}
|
||||||
|
|
||||||
ok_natgw_follower_static_routes ()
|
ok_natgw_follower_static_routes()
|
||||||
{
|
{
|
||||||
_nl="
|
_nl="
|
||||||
"
|
"
|
||||||
_t=""
|
_t=""
|
||||||
for _i in $CTDB_NATGW_STATIC_ROUTES ; do
|
for _i in $CTDB_NATGW_STATIC_ROUTES; do
|
||||||
# This is intentionally different to the code in 11.natgw ;-)
|
# This is intentionally different to the code in 11.natgw ;-)
|
||||||
_net=$(echo "$_i" | sed -e 's|@.*||')
|
_net=$(echo "$_i" | sed -e 's|@.*||')
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
setup ()
|
setup()
|
||||||
{
|
{
|
||||||
setup_public_addresses
|
setup_public_addresses
|
||||||
|
|
||||||
@ -18,25 +18,28 @@ EOF
|
|||||||
# Create policy routing configuration in $CTDB_PER_IP_ROUTING_CONF.
|
# Create policy routing configuration in $CTDB_PER_IP_ROUTING_CONF.
|
||||||
# $1 is the number of assigned IPs to use (<num>, all), defaulting to
|
# $1 is the number of assigned IPs to use (<num>, all), defaulting to
|
||||||
# 1. If $2 is "default" then a default route is also added.
|
# 1. If $2 is "default" then a default route is also added.
|
||||||
create_policy_routing_config ()
|
create_policy_routing_config()
|
||||||
{
|
{
|
||||||
_num_ips="${1:-1}"
|
_num_ips="${1:-1}"
|
||||||
_should_add_default="$2"
|
_should_add_default="$2"
|
||||||
|
|
||||||
ctdb_get_my_public_addresses |
|
ctdb_get_my_public_addresses |
|
||||||
if [ "$_num_ips" = "all" ] ; then
|
if [ "$_num_ips" = "all" ]; then
|
||||||
cat
|
cat
|
||||||
else
|
else
|
||||||
{ head -n "$_num_ips" ; cat >/dev/null ; }
|
{
|
||||||
fi |
|
head -n "$_num_ips"
|
||||||
while read _dev _ip _bits ; do
|
cat >/dev/null
|
||||||
_net=$(ipv4_host_addr_to_net "$_ip" "$_bits")
|
}
|
||||||
_gw="${_net%.*}.254" # a dumb, calculated default
|
fi |
|
||||||
|
while read _dev _ip _bits; do
|
||||||
|
_net=$(ipv4_host_addr_to_net "$_ip" "$_bits")
|
||||||
|
_gw="${_net%.*}.254" # a dumb, calculated default
|
||||||
|
|
||||||
echo "$_ip $_net"
|
echo "$_ip $_net"
|
||||||
|
|
||||||
if [ "$_should_add_default" = "default" ] ; then
|
if [ "$_should_add_default" = "default" ]; then
|
||||||
echo "$_ip 0.0.0.0/0 $_gw"
|
echo "$_ip 0.0.0.0/0 $_gw"
|
||||||
fi
|
fi
|
||||||
done >"$CTDB_PER_IP_ROUTING_CONF"
|
done >"$CTDB_PER_IP_ROUTING_CONF"
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
setup ()
|
setup()
|
||||||
{
|
{
|
||||||
_failures=""
|
_failures=""
|
||||||
_devices=""
|
_devices=""
|
||||||
for i ; do
|
for i; do
|
||||||
case "$i" in
|
case "$i" in
|
||||||
\!*)
|
\!*)
|
||||||
_t="${i#!}"
|
_t="${i#!}"
|
||||||
echo "Marking ${_t} as having no active paths"
|
echo "Marking ${_t} as having no active paths"
|
||||||
_failures="${_failures}${_failures:+ }${_t}"
|
_failures="${_failures}${_failures:+ }${_t}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
_t="$i"
|
_t="$i"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
_devices="${_devices}${_devices:+ }${_t}"
|
_devices="${_devices}${_devices:+ }${_t}"
|
||||||
done
|
done
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
setup ()
|
setup()
|
||||||
{
|
{
|
||||||
setup_script_options <<EOF
|
setup_script_options <<EOF
|
||||||
CTDB_CLAMD_SOCKET="/var/run/clamd.sock"
|
CTDB_CLAMD_SOCKET="/var/run/clamd.sock"
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
setup ()
|
setup()
|
||||||
{
|
{
|
||||||
debug "Setting up VSFTPD environment: service $1, not managed by CTDB"
|
debug "Setting up VSFTPD environment: service $1, not managed by CTDB"
|
||||||
|
|
||||||
_service_name="vsftpd"
|
_service_name="vsftpd"
|
||||||
|
|
||||||
if [ "$1" != "down" ] ; then
|
if [ "$1" != "down" ]; then
|
||||||
service "$_service_name" start
|
service "$_service_name" start
|
||||||
else
|
else
|
||||||
service "$_service_name" force-stopped
|
service "$_service_name" force-stopped
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
setup ()
|
setup()
|
||||||
{
|
{
|
||||||
debug "Setting up HTTPD environment: service $1, not managed by CTDB"
|
debug "Setting up HTTPD environment: service $1, not managed by CTDB"
|
||||||
|
|
||||||
if [ "$1" != "down" ] ; then
|
if [ "$1" != "down" ]; then
|
||||||
for _service_name in "apache2" "httpd" ; do
|
for _service_name in "apache2" "httpd"; do
|
||||||
service "$_service_name" start
|
service "$_service_name" start
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
for _service_name in "apache2" "httpd" ; do
|
for _service_name in "apache2" "httpd"; do
|
||||||
service "$_service_name" force-stopped
|
service "$_service_name" force-stopped
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
setup ()
|
setup()
|
||||||
{
|
{
|
||||||
service_name="netbios"
|
service_name="netbios"
|
||||||
|
|
||||||
if [ "$1" != "down" ] ; then
|
if [ "$1" != "down" ]; then
|
||||||
|
|
||||||
debug "Marking Netbios name services as up, listening and managed by CTDB"
|
debug "Marking Netbios name services as up, listening and managed by CTDB"
|
||||||
|
|
||||||
# All possible service names for all known distros.
|
# All possible service names for all known distros.
|
||||||
for i in "nmb" "nmbd" ; do
|
for i in "nmb" "nmbd"; do
|
||||||
service "$i" force-started
|
service "$i" force-started
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
debug "Marking Netbios name services as down, not listening and not managed by CTDB"
|
debug "Marking Netbios name services as down, not listening and not managed by CTDB"
|
||||||
|
|
||||||
# All possible service names for all known distros.
|
# All possible service names for all known distros.
|
||||||
for i in "nmb" "nmbd" ; do
|
for i in "nmb" "nmbd"; do
|
||||||
service "$i" force-stopped
|
service "$i" force-stopped
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
setup ()
|
setup()
|
||||||
{
|
{
|
||||||
service_name="winbind"
|
service_name="winbind"
|
||||||
|
|
||||||
if [ "$1" != "down" ] ; then
|
if [ "$1" != "down" ]; then
|
||||||
|
|
||||||
debug "Marking Winbind service as up and managed by CTDB"
|
debug "Marking Winbind service as up and managed by CTDB"
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ setup ()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
wbinfo_down ()
|
wbinfo_down()
|
||||||
{
|
{
|
||||||
debug "Making wbinfo commands fail"
|
debug "Making wbinfo commands fail"
|
||||||
FAKE_WBINFO_FAIL="yes"
|
FAKE_WBINFO_FAIL="yes"
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
setup ()
|
setup()
|
||||||
{
|
{
|
||||||
service_name="samba"
|
service_name="samba"
|
||||||
|
|
||||||
if [ "$1" != "down" ] ; then
|
if [ "$1" != "down" ]; then
|
||||||
|
|
||||||
debug "Marking Samba services as up, listening and managed by CTDB"
|
debug "Marking Samba services as up, listening and managed by CTDB"
|
||||||
|
|
||||||
# All possible service names for all known distros.
|
# All possible service names for all known distros.
|
||||||
for i in "smb" "samba" "smbd" ; do
|
for i in "smb" "samba" "smbd"; do
|
||||||
service "$i" force-started
|
service "$i" force-started
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ setup ()
|
|||||||
debug "Marking Samba services as down, not listening and not managed by CTDB"
|
debug "Marking Samba services as down, not listening and not managed by CTDB"
|
||||||
|
|
||||||
# All possible service names for all known distros.
|
# All possible service names for all known distros.
|
||||||
for i in "smb" "samba" "smbd" ; do
|
for i in "smb" "samba" "smbd"; do
|
||||||
service "$i" force-stopped
|
service "$i" force-stopped
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ EOF
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
samba_setup_fake_threads ()
|
samba_setup_fake_threads()
|
||||||
{
|
{
|
||||||
export FAKE_SMBD_THREAD_PIDS="$*"
|
export FAKE_SMBD_THREAD_PIDS="$*"
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ samba_setup_fake_threads ()
|
|||||||
"
|
"
|
||||||
_out=""
|
_out=""
|
||||||
_count=0
|
_count=0
|
||||||
for _pid ; do
|
for _pid; do
|
||||||
[ "$_count" -lt 5 ] || break
|
[ "$_count" -lt 5 ] || break
|
||||||
_t=$(program_stack_trace "smbd" $_pid)
|
_t=$(program_stack_trace "smbd" $_pid)
|
||||||
_out="${_out:+${_out}${_nl}}${_t}"
|
_out="${_out:+${_out}${_nl}}${_t}"
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
setup ()
|
setup()
|
||||||
{
|
{
|
||||||
setup_public_addresses
|
setup_public_addresses
|
||||||
setup_shares
|
setup_shares
|
||||||
|
|
||||||
service_name="nfs"
|
service_name="nfs"
|
||||||
|
|
||||||
if [ -z "$CTDB_NFS_DISTRO_STYLE" ] ; then
|
if [ -z "$CTDB_NFS_DISTRO_STYLE" ]; then
|
||||||
# Currently supported: sysvinit-redhat, systemd-redhat
|
# Currently supported: sysvinit-redhat, systemd-redhat
|
||||||
CTDB_NFS_DISTRO_STYLE="systemd-redhat"
|
CTDB_NFS_DISTRO_STYLE="systemd-redhat"
|
||||||
fi
|
fi
|
||||||
@ -20,7 +20,7 @@ EOF
|
|||||||
|
|
||||||
export RPCNFSDCOUNT
|
export RPCNFSDCOUNT
|
||||||
|
|
||||||
if [ "$1" != "down" ] ; then
|
if [ "$1" != "down" ]; then
|
||||||
debug <<EOF
|
debug <<EOF
|
||||||
Setting up NFS environment: all RPC services up, NFS managed by CTDB
|
Setting up NFS environment: all RPC services up, NFS managed by CTDB
|
||||||
EOF
|
EOF
|
||||||
@ -43,7 +43,7 @@ EOF
|
|||||||
"nlockmgr" "status"
|
"nlockmgr" "status"
|
||||||
|
|
||||||
nfs_setup_fake_threads "nfsd"
|
nfs_setup_fake_threads "nfsd"
|
||||||
nfs_setup_fake_threads "rpc.foobar" # Set the variable to empty
|
nfs_setup_fake_threads "rpc.foobar" # Set the variable to empty
|
||||||
else
|
else
|
||||||
debug <<EOF
|
debug <<EOF
|
||||||
Setting up NFS environment: all RPC services down, NFS not managed by CTDB
|
Setting up NFS environment: all RPC services down, NFS not managed by CTDB
|
||||||
@ -72,14 +72,14 @@ EOF
|
|||||||
rm "${CTDB_BASE}/statd-callout"
|
rm "${CTDB_BASE}/statd-callout"
|
||||||
}
|
}
|
||||||
|
|
||||||
rpc_services_down ()
|
rpc_services_down()
|
||||||
{
|
{
|
||||||
_out=""
|
_out=""
|
||||||
for _s in $FAKE_RPCINFO_SERVICES ; do
|
for _s in $FAKE_RPCINFO_SERVICES; do
|
||||||
for _i ; do
|
for _i; do
|
||||||
if [ "$_i" = "${_s%%:*}" ] ; then
|
if [ "$_i" = "${_s%%:*}" ]; then
|
||||||
debug "Marking RPC service \"${_i}\" as UNAVAILABLE"
|
debug "Marking RPC service \"${_i}\" as UNAVAILABLE"
|
||||||
continue 2
|
continue 2
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
_out="${_out}${_out:+ }${_s}"
|
_out="${_out}${_out:+ }${_s}"
|
||||||
@ -87,18 +87,18 @@ rpc_services_down ()
|
|||||||
FAKE_RPCINFO_SERVICES="$_out"
|
FAKE_RPCINFO_SERVICES="$_out"
|
||||||
}
|
}
|
||||||
|
|
||||||
rpc_services_up ()
|
rpc_services_up()
|
||||||
{
|
{
|
||||||
_out="$FAKE_RPCINFO_SERVICES"
|
_out="$FAKE_RPCINFO_SERVICES"
|
||||||
for _i ; do
|
for _i; do
|
||||||
debug "Marking RPC service \"${_i}\" as available"
|
debug "Marking RPC service \"${_i}\" as available"
|
||||||
case "$_i" in
|
case "$_i" in
|
||||||
portmapper) _t="2:4" ;;
|
portmapper) _t="2:4" ;;
|
||||||
nfs) _t="2:3" ;;
|
nfs) _t="2:3" ;;
|
||||||
mountd) _t="1:3" ;;
|
mountd) _t="1:3" ;;
|
||||||
rquotad) _t="1:2" ;;
|
rquotad) _t="1:2" ;;
|
||||||
nlockmgr) _t="3:4" ;;
|
nlockmgr) _t="3:4" ;;
|
||||||
status) _t="1:1" ;;
|
status) _t="1:1" ;;
|
||||||
*) die "Internal error - unsupported RPC service \"${_i}\"" ;;
|
*) die "Internal error - unsupported RPC service \"${_i}\"" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -107,9 +107,10 @@ rpc_services_up ()
|
|||||||
export FAKE_RPCINFO_SERVICES="$_out"
|
export FAKE_RPCINFO_SERVICES="$_out"
|
||||||
}
|
}
|
||||||
|
|
||||||
nfs_setup_fake_threads ()
|
nfs_setup_fake_threads()
|
||||||
{
|
{
|
||||||
_prog="$1" ; shift
|
_prog="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
case "$_prog" in
|
case "$_prog" in
|
||||||
nfsd)
|
nfsd)
|
||||||
@ -125,7 +126,7 @@ nfs_setup_fake_threads ()
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
guess_output ()
|
guess_output()
|
||||||
{
|
{
|
||||||
case "$1" in
|
case "$1" in
|
||||||
$CTDB_NFS_CALLOUT\ start\ nlockmgr)
|
$CTDB_NFS_CALLOUT\ start\ nlockmgr)
|
||||||
@ -226,6 +227,7 @@ EOF
|
|||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
: # Nothing
|
: # Nothing
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,14 +239,14 @@ EOF
|
|||||||
# if it is incomplete and hacky. So, if the 60.nfs eventscript
|
# if it is incomplete and hacky. So, if the 60.nfs eventscript
|
||||||
# changes and the tests start to fail then it may be due to this
|
# changes and the tests start to fail then it may be due to this
|
||||||
# function being incomplete.
|
# function being incomplete.
|
||||||
rpc_set_service_failure_response ()
|
rpc_set_service_failure_response()
|
||||||
{
|
{
|
||||||
_rpc_service="$1"
|
_rpc_service="$1"
|
||||||
_numfails="${2:-1}" # default 1
|
_numfails="${2:-1}" # default 1
|
||||||
|
|
||||||
# Default
|
# Default
|
||||||
ok_null
|
ok_null
|
||||||
if [ $_numfails -eq 0 ] ; then
|
if [ $_numfails -eq 0 ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -257,7 +259,7 @@ rpc_set_service_failure_response ()
|
|||||||
_dir="${CTDB_NFS_CHECKS_DIR:-${CTDB_BASE}/nfs-checks.d}"
|
_dir="${CTDB_NFS_CHECKS_DIR:-${CTDB_BASE}/nfs-checks.d}"
|
||||||
|
|
||||||
_file=$(ls "$_dir"/[0-9][0-9]."${_rpc_service}.check")
|
_file=$(ls "$_dir"/[0-9][0-9]."${_rpc_service}.check")
|
||||||
[ -r "$_file" ] || \
|
[ -r "$_file" ] ||
|
||||||
die "RPC check file \"$_file\" does not exist or is not unique"
|
die "RPC check file \"$_file\" does not exist or is not unique"
|
||||||
|
|
||||||
_out="${CTDB_TEST_TMP_DIR}/rpc_failure_output"
|
_out="${CTDB_TEST_TMP_DIR}/rpc_failure_output"
|
||||||
@ -283,12 +285,12 @@ rpc_set_service_failure_response ()
|
|||||||
# Just use the first version, or use default. This is
|
# Just use the first version, or use default. This is
|
||||||
# dumb but handles all the cases that we care about
|
# dumb but handles all the cases that we care about
|
||||||
# now...
|
# now...
|
||||||
if [ -n "$version" ] ; then
|
if [ -n "$version" ]; then
|
||||||
_ver="${version%% *}"
|
_ver="${version%% *}"
|
||||||
else
|
else
|
||||||
case "$_rpc_service" in
|
case "$_rpc_service" in
|
||||||
portmapper) _ver="" ;;
|
portmapper) _ver="" ;;
|
||||||
*) _ver=1 ;;
|
*) _ver=1 ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
_rpc_check_out="\
|
_rpc_check_out="\
|
||||||
@ -297,7 +299,7 @@ rpcinfo: RPC: Program not registered
|
|||||||
program $_rpc_service${_ver:+ version }${_ver} is not available"
|
program $_rpc_service${_ver:+ version }${_ver} is not available"
|
||||||
|
|
||||||
if [ $unhealthy_after -gt 0 -a \
|
if [ $unhealthy_after -gt 0 -a \
|
||||||
$_numfails -ge $unhealthy_after ] ; then
|
$_numfails -ge $unhealthy_after ]; then
|
||||||
_unhealthy=true
|
_unhealthy=true
|
||||||
echo 1 >"$_rc_file"
|
echo 1 >"$_rc_file"
|
||||||
echo "ERROR: ${_rpc_check_out}" >>"$_out"
|
echo "ERROR: ${_rpc_check_out}" >>"$_out"
|
||||||
@ -306,18 +308,18 @@ program $_rpc_service${_ver:+ version }${_ver} is not available"
|
|||||||
echo 0 >"$_rc_file"
|
echo 0 >"$_rc_file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $restart_every -gt 0 ] && \
|
if [ $restart_every -gt 0 ] &&
|
||||||
[ $(($_numfails % $restart_every)) -eq 0 ] ; then
|
[ $(($_numfails % $restart_every)) -eq 0 ]; then
|
||||||
if ! $_unhealthy ; then
|
if ! $_unhealthy; then
|
||||||
echo "WARNING: ${_rpc_check_out}" >>"$_out"
|
echo "WARNING: ${_rpc_check_out}" >>"$_out"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Trying to restart service \"${_rpc_service}\"..."\
|
echo "Trying to restart service \"${_rpc_service}\"..." \
|
||||||
>>"$_out"
|
>>"$_out"
|
||||||
|
|
||||||
guess_output "$service_stop_cmd" >>"$_out"
|
guess_output "$service_stop_cmd" >>"$_out"
|
||||||
|
|
||||||
if [ -n "$service_debug_cmd" ] ; then
|
if [ -n "$service_debug_cmd" ]; then
|
||||||
$service_debug_cmd 2>&1 >>"$_out"
|
$service_debug_cmd 2>&1 >>"$_out"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -331,18 +333,18 @@ program $_rpc_service${_ver:+ version }${_ver} is not available"
|
|||||||
rm -f "$_out" "$_rc_file"
|
rm -f "$_out" "$_rc_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
program_stack_traces ()
|
program_stack_traces()
|
||||||
{
|
{
|
||||||
_prog="$1"
|
_prog="$1"
|
||||||
_max="${2:-1}"
|
_max="${2:-1}"
|
||||||
|
|
||||||
_count=1
|
_count=1
|
||||||
if [ "$_prog" = "nfsd" ] ; then
|
if [ "$_prog" = "nfsd" ]; then
|
||||||
_pids="$FAKE_NFSD_THREAD_PIDS"
|
_pids="$FAKE_NFSD_THREAD_PIDS"
|
||||||
else
|
else
|
||||||
_pids="$FAKE_RPC_THREAD_PIDS"
|
_pids="$FAKE_RPC_THREAD_PIDS"
|
||||||
fi
|
fi
|
||||||
for _pid in $_pids ; do
|
for _pid in $_pids; do
|
||||||
[ $_count -le $_max ] || break
|
[ $_count -le $_max ] || break
|
||||||
|
|
||||||
program_stack_trace "$_prog" "$_pid"
|
program_stack_trace "$_prog" "$_pid"
|
||||||
@ -373,11 +375,11 @@ program_stack_traces ()
|
|||||||
# These arguments can allow a service to be started or stopped
|
# These arguments can allow a service to be started or stopped
|
||||||
# before a particular iteration.
|
# before a particular iteration.
|
||||||
#
|
#
|
||||||
nfs_iterate_test ()
|
nfs_iterate_test()
|
||||||
{
|
{
|
||||||
_repeats="$1"
|
_repeats="$1"
|
||||||
_rpc_service="$2"
|
_rpc_service="$2"
|
||||||
if [ -n "$2" ] ; then
|
if [ -n "$2" ]; then
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
shift
|
shift
|
||||||
@ -386,10 +388,10 @@ nfs_iterate_test ()
|
|||||||
echo "Running $_repeats iterations of \"$script $event\" $args"
|
echo "Running $_repeats iterations of \"$script $event\" $args"
|
||||||
|
|
||||||
_iterate_failcount=0
|
_iterate_failcount=0
|
||||||
for _iteration in $(seq 1 $_repeats) ; do
|
for _iteration in $(seq 1 $_repeats); do
|
||||||
# This is not a numerical comparison because $1 will
|
# This is not a numerical comparison because $1 will
|
||||||
# often not be set.
|
# often not be set.
|
||||||
if [ "$_iteration" = "$1" ] ; then
|
if [ "$_iteration" = "$1" ]; then
|
||||||
debug <<EOF
|
debug <<EOF
|
||||||
##################################################
|
##################################################
|
||||||
EOF
|
EOF
|
||||||
@ -399,20 +401,20 @@ EOF
|
|||||||
EOF
|
EOF
|
||||||
shift 2
|
shift 2
|
||||||
fi
|
fi
|
||||||
if [ -n "$_rpc_service" ] ; then
|
if [ -n "$_rpc_service" ]; then
|
||||||
_ok=false
|
_ok=false
|
||||||
if [ -n "$service_check_cmd" ] ; then
|
if [ -n "$service_check_cmd" ]; then
|
||||||
if eval "$service_check_cmd" ; then
|
if eval "$service_check_cmd"; then
|
||||||
_ok=true
|
_ok=true
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if rpcinfo -T tcp localhost "$_rpc_service" \
|
if rpcinfo -T tcp localhost "$_rpc_service" \
|
||||||
>/dev/null 2>&1 ; then
|
>/dev/null 2>&1; then
|
||||||
_ok=true
|
_ok=true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $_ok ; then
|
if $_ok; then
|
||||||
_iterate_failcount=0
|
_iterate_failcount=0
|
||||||
else
|
else
|
||||||
_iterate_failcount=$(($_iterate_failcount + 1))
|
_iterate_failcount=$(($_iterate_failcount + 1))
|
||||||
@ -422,14 +424,14 @@ EOF
|
|||||||
fi
|
fi
|
||||||
_out=$(simple_test 2>&1)
|
_out=$(simple_test 2>&1)
|
||||||
_ret=$?
|
_ret=$?
|
||||||
if "$CTDB_TEST_VERBOSE" || [ $_ret -ne 0 ] ; then
|
if "$CTDB_TEST_VERBOSE" || [ $_ret -ne 0 ]; then
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
##################################################
|
##################################################
|
||||||
Iteration ${_iteration}:
|
Iteration ${_iteration}:
|
||||||
$_out
|
$_out
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
if [ $_ret -ne 0 ] ; then
|
if [ $_ret -ne 0 ]; then
|
||||||
exit $_ret
|
exit $_ret
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
setup ()
|
setup()
|
||||||
{
|
{
|
||||||
_ip="$1"
|
_ip="$1"
|
||||||
_iface="$2"
|
_iface="$2"
|
||||||
@ -21,7 +21,7 @@ EOF
|
|||||||
|
|
||||||
# Read from stdin
|
# Read from stdin
|
||||||
_pnn=0
|
_pnn=0
|
||||||
while read _ip _opts ; do
|
while read _ip _opts; do
|
||||||
case "$_opts" in
|
case "$_opts" in
|
||||||
leader)
|
leader)
|
||||||
FAKE_CTDB_LVS_LEADER="$_pnn"
|
FAKE_CTDB_LVS_LEADER="$_pnn"
|
||||||
@ -38,9 +38,9 @@ EOF
|
|||||||
done >"$CTDB_LVS_NODES"
|
done >"$CTDB_LVS_NODES"
|
||||||
}
|
}
|
||||||
|
|
||||||
check_ipvsadm ()
|
check_ipvsadm()
|
||||||
{
|
{
|
||||||
if [ "$1" = "NULL" ] ; then
|
if [ "$1" = "NULL" ]; then
|
||||||
required_result 0 <<EOF
|
required_result 0 <<EOF
|
||||||
$lvs_header
|
$lvs_header
|
||||||
EOF
|
EOF
|
||||||
@ -54,11 +54,11 @@ EOF
|
|||||||
simple_test_command ipvsadm -l -n
|
simple_test_command ipvsadm -l -n
|
||||||
}
|
}
|
||||||
|
|
||||||
check_lvs_ip ()
|
check_lvs_ip()
|
||||||
{
|
{
|
||||||
_scope="$1"
|
_scope="$1"
|
||||||
|
|
||||||
if [ "$_scope" = "NULL" ] ; then
|
if [ "$_scope" = "NULL" ]; then
|
||||||
required_result 0 <<EOF
|
required_result 0 <<EOF
|
||||||
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
|
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
|
||||||
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
|
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
setup ()
|
setup()
|
||||||
{
|
{
|
||||||
setup_dbdir
|
setup_dbdir
|
||||||
}
|
}
|
||||||
@ -8,20 +8,20 @@ result_filter()
|
|||||||
sed -e 's|\( of debug locks PID=\)[0-9]*|\1PID|'
|
sed -e 's|\( of debug locks PID=\)[0-9]*|\1PID|'
|
||||||
}
|
}
|
||||||
|
|
||||||
tdb_path ()
|
tdb_path()
|
||||||
{
|
{
|
||||||
echo "${CTDB_DBDIR}/${1}.${FAKE_CTDB_PNN}"
|
echo "${CTDB_DBDIR}/${1}.${FAKE_CTDB_PNN}"
|
||||||
}
|
}
|
||||||
|
|
||||||
fake_file_id ()
|
fake_file_id()
|
||||||
{
|
{
|
||||||
_path="$1"
|
_path="$1"
|
||||||
|
|
||||||
echo "$FAKE_FILE_ID_MAP" |
|
echo "$FAKE_FILE_ID_MAP" |
|
||||||
awk -v path="$_path" '$1 == path { print $2 }'
|
awk -v path="$_path" '$1 == path { print $2 }'
|
||||||
}
|
}
|
||||||
|
|
||||||
fake_stack_trace ()
|
fake_stack_trace()
|
||||||
{
|
{
|
||||||
_pid="$1"
|
_pid="$1"
|
||||||
_command="${2:-smbd}"
|
_command="${2:-smbd}"
|
||||||
@ -47,7 +47,7 @@ EOF
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
do_test ()
|
do_test()
|
||||||
{
|
{
|
||||||
_holder_scope="$1"
|
_holder_scope="$1"
|
||||||
_holder_state="$2"
|
_holder_state="$2"
|
||||||
@ -56,26 +56,28 @@ do_test ()
|
|||||||
|
|
||||||
_lock_helper_pid="4132032"
|
_lock_helper_pid="4132032"
|
||||||
|
|
||||||
FAKE_PS_MAP=$(cat <<EOF
|
FAKE_PS_MAP=$(
|
||||||
|
cat <<EOF
|
||||||
1234567 ctdbd S
|
1234567 ctdbd S
|
||||||
2345678 smbd S
|
2345678 smbd S
|
||||||
4131931 smbd ${_holder_state}
|
4131931 smbd ${_holder_state}
|
||||||
${_lock_helper_pid} ctdb_lock_helpe S+
|
${_lock_helper_pid} ctdb_lock_helpe S+
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
export FAKE_PS_MAP
|
export FAKE_PS_MAP
|
||||||
|
|
||||||
FAKE_FILE_ID_MAP=""
|
FAKE_FILE_ID_MAP=""
|
||||||
_tdbs="locking.tdb brlock.tdb test.tdb foo.tdb"
|
_tdbs="locking.tdb brlock.tdb test.tdb foo.tdb"
|
||||||
_n=1
|
_n=1
|
||||||
for _t in $_tdbs ; do
|
for _t in $_tdbs; do
|
||||||
_path=$(tdb_path "$_t")
|
_path=$(tdb_path "$_t")
|
||||||
_inode=$((19690818 + _n))
|
_inode=$((19690818 + _n))
|
||||||
FAKE_FILE_ID_MAP=$(cat <<EOF
|
FAKE_FILE_ID_MAP=$(
|
||||||
|
cat <<EOF
|
||||||
${FAKE_FILE_ID_MAP}
|
${FAKE_FILE_ID_MAP}
|
||||||
${_path} 103:04:${_inode}
|
${_path} 103:04:${_inode}
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
rm -f "$_path"
|
rm -f "$_path"
|
||||||
touch "$_path"
|
touch "$_path"
|
||||||
_n=$((_n + 1))
|
_n=$((_n + 1))
|
||||||
@ -85,7 +87,8 @@ EOF
|
|||||||
_path=$(tdb_path "locking.tdb")
|
_path=$(tdb_path "locking.tdb")
|
||||||
_locking_tdb_id=$(fake_file_id "$_path")
|
_locking_tdb_id=$(fake_file_id "$_path")
|
||||||
|
|
||||||
_t=$(cat <<EOF
|
_t=$(
|
||||||
|
cat <<EOF
|
||||||
POSIX ADVISORY WRITE 3769740 103:04:24380821 1073741826 1073742335
|
POSIX ADVISORY WRITE 3769740 103:04:24380821 1073741826 1073742335
|
||||||
FLOCK ADVISORY WRITE 3632524 103:02:1059266 0 EOF
|
FLOCK ADVISORY WRITE 3632524 103:02:1059266 0 EOF
|
||||||
FLOCK ADVISORY WRITE 4060231 00:17:17184 0 EOF
|
FLOCK ADVISORY WRITE 4060231 00:17:17184 0 EOF
|
||||||
@ -95,73 +98,83 @@ POSIX ADVISORY READ 4427 103:04:22152234 1073741826 1073742335
|
|||||||
POSIX ADVISORY WRITE 4427 103:04:22152494 0 EOF
|
POSIX ADVISORY WRITE 4427 103:04:22152494 0 EOF
|
||||||
POSIX ADVISORY READ 4427 103:04:22152702 1073741826 1073742335
|
POSIX ADVISORY READ 4427 103:04:22152702 1073741826 1073742335
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
_holder_lock=""
|
_holder_lock=""
|
||||||
if [ "$_holder_scope" = "DB" ] ; then
|
if [ "$_holder_scope" = "DB" ]; then
|
||||||
if [ "$_lock_type" = "FCNTL" ] ; then
|
if [ "$_lock_type" = "FCNTL" ]; then
|
||||||
_holder_lock=$(cat <<EOF
|
_holder_lock=$(
|
||||||
|
cat <<EOF
|
||||||
POSIX ADVISORY WRITE 4131931 ${_locking_tdb_id} 168 EOF
|
POSIX ADVISORY WRITE 4131931 ${_locking_tdb_id} 168 EOF
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
elif [ "$_lock_type" = "MUTEX" ] ; then
|
elif [ "$_lock_type" = "MUTEX" ]; then
|
||||||
_holder_lock=$(cat <<EOF
|
_holder_lock=$(
|
||||||
|
cat <<EOF
|
||||||
POSIX ADVISORY WRITE 4131931 ${_locking_tdb_id} 400172 EOF
|
POSIX ADVISORY WRITE 4131931 ${_locking_tdb_id} 400172 EOF
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
elif [ "$_holder_scope" = "RECORD" ] && \
|
elif [ "$_holder_scope" = "RECORD" ] &&
|
||||||
[ "$_lock_type" = "FCNTL" ] ; then
|
[ "$_lock_type" = "FCNTL" ]; then
|
||||||
_holder_lock=$(cat <<EOF
|
_holder_lock=$(
|
||||||
|
cat <<EOF
|
||||||
POSIX ADVISORY WRITE 2345678 ${_locking_tdb_id} 112736 112736
|
POSIX ADVISORY WRITE 2345678 ${_locking_tdb_id} 112736 112736
|
||||||
POSIX ADVISORY WRITE 4131931 ${_locking_tdb_id} 225472 225472
|
POSIX ADVISORY WRITE 4131931 ${_locking_tdb_id} 225472 225472
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_t=$(cat <<EOF
|
_t=$(
|
||||||
|
cat <<EOF
|
||||||
$_t
|
$_t
|
||||||
$_holder_lock
|
$_holder_lock
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
_helper_lock=""
|
_helper_lock=""
|
||||||
if [ "$_helper_scope" = "DB" ] && \
|
if [ "$_helper_scope" = "DB" ] &&
|
||||||
[ "$_lock_type" = "FCNTL" ] ; then
|
[ "$_lock_type" = "FCNTL" ]; then
|
||||||
_helper_lock=$(cat <<EOF
|
_helper_lock=$(
|
||||||
|
cat <<EOF
|
||||||
-> POSIX ADVISORY WRITE ${_lock_helper_pid} ${_locking_tdb_id} 168 170
|
-> POSIX ADVISORY WRITE ${_lock_helper_pid} ${_locking_tdb_id} 168 170
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
elif [ "$_helper_scope" = "RECORD" ] && \
|
elif [ "$_helper_scope" = "RECORD" ] &&
|
||||||
[ "$_lock_type" = "FCNTL" ] ; then
|
[ "$_lock_type" = "FCNTL" ]; then
|
||||||
_helper_lock=$(cat <<EOF
|
_helper_lock=$(
|
||||||
|
cat <<EOF
|
||||||
-> POSIX ADVISORY WRITE ${_lock_helper_pid} ${_locking_tdb_id} 112736 112736
|
-> POSIX ADVISORY WRITE ${_lock_helper_pid} ${_locking_tdb_id} 112736 112736
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
_t=$(cat <<EOF
|
_t=$(
|
||||||
|
cat <<EOF
|
||||||
$_t
|
$_t
|
||||||
$_helper_lock
|
$_helper_lock
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
if [ "$_holder_scope" = "DB" ] ; then
|
if [ "$_holder_scope" = "DB" ]; then
|
||||||
_t=$(cat <<EOF
|
_t=$(
|
||||||
|
cat <<EOF
|
||||||
$_t
|
$_t
|
||||||
POSIX ADVISORY READ 4131931 ${_locking_tdb_id} 4 4
|
POSIX ADVISORY READ 4131931 ${_locking_tdb_id} 4 4
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
elif [ "$_holder_scope" = "RECORD" ] && \
|
elif [ "$_holder_scope" = "RECORD" ] &&
|
||||||
[ "$_lock_type" = "FCNTL" ] ; then
|
[ "$_lock_type" = "FCNTL" ]; then
|
||||||
_t=$(cat <<EOF
|
_t=$(
|
||||||
|
cat <<EOF
|
||||||
$_t
|
$_t
|
||||||
POSIX ADVISORY READ 2345678 ${_locking_tdb_id} 4 4
|
POSIX ADVISORY READ 2345678 ${_locking_tdb_id} 4 4
|
||||||
POSIX ADVISORY READ 4131931 ${_locking_tdb_id} 4 4
|
POSIX ADVISORY READ 4131931 ${_locking_tdb_id} 4 4
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_t=$(cat <<EOF
|
_t=$(
|
||||||
|
cat <<EOF
|
||||||
$_t
|
$_t
|
||||||
POSIX ADVISORY READ 3769740 103:04:24390149 1073741826 1073742335
|
POSIX ADVISORY READ 3769740 103:04:24390149 1073741826 1073742335
|
||||||
POSIX ADVISORY WRITE 3769740 103:04:24380839 1073741826 1073742335
|
POSIX ADVISORY WRITE 3769740 103:04:24380839 1073741826 1073742335
|
||||||
@ -170,19 +183,20 @@ FLOCK ADVISORY WRITE 3769302 103:02:1177487 0 EOF
|
|||||||
FLOCK ADVISORY WRITE 3769302 103:02:1180308 0 EOF
|
FLOCK ADVISORY WRITE 3769302 103:02:1180308 0 EOF
|
||||||
OFDLCK ADVISORY READ -1 00:05:6 0 EOF
|
OFDLCK ADVISORY READ -1 00:05:6 0 EOF
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
FAKE_PROC_LOCKS=$(echo "$_t" | awk '{ printf "%d: %s\n", NR, $0 }')
|
FAKE_PROC_LOCKS=$(echo "$_t" | awk '{ printf "%d: %s\n", NR, $0 }')
|
||||||
export FAKE_PROC_LOCKS
|
export FAKE_PROC_LOCKS
|
||||||
|
|
||||||
_holder_mutex_lock=""
|
_holder_mutex_lock=""
|
||||||
if [ "$_lock_type" = "MUTEX" ] ; then
|
if [ "$_lock_type" = "MUTEX" ]; then
|
||||||
if [ "$_holder_scope" = "RECORD" ] ; then
|
if [ "$_holder_scope" = "RECORD" ]; then
|
||||||
_holder_mutex_lock=$(cat <<EOF
|
_holder_mutex_lock=$(
|
||||||
|
cat <<EOF
|
||||||
2345678 28142
|
2345678 28142
|
||||||
4131931 56284
|
4131931 56284
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -194,7 +208,7 @@ EOF
|
|||||||
'
|
'
|
||||||
_db="locking.tdb.${FAKE_CTDB_PNN}"
|
_db="locking.tdb.${FAKE_CTDB_PNN}"
|
||||||
|
|
||||||
if [ -n "$_helper_lock" ] ; then
|
if [ -n "$_helper_lock" ]; then
|
||||||
read -r _ _ _ _ _pid _ _start _end <<EOF
|
read -r _ _ _ _ _pid _ _start _end <<EOF
|
||||||
$_helper_lock
|
$_helper_lock
|
||||||
EOF
|
EOF
|
||||||
@ -205,8 +219,8 @@ EOF
|
|||||||
# fake lock info
|
# fake lock info
|
||||||
_pids=''
|
_pids=''
|
||||||
_out="${_out:+${_out}${_nl}}Lock holders:"
|
_out="${_out:+${_out}${_nl}}Lock holders:"
|
||||||
if [ -n "$_holder_mutex_lock" ] ; then
|
if [ -n "$_holder_mutex_lock" ]; then
|
||||||
while read -r _pid _chain ; do
|
while read -r _pid _chain; do
|
||||||
_comm="smbd"
|
_comm="smbd"
|
||||||
_out="${_out}${_nl}"
|
_out="${_out}${_nl}"
|
||||||
_out="${_out}${_pid} smbd ${_db} ${_chain}"
|
_out="${_out}${_pid} smbd ${_db} ${_chain}"
|
||||||
@ -215,7 +229,7 @@ EOF
|
|||||||
$_holder_mutex_lock
|
$_holder_mutex_lock
|
||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
while read -r _ _ _ _pid _ _start _end ; do
|
while read -r _ _ _ _pid _ _start _end; do
|
||||||
_comm="smbd"
|
_comm="smbd"
|
||||||
_out="${_out}${_nl}"
|
_out="${_out}${_nl}"
|
||||||
_out="${_out}${_pid} smbd ${_db} ${_start} ${_end}"
|
_out="${_out}${_pid} smbd ${_db} ${_start} ${_end}"
|
||||||
@ -226,18 +240,19 @@ EOF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# fake stack traces
|
# fake stack traces
|
||||||
for _pid in $_pids ; do
|
for _pid in $_pids; do
|
||||||
_comm="smbd"
|
_comm="smbd"
|
||||||
if [ "$_pid" = "4131931" ] ; then
|
if [ "$_pid" = "4131931" ]; then
|
||||||
_state="$_holder_state"
|
_state="$_holder_state"
|
||||||
else
|
else
|
||||||
_state="S"
|
_state="S"
|
||||||
fi
|
fi
|
||||||
_out=$(cat <<EOF
|
_out=$(
|
||||||
|
cat <<EOF
|
||||||
$_out
|
$_out
|
||||||
$(fake_stack_trace "$_pid" "$_comm" "$_state")
|
$(fake_stack_trace "$_pid" "$_comm" "$_state")
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
done
|
done
|
||||||
|
|
||||||
ok <<EOF
|
ok <<EOF
|
||||||
@ -247,9 +262,9 @@ $_out
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
script_test "${script_dir}/${script}" \
|
script_test "${script_dir}/${script}" \
|
||||||
"$_lock_helper_pid" \
|
"$_lock_helper_pid" \
|
||||||
"$_helper_scope" \
|
"$_helper_scope" \
|
||||||
"$_path" \
|
"$_path" \
|
||||||
"$_lock_type"
|
"$_lock_type"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,29 +18,28 @@ export CTDB_HELPER_BINDIR="$stubs_dir"
|
|||||||
|
|
||||||
PATH="${stubs_dir}:${PATH}"
|
PATH="${stubs_dir}:${PATH}"
|
||||||
|
|
||||||
|
|
||||||
export CTDB="ctdb"
|
export CTDB="ctdb"
|
||||||
|
|
||||||
# Force this to be absolute - event scripts can change directory
|
# Force this to be absolute - event scripts can change directory
|
||||||
CTDB_TEST_TMP_DIR=$(cd "$CTDB_TEST_TMP_DIR" && echo "$PWD")
|
CTDB_TEST_TMP_DIR=$(cd "$CTDB_TEST_TMP_DIR" && echo "$PWD")
|
||||||
|
|
||||||
export CTDB_LOGGING="file:${CTDB_TEST_TMP_DIR}/log.ctdb"
|
export CTDB_LOGGING="file:${CTDB_TEST_TMP_DIR}/log.ctdb"
|
||||||
touch "${CTDB_LOGGING#file:}" || \
|
touch "${CTDB_LOGGING#file:}" ||
|
||||||
die "Unable to setup logging for \"$CTDB_LOGGING\""
|
die "Unable to setup logging for \"$CTDB_LOGGING\""
|
||||||
|
|
||||||
if [ -d "${CTDB_TEST_SUITE_DIR}/etc" ] ; then
|
if [ -d "${CTDB_TEST_SUITE_DIR}/etc" ]; then
|
||||||
cp -a "${CTDB_TEST_SUITE_DIR}/etc" "$CTDB_TEST_TMP_DIR"
|
cp -a "${CTDB_TEST_SUITE_DIR}/etc" "$CTDB_TEST_TMP_DIR"
|
||||||
export CTDB_SYS_ETCDIR="${CTDB_TEST_TMP_DIR}/etc"
|
export CTDB_SYS_ETCDIR="${CTDB_TEST_TMP_DIR}/etc"
|
||||||
else
|
else
|
||||||
die "Unable to setup \$CTDB_SYS_ETCDIR"
|
die "Unable to setup \$CTDB_SYS_ETCDIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
setup_ctdb_base "$CTDB_TEST_TMP_DIR" "etc-ctdb" \
|
setup_ctdb_base "$CTDB_TEST_TMP_DIR" "etc-ctdb" \
|
||||||
debug_locks.sh \
|
debug_locks.sh \
|
||||||
functions \
|
functions \
|
||||||
nfs-checks.d \
|
nfs-checks.d \
|
||||||
nfs-linux-kernel-callout \
|
nfs-linux-kernel-callout \
|
||||||
statd-callout
|
statd-callout
|
||||||
|
|
||||||
export FAKE_CTDB_STATE="${CTDB_TEST_TMP_DIR}/fake-ctdb"
|
export FAKE_CTDB_STATE="${CTDB_TEST_TMP_DIR}/fake-ctdb"
|
||||||
mkdir -p "$FAKE_CTDB_STATE"
|
mkdir -p "$FAKE_CTDB_STATE"
|
||||||
@ -50,17 +49,20 @@ mkdir -p "$FAKE_NETWORK_STATE"
|
|||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
if "$CTDB_TEST_VERBOSE" ; then
|
if "$CTDB_TEST_VERBOSE"; then
|
||||||
debug ()
|
debug()
|
||||||
{
|
{
|
||||||
if [ -n "$1" ] ; then
|
if [ -n "$1" ]; then
|
||||||
echo "$@" >&2
|
echo "$@" >&2
|
||||||
else
|
else
|
||||||
cat >&2
|
cat >&2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
debug () { : ; }
|
debug()
|
||||||
|
{
|
||||||
|
:
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
@ -70,17 +72,17 @@ fi
|
|||||||
# Default is to use script name with ".options" appended. With
|
# Default is to use script name with ".options" appended. With
|
||||||
# arguments, this can specify an alternate script name (and
|
# arguments, this can specify an alternate script name (and
|
||||||
# component).
|
# component).
|
||||||
setup_script_options ()
|
setup_script_options()
|
||||||
{
|
{
|
||||||
if [ $# -eq 2 ] ; then
|
if [ $# -eq 2 ]; then
|
||||||
_script="$2"
|
_script="$2"
|
||||||
elif [ $# -eq 0 ] ; then
|
elif [ $# -eq 0 ]; then
|
||||||
_script=""
|
_script=""
|
||||||
else
|
else
|
||||||
die "usage: setup_script_options [ component script ]"
|
die "usage: setup_script_options [ component script ]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$_script" ] ; then
|
if [ -n "$_script" ]; then
|
||||||
_options="${CTDB_BASE}/events/legacy/${_script}.options"
|
_options="${CTDB_BASE}/events/legacy/${_script}.options"
|
||||||
else
|
else
|
||||||
_options="${script_dir}/${script%.script}.options"
|
_options="${script_dir}/${script%.script}.options"
|
||||||
@ -92,7 +94,7 @@ setup_script_options ()
|
|||||||
. "$_options"
|
. "$_options"
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_dbdir ()
|
setup_dbdir()
|
||||||
{
|
{
|
||||||
export CTDB_DBDIR_BASE="${CTDB_TEST_TMP_DIR}/db"
|
export CTDB_DBDIR_BASE="${CTDB_TEST_TMP_DIR}/db"
|
||||||
CTDB_DBDIR="${CTDB_DBDIR_BASE}/volatile"
|
CTDB_DBDIR="${CTDB_DBDIR_BASE}/volatile"
|
||||||
@ -109,31 +111,31 @@ EOF
|
|||||||
mkdir -p "$CTDB_DBDIR_STATE"
|
mkdir -p "$CTDB_DBDIR_STATE"
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_date ()
|
setup_date()
|
||||||
{
|
{
|
||||||
export FAKE_DATE_OUTPUT="$1"
|
export FAKE_DATE_OUTPUT="$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_tcp_listen ()
|
setup_tcp_listen()
|
||||||
{
|
{
|
||||||
export FAKE_TCP_LISTEN="$*"
|
export FAKE_TCP_LISTEN="$*"
|
||||||
}
|
}
|
||||||
|
|
||||||
tcp_port_listening ()
|
tcp_port_listening()
|
||||||
{
|
{
|
||||||
for _i ; do
|
for _i; do
|
||||||
FAKE_TCP_LISTEN="${FAKE_TCP_LISTEN} ${_i}"
|
FAKE_TCP_LISTEN="${FAKE_TCP_LISTEN} ${_i}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
tcp_port_down ()
|
tcp_port_down()
|
||||||
{
|
{
|
||||||
_port="$1"
|
_port="$1"
|
||||||
debug "Marking TCP port \"${_port}\" as not listening"
|
debug "Marking TCP port \"${_port}\" as not listening"
|
||||||
|
|
||||||
_t=""
|
_t=""
|
||||||
for _i in $FAKE_TCP_LISTEN ; do
|
for _i in $FAKE_TCP_LISTEN; do
|
||||||
if [ "$_i" = "$_port" ] ; then
|
if [ "$_i" = "$_port" ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
_t="${_t} ${_i}"
|
_t="${_t} ${_i}"
|
||||||
@ -142,43 +144,44 @@ tcp_port_down ()
|
|||||||
FAKE_TCP_LISTEN="$_t"
|
FAKE_TCP_LISTEN="$_t"
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_unix_listen ()
|
setup_unix_listen()
|
||||||
{
|
{
|
||||||
export FAKE_NETSTAT_UNIX_LISTEN="$*"
|
export FAKE_NETSTAT_UNIX_LISTEN="$*"
|
||||||
}
|
}
|
||||||
|
|
||||||
unix_socket_listening ()
|
unix_socket_listening()
|
||||||
{
|
{
|
||||||
_s="$1"
|
_s="$1"
|
||||||
|
|
||||||
FAKE_NETSTAT_UNIX_LISTEN="${FAKE_NETSTAT_UNIX_LISTEN} ${_s}"
|
FAKE_NETSTAT_UNIX_LISTEN="${FAKE_NETSTAT_UNIX_LISTEN} ${_s}"
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_shares ()
|
setup_shares()
|
||||||
{
|
{
|
||||||
debug "Setting up shares (3 existing shares)"
|
debug "Setting up shares (3 existing shares)"
|
||||||
# Create 3 fake shares/exports.
|
# Create 3 fake shares/exports.
|
||||||
export FAKE_SHARES=""
|
export FAKE_SHARES=""
|
||||||
for i in $(seq 1 3) ; do
|
for i in $(seq 1 3); do
|
||||||
_s="${CTDB_TEST_TMP_DIR}/shares/share${i}"
|
_s="${CTDB_TEST_TMP_DIR}/shares/share${i}"
|
||||||
mkdir -p "$_s"
|
mkdir -p "$_s"
|
||||||
FAKE_SHARES="${FAKE_SHARES}${FAKE_SHARES:+ }${_s}"
|
FAKE_SHARES="${FAKE_SHARES}${FAKE_SHARES:+ }${_s}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
shares_missing ()
|
shares_missing()
|
||||||
{
|
{
|
||||||
# Mark some shares as non-existent
|
# Mark some shares as non-existent
|
||||||
_fmt="$1" ; shift
|
_fmt="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
_out=""
|
_out=""
|
||||||
_nl="
|
_nl="
|
||||||
"
|
"
|
||||||
|
|
||||||
_n=1
|
_n=1
|
||||||
for _i in $FAKE_SHARES ; do
|
for _i in $FAKE_SHARES; do
|
||||||
for _j ; do
|
for _j; do
|
||||||
if [ $_n -ne "$_j" ] ; then
|
if [ $_n -ne "$_j" ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -193,82 +196,85 @@ shares_missing ()
|
|||||||
echo "$_out"
|
echo "$_out"
|
||||||
}
|
}
|
||||||
|
|
||||||
_ethtool_setup ()
|
_ethtool_setup()
|
||||||
{
|
{
|
||||||
FAKE_ETHTOOL_LINK_DOWN="${FAKE_NETWORK_STATE}/ethtool-link-down"
|
FAKE_ETHTOOL_LINK_DOWN="${FAKE_NETWORK_STATE}/ethtool-link-down"
|
||||||
export FAKE_ETHTOOL_LINK_DOWN
|
export FAKE_ETHTOOL_LINK_DOWN
|
||||||
mkdir -p "$FAKE_ETHTOOL_LINK_DOWN"
|
mkdir -p "$FAKE_ETHTOOL_LINK_DOWN"
|
||||||
}
|
}
|
||||||
|
|
||||||
ethtool_interfaces_down ()
|
ethtool_interfaces_down()
|
||||||
{
|
{
|
||||||
_ethtool_setup
|
_ethtool_setup
|
||||||
|
|
||||||
for _i ; do
|
for _i; do
|
||||||
echo "Marking interface $_i DOWN for ethtool"
|
echo "Marking interface $_i DOWN for ethtool"
|
||||||
touch "${FAKE_ETHTOOL_LINK_DOWN}/${_i}"
|
touch "${FAKE_ETHTOOL_LINK_DOWN}/${_i}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
ethtool_interfaces_up ()
|
ethtool_interfaces_up()
|
||||||
{
|
{
|
||||||
_ethtool_setup
|
_ethtool_setup
|
||||||
|
|
||||||
for _i ; do
|
for _i; do
|
||||||
echo "Marking interface $_i UP for ethtool"
|
echo "Marking interface $_i UP for ethtool"
|
||||||
rm -f "${FAKE_ETHTOOL_LINK_DOWN}/${_i}"
|
rm -f "${FAKE_ETHTOOL_LINK_DOWN}/${_i}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
dump_routes ()
|
dump_routes()
|
||||||
{
|
{
|
||||||
echo "# ip rule show"
|
echo "# ip rule show"
|
||||||
ip rule show
|
ip rule show
|
||||||
|
|
||||||
ip rule show |
|
ip rule show |
|
||||||
while read _p _x _i _x _t ; do
|
while read _p _x _i _x _t; do
|
||||||
# Remove trailing colon after priority/preference.
|
# Remove trailing colon after priority/preference.
|
||||||
_p="${_p%:}"
|
_p="${_p%:}"
|
||||||
# Only remove rules that match our priority/preference.
|
# Only remove rules that match our priority/preference.
|
||||||
[ "$CTDB_PER_IP_ROUTING_RULE_PREF" = "$_p" ] || continue
|
[ "$CTDB_PER_IP_ROUTING_RULE_PREF" = "$_p" ] || continue
|
||||||
|
|
||||||
echo "# ip route show table $_t"
|
echo "# ip route show table $_t"
|
||||||
ip route show table "$_t"
|
ip route show table "$_t"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Copied from 13.per_ip_routing for now... so this is lazy testing :-(
|
# Copied from 13.per_ip_routing for now... so this is lazy testing :-(
|
||||||
ipv4_host_addr_to_net ()
|
ipv4_host_addr_to_net()
|
||||||
{
|
{
|
||||||
_host="$1"
|
_host="$1"
|
||||||
_maskbits="$2"
|
_maskbits="$2"
|
||||||
|
|
||||||
# Convert the host address to an unsigned long by splitting out
|
# Convert the host address to an unsigned long by splitting out
|
||||||
# the octets and doing the math.
|
# the octets and doing the math.
|
||||||
_host_ul=0
|
_host_ul=0
|
||||||
for _o in $(export IFS="." ; echo $_host) ; do
|
for _o in $(
|
||||||
_host_ul=$(( ($_host_ul << 8) + $_o)) # work around Emacs color bug
|
export IFS="."
|
||||||
done
|
echo $_host
|
||||||
|
); do
|
||||||
|
_host_ul=$((($_host_ul << 8) + $_o)) # work around Emacs color bug
|
||||||
|
done
|
||||||
|
|
||||||
# Calculate the mask and apply it.
|
# Calculate the mask and apply it.
|
||||||
_mask_ul=$(( 0xffffffff << (32 - $_maskbits) ))
|
_mask_ul=$((0xffffffff << (32 - $_maskbits)))
|
||||||
_net_ul=$(( $_host_ul & $_mask_ul ))
|
_net_ul=$(($_host_ul & $_mask_ul))
|
||||||
|
|
||||||
# Now convert to a network address one byte at a time.
|
# Now convert to a network address one byte at a time.
|
||||||
_net=""
|
_net=""
|
||||||
for _o in $(seq 1 4) ; do
|
for _o in $(seq 1 4); do
|
||||||
_net="$(($_net_ul & 255))${_net:+.}${_net}"
|
_net="$(($_net_ul & 255))${_net:+.}${_net}"
|
||||||
_net_ul=$(($_net_ul >> 8))
|
_net_ul=$(($_net_ul >> 8))
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "${_net}/${_maskbits}"
|
echo "${_net}/${_maskbits}"
|
||||||
}
|
}
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
# CTDB fakery
|
# CTDB fakery
|
||||||
|
|
||||||
setup_numnodes ()
|
setup_numnodes()
|
||||||
{
|
{
|
||||||
export FAKE_CTDB_NUMNODES="${1:-3}"
|
export FAKE_CTDB_NUMNODES="${1:-3}"
|
||||||
echo "Setting up CTDB with ${FAKE_CTDB_NUMNODES} fake nodes"
|
echo "Setting up CTDB with ${FAKE_CTDB_NUMNODES} fake nodes"
|
||||||
@ -276,7 +282,7 @@ setup_numnodes ()
|
|||||||
|
|
||||||
# For now this creates the same public addresses each time. However,
|
# For now this creates the same public addresses each time. However,
|
||||||
# it could be made more flexible.
|
# it could be made more flexible.
|
||||||
setup_public_addresses ()
|
setup_public_addresses()
|
||||||
{
|
{
|
||||||
_f="${CTDB_BASE}/public_addresses"
|
_f="${CTDB_BASE}/public_addresses"
|
||||||
|
|
||||||
@ -294,117 +300,122 @@ setup_public_addresses ()
|
|||||||
10.0.1.3/24 dev456
|
10.0.1.3/24 dev456
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Needed for IP allocation
|
# Needed for IP allocation
|
||||||
setup_numnodes
|
setup_numnodes
|
||||||
}
|
}
|
||||||
|
|
||||||
# Need to cope with ctdb_get_pnn(). If a test changes PNN then it
|
# Need to cope with ctdb_get_pnn(). If a test changes PNN then it
|
||||||
# needs to be using a different state directory, otherwise the wrong
|
# needs to be using a different state directory, otherwise the wrong
|
||||||
# PNN can already be cached in the state directory.
|
# PNN can already be cached in the state directory.
|
||||||
ctdb_set_pnn ()
|
ctdb_set_pnn()
|
||||||
{
|
{
|
||||||
export FAKE_CTDB_PNN="$1"
|
export FAKE_CTDB_PNN="$1"
|
||||||
echo "Setting up PNN ${FAKE_CTDB_PNN}"
|
echo "Setting up PNN ${FAKE_CTDB_PNN}"
|
||||||
|
|
||||||
CTDB_SCRIPT_VARDIR="${CTDB_TEST_TMP_DIR}/scripts/${FAKE_CTDB_PNN}"
|
CTDB_SCRIPT_VARDIR="${CTDB_TEST_TMP_DIR}/scripts/${FAKE_CTDB_PNN}"
|
||||||
export CTDB_SCRIPT_VARDIR
|
export CTDB_SCRIPT_VARDIR
|
||||||
mkdir -p "$CTDB_SCRIPT_VARDIR"
|
mkdir -p "$CTDB_SCRIPT_VARDIR"
|
||||||
}
|
}
|
||||||
|
|
||||||
ctdb_get_interfaces ()
|
ctdb_get_interfaces()
|
||||||
{
|
{
|
||||||
# The echo/subshell forces all the output onto 1 line.
|
# The echo/subshell forces all the output onto 1 line.
|
||||||
echo $(ctdb ifaces -X | awk -F'|' 'FNR > 1 {print $2}')
|
echo $(ctdb ifaces -X | awk -F'|' 'FNR > 1 {print $2}')
|
||||||
}
|
}
|
||||||
|
|
||||||
ctdb_get_1_interface ()
|
ctdb_get_1_interface()
|
||||||
{
|
{
|
||||||
_t=$(ctdb_get_interfaces)
|
_t=$(ctdb_get_interfaces)
|
||||||
echo ${_t%% *}
|
echo ${_t%% *}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Print public addresses on this node as: interface IP maskbits
|
# Print public addresses on this node as: interface IP maskbits
|
||||||
# Each line is suitable for passing to takeip/releaseip
|
# Each line is suitable for passing to takeip/releaseip
|
||||||
ctdb_get_my_public_addresses ()
|
ctdb_get_my_public_addresses()
|
||||||
{
|
{
|
||||||
ctdb ip -v -X | {
|
ctdb ip -v -X | {
|
||||||
read _x # skip header line
|
read _x # skip header line
|
||||||
|
|
||||||
while IFS="|" read _x _ip _x _iface _x ; do
|
while IFS="|" read _x _ip _x _iface _x; do
|
||||||
[ -n "$_iface" ] || continue
|
[ -n "$_iface" ] || continue
|
||||||
while IFS="/$IFS" read _i _maskbits _x ; do
|
while IFS="/$IFS" read _i _maskbits _x; do
|
||||||
if [ "$_ip" = "$_i" ] ; then
|
if [ "$_ip" = "$_i" ]; then
|
||||||
echo $_iface $_ip $_maskbits
|
echo $_iface $_ip $_maskbits
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done <"${CTDB_BASE}/public_addresses"
|
done <"${CTDB_BASE}/public_addresses"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Prints the 1st public address as: interface IP maskbits
|
# Prints the 1st public address as: interface IP maskbits
|
||||||
# This is suitable for passing to takeip/releaseip
|
# This is suitable for passing to takeip/releaseip
|
||||||
ctdb_get_1_public_address ()
|
ctdb_get_1_public_address()
|
||||||
{
|
{
|
||||||
ctdb_get_my_public_addresses | { head -n 1 ; cat >/dev/null ; }
|
ctdb_get_my_public_addresses | {
|
||||||
|
head -n 1
|
||||||
|
cat >/dev/null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check the routes against those that are expected. $1 is the number
|
# Check the routes against those that are expected. $1 is the number
|
||||||
# of assigned IPs to use (<num>, all), defaulting to 1. If $2 is
|
# of assigned IPs to use (<num>, all), defaulting to 1. If $2 is
|
||||||
# "default" then expect default routes to have been added.
|
# "default" then expect default routes to have been added.
|
||||||
check_routes ()
|
check_routes()
|
||||||
{
|
{
|
||||||
_num_ips="${1:-1}"
|
_num_ips="${1:-1}"
|
||||||
_should_add_default="$2"
|
_should_add_default="$2"
|
||||||
|
|
||||||
_policy_rules=""
|
_policy_rules=""
|
||||||
_policy_routes=""
|
_policy_routes=""
|
||||||
|
|
||||||
ctdb_get_my_public_addresses |
|
ctdb_get_my_public_addresses |
|
||||||
if [ "$_num_ips" = "all" ] ; then
|
if [ "$_num_ips" = "all" ]; then
|
||||||
cat
|
cat
|
||||||
else
|
else
|
||||||
{ head -n "$_num_ips" ; cat >/dev/null ; }
|
{
|
||||||
fi | {
|
head -n "$_num_ips"
|
||||||
while read _dev _ip _bits ; do
|
cat >/dev/null
|
||||||
_net=$(ipv4_host_addr_to_net "$_ip" "$_bits")
|
}
|
||||||
_gw="${_net%.*}.254" # a dumb, calculated default
|
fi | {
|
||||||
|
while read _dev _ip _bits; do
|
||||||
|
_net=$(ipv4_host_addr_to_net "$_ip" "$_bits")
|
||||||
|
_gw="${_net%.*}.254" # a dumb, calculated default
|
||||||
|
|
||||||
_policy_rules="${_policy_rules}
|
_policy_rules="${_policy_rules}
|
||||||
${CTDB_PER_IP_ROUTING_RULE_PREF}: from $_ip lookup ctdb.$_ip "
|
${CTDB_PER_IP_ROUTING_RULE_PREF}: from $_ip lookup ctdb.$_ip "
|
||||||
_policy_routes="${_policy_routes}
|
_policy_routes="${_policy_routes}
|
||||||
# ip route show table ctdb.$_ip
|
# ip route show table ctdb.$_ip
|
||||||
$_net dev $_dev scope link "
|
$_net dev $_dev scope link "
|
||||||
|
|
||||||
if [ "$_should_add_default" = "default" ] ; then
|
if [ "$_should_add_default" = "default" ]; then
|
||||||
_policy_routes="${_policy_routes}
|
_policy_routes="${_policy_routes}
|
||||||
default via $_gw dev $_dev "
|
default via $_gw dev $_dev "
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
ok <<EOF
|
ok <<EOF
|
||||||
# ip rule show
|
# ip rule show
|
||||||
0: from all lookup local ${_policy_rules}
|
0: from all lookup local ${_policy_rules}
|
||||||
32766: from all lookup main
|
32766: from all lookup main
|
||||||
32767: from all lookup default ${_policy_routes}
|
32767: from all lookup default ${_policy_routes}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
simple_test_command dump_routes
|
simple_test_command dump_routes
|
||||||
} || test_fail
|
} || test_fail
|
||||||
}
|
}
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
nfs_load_config()
|
||||||
nfs_load_config ()
|
|
||||||
{
|
{
|
||||||
_etc="$CTDB_SYS_ETCDIR" # shortcut for readability
|
_etc="$CTDB_SYS_ETCDIR" # shortcut for readability
|
||||||
for _c in "$_etc/sysconfig/nfs" "$_etc/default/nfs" "$_etc/ctdb/sysconfig/nfs" ; do
|
for _c in "$_etc/sysconfig/nfs" "$_etc/default/nfs" "$_etc/ctdb/sysconfig/nfs"; do
|
||||||
if [ -r "$_c" ] ; then
|
if [ -r "$_c" ]; then
|
||||||
. "$_c"
|
. "$_c"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_nfs_callout()
|
setup_nfs_callout()
|
||||||
@ -413,7 +424,7 @@ setup_nfs_callout()
|
|||||||
export NFS_FAKE_CALLOUT_MAGIC="$1"
|
export NFS_FAKE_CALLOUT_MAGIC="$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
program_stack_trace ()
|
program_stack_trace()
|
||||||
{
|
{
|
||||||
_prog="$1"
|
_prog="$1"
|
||||||
_pid="$2"
|
_pid="$2"
|
||||||
@ -428,16 +439,15 @@ EOF
|
|||||||
|
|
||||||
# Result and test functions
|
# Result and test functions
|
||||||
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
setup ()
|
setup()
|
||||||
{
|
{
|
||||||
die "setup() is not defined"
|
die "setup() is not defined"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set some globals and print the summary.
|
# Set some globals and print the summary.
|
||||||
define_test ()
|
define_test()
|
||||||
{
|
{
|
||||||
desc="$1"
|
desc="$1"
|
||||||
|
|
||||||
@ -466,7 +476,7 @@ define_test ()
|
|||||||
# Symlink target needs to be absolute
|
# Symlink target needs to be absolute
|
||||||
case "$CTDB_SCRIPTS_DATA_DIR" in
|
case "$CTDB_SCRIPTS_DATA_DIR" in
|
||||||
/*) _data_dir="${CTDB_SCRIPTS_DATA_DIR}/${_subdir}" ;;
|
/*) _data_dir="${CTDB_SCRIPTS_DATA_DIR}/${_subdir}" ;;
|
||||||
*) _data_dir="${PWD}/${CTDB_SCRIPTS_DATA_DIR}/${_subdir}"
|
*) _data_dir="${PWD}/${CTDB_SCRIPTS_DATA_DIR}/${_subdir}" ;;
|
||||||
esac
|
esac
|
||||||
mkdir -p "$script_dir"
|
mkdir -p "$script_dir"
|
||||||
ln -s "${_data_dir}/${script}" "$script_dir"
|
ln -s "${_data_dir}/${script}" "$script_dir"
|
||||||
@ -476,10 +486,11 @@ define_test ()
|
|||||||
script="$_f"
|
script="$_f"
|
||||||
unset event
|
unset event
|
||||||
script_dir="${CTDB_BASE}"
|
script_dir="${CTDB_BASE}"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
_s="${script_dir}/${script}"
|
_s="${script_dir}/${script}"
|
||||||
[ -r "$_s" ] || \
|
[ -r "$_s" ] ||
|
||||||
die "Internal error - unable to find script \"${_s}\""
|
die "Internal error - unable to find script \"${_s}\""
|
||||||
|
|
||||||
case "$script" in
|
case "$script" in
|
||||||
@ -489,10 +500,10 @@ define_test ()
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
printf "%-17s %-10s %-4s - %s\n\n" \
|
printf "%-17s %-10s %-4s - %s\n\n" \
|
||||||
"$script_short" "$event" "$_num" "$desc"
|
"$script_short" "$event" "$_num" "$desc"
|
||||||
|
|
||||||
_f="${CTDB_TEST_SUITE_DIR}/scripts/${script_short}.sh"
|
_f="${CTDB_TEST_SUITE_DIR}/scripts/${script_short}.sh"
|
||||||
if [ -r "$_f" ] ; then
|
if [ -r "$_f" ]; then
|
||||||
. "$_f"
|
. "$_f"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -504,20 +515,20 @@ define_test ()
|
|||||||
|
|
||||||
# Any args are passed to the eventscript.
|
# Any args are passed to the eventscript.
|
||||||
|
|
||||||
simple_test ()
|
simple_test()
|
||||||
{
|
{
|
||||||
[ -n "$event" ] || die 'simple_test: $event not set'
|
[ -n "$event" ] || die 'simple_test: $event not set'
|
||||||
|
|
||||||
args="$@"
|
args="$@"
|
||||||
|
|
||||||
test_header ()
|
test_header()
|
||||||
{
|
{
|
||||||
echo "Running script \"$script $event${args:+ }$args\""
|
echo "Running script \"$script $event${args:+ }$args\""
|
||||||
}
|
}
|
||||||
|
|
||||||
extra_header ()
|
extra_header()
|
||||||
{
|
{
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
|
|
||||||
##################################################
|
##################################################
|
||||||
CTDB_BASE="$CTDB_BASE"
|
CTDB_BASE="$CTDB_BASE"
|
||||||
@ -525,26 +536,27 @@ CTDB_SYS_ETCDIR="$CTDB_SYS_ETCDIR"
|
|||||||
ctdb client is "$(which ctdb)"
|
ctdb client is "$(which ctdb)"
|
||||||
ip command is "$(which ip)"
|
ip command is "$(which ip)"
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
script_test "${script_dir}/${script}" "$event" "$@"
|
script_test "${script_dir}/${script}" "$event" "$@"
|
||||||
|
|
||||||
reset_test_header
|
reset_test_header
|
||||||
reset_extra_header
|
reset_extra_header
|
||||||
}
|
}
|
||||||
|
|
||||||
simple_test_event ()
|
simple_test_event()
|
||||||
{
|
{
|
||||||
# If something has previously failed then don't continue.
|
# If something has previously failed then don't continue.
|
||||||
: ${_passed:=true}
|
: ${_passed:=true}
|
||||||
$_passed || return 1
|
$_passed || return 1
|
||||||
|
|
||||||
event="$1" ; shift
|
event="$1"
|
||||||
echo "=================================================="
|
shift
|
||||||
simple_test "$@"
|
echo "=================================================="
|
||||||
|
simple_test "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
simple_test_command ()
|
simple_test_command()
|
||||||
{
|
{
|
||||||
unit_test_notrace "$@"
|
unit_test_notrace "$@"
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
setup ()
|
setup()
|
||||||
{
|
{
|
||||||
ctdb_set_pnn
|
ctdb_set_pnn
|
||||||
setup_public_addresses
|
setup_public_addresses
|
||||||
setup_date "123456789"
|
setup_date "123456789"
|
||||||
}
|
}
|
||||||
|
|
||||||
ctdb_catdb_format_pairs ()
|
ctdb_catdb_format_pairs()
|
||||||
{
|
{
|
||||||
_count=0
|
_count=0
|
||||||
|
|
||||||
while read _k _v ; do
|
while read _k _v; do
|
||||||
_kn=$(echo -n "$_k" | wc -c)
|
_kn=$(echo -n "$_k" | wc -c)
|
||||||
_vn=$(echo -n "$_v" | wc -c)
|
_vn=$(echo -n "$_v" | wc -c)
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
@ -25,11 +25,11 @@ EOF
|
|||||||
echo "Dumped ${_count} records"
|
echo "Dumped ${_count} records"
|
||||||
}
|
}
|
||||||
|
|
||||||
check_ctdb_tdb_statd_state ()
|
check_ctdb_tdb_statd_state()
|
||||||
{
|
{
|
||||||
ctdb_get_my_public_addresses |
|
ctdb_get_my_public_addresses |
|
||||||
while read _x _sip _x ; do
|
while read _x _sip _x; do
|
||||||
for _cip ; do
|
for _cip; do
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
statd-state@${_sip}@${_cip} $(date)
|
statd-state@${_sip}@${_cip} $(date)
|
||||||
EOF
|
EOF
|
||||||
@ -41,7 +41,7 @@ EOF
|
|||||||
} || exit $?
|
} || exit $?
|
||||||
}
|
}
|
||||||
|
|
||||||
check_statd_callout_smnotify ()
|
check_statd_callout_smnotify()
|
||||||
{
|
{
|
||||||
_state_even=$(( $(date '+%s') / 2 * 2))
|
_state_even=$(( $(date '+%s') / 2 * 2))
|
||||||
_state_odd=$(($_state_even + 1))
|
_state_odd=$(($_state_even + 1))
|
||||||
@ -49,8 +49,8 @@ check_statd_callout_smnotify ()
|
|||||||
nfs_load_config
|
nfs_load_config
|
||||||
|
|
||||||
ctdb_get_my_public_addresses |
|
ctdb_get_my_public_addresses |
|
||||||
while read _x _sip _x ; do
|
while read _x _sip _x; do
|
||||||
for _cip ; do
|
for _cip; do
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
SM_NOTIFY: ${_sip} -> ${_cip}, MON_NAME=${_sip}, STATE=${_state_even}
|
SM_NOTIFY: ${_sip} -> ${_cip}, MON_NAME=${_sip}, STATE=${_state_even}
|
||||||
SM_NOTIFY: ${_sip} -> ${_cip}, MON_NAME=${NFS_HOSTNAME}, STATE=${_state_even}
|
SM_NOTIFY: ${_sip} -> ${_cip}, MON_NAME=${NFS_HOSTNAME}, STATE=${_state_even}
|
||||||
|
Reference in New Issue
Block a user