The branch, master has been updated via 7a10e07 ctdb-build: Specify absolute path to libsocket-wrapper.so via a7dcc18 ctdb-tests: Remove the old, confusing INSTALL script via 50ddc2c ctdb-scripts: Remove unused function nfs_statd_update() via 500c6e1 ctdb-scripts: Change statd-callout to be more scalable via 032441d ctdb-scripts: Fix a regression in statd-callout via 22602f7 ctdb-tests: Unit tests for statd-callout via d98c7ba ctdb-tests: Make setup of public addresses more obvious via 7e7c24c ctdb-tests: Extend eventscript unit test infrastructure for other scripts via 9317d82 ctdb-tests: Support testing scripts that change directory via 2aeb518 ctdb-tests: Extend ctdb stub to support "ip" with and without -X via d057ca0 ctdb-tests: Extend ctdb stub to support "ptrans", "pdelete", "catdb" from 89788dd tevent: version 0.9.24
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 7a10e077706efd3b5d2ce024084b7ed97d4cd36c Author: Amitay Isaacs <ami...@gmail.com> Date: Wed Mar 4 15:55:15 2015 +1100 ctdb-build: Specify absolute path to libsocket-wrapper.so Specifying a relative path to LD_PRELOAD can fail if any of the test scripts uses cd to change directory and execute commands. Adding statd-callout tests breaks autotest since statd-callout does "cd". Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> Autobuild-User(master): Amitay Isaacs <ami...@samba.org> Autobuild-Date(master): Wed Mar 4 13:11:53 CET 2015 on sn-devel-104 commit a7dcc187e762b4f07e0233504a97aac816b04799 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Mar 4 11:51:50 2015 +1100 ctdb-tests: Remove the old, confusing INSTALL script It is not used after switching to waf build. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 50ddc2c35643389c2f249c6ad4496ab73a1bfc99 Author: Martin Schwenke <mar...@meltin.net> Date: Fri Feb 13 15:42:20 2015 +1100 ctdb-scripts: Remove unused function nfs_statd_update() Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 500c6e194babe06b6aead7a053a9442c94db6e38 Author: Martin Schwenke <mar...@meltin.net> Date: Fri Feb 13 20:55:43 2015 +1100 ctdb-scripts: Change statd-callout to be more scalable Updating ctdb.tdb on each add-client, del-client and each delete during notify was too ambitious. Persistent transactions do not perform well enough to do this. Revert to having add-client and del-client create touch files. Each monitor event calls "statd-callout update" to convert touch files into ctdb.tdb records. Update testcases to do the "update" and add an extra test. Signed-off-by: Martin Schwenke <mar...@meltin.net> Pair-programmed-with: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 032441d9a2974584cde455e4dbd5cc33fe6a23c2 Author: Martin Schwenke <mar...@meltin.net> Date: Thu Feb 26 15:34:51 2015 +1100 ctdb-scripts: Fix a regression in statd-callout Commit 4638010abb116aed0c180207aaa11475277aecb7 changed from using gensub() to gsub() in awk. However, it didn't halve the number of backslashes in the target strings. This is necessary because backslash is used in gensub() target strings to allow substitution of text matching parenthesised subexpressions. This is not the case with gsub(). So, halve the number of backslashes in the target string where gsub() is used in statd-callout. This is the only target string broken by changes made by the above commit Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 22602f76bc1ec91e807a8f1cd45ba6fb4c05e622 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Mar 4 11:51:20 2015 +1100 ctdb-tests: Unit tests for statd-callout With improvements to unit test infrastructure to support. This includes linking the real statd-callout into etc-ctdb/ in place of the placeholder script. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit d98c7ba382189161c5b8cbbebbdfbe36f1456572 Author: Martin Schwenke <mar...@meltin.net> Date: Fri Feb 27 15:20:56 2015 +1100 ctdb-tests: Make setup of public addresses more obvious Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 7e7c24ca7a422f2258962216b0184eda8d49827f Author: Martin Schwenke <mar...@meltin.net> Date: Fri Feb 27 15:19:04 2015 +1100 ctdb-tests: Extend eventscript unit test infrastructure for other scripts There's so much infrastructure here that it would be a shame not to use it for testing things like statd-callout. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 9317d82c19a0eb51ff6293d00328a5c36b063a2c Author: Martin Schwenke <mar...@meltin.net> Date: Fri Feb 27 15:17:30 2015 +1100 ctdb-tests: Support testing scripts that change directory Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 2aeb518637af29da03984470d874b94dfb18e34e Author: Martin Schwenke <mar...@meltin.net> Date: Fri Feb 27 15:15:18 2015 +1100 ctdb-tests: Extend ctdb stub to support "ip" with and without -X Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit d057ca04a9eec0f2aa3d792da0a4648e3716685a Author: Martin Schwenke <mar...@meltin.net> Date: Fri Feb 27 15:13:23 2015 +1100 ctdb-tests: Extend ctdb stub to support "ptrans", "pdelete", "catdb" Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> ----------------------------------------------------------------------- Summary of changes: ctdb/config/events.d/60.ganesha | 1 + ctdb/config/events.d/60.nfs | 1 + ctdb/config/functions | 27 ++-- ctdb/config/statd-callout | 142 ++++++++++++-------- ctdb/tests/INSTALL | 96 ------------- ctdb/tests/eventscripts/etc-ctdb/statd-callout | 6 +- ctdb/tests/eventscripts/scripts/local.sh | 148 +++++++++++++++++---- ctdb/tests/eventscripts/statd-callout.001.sh | 15 +++ ctdb/tests/eventscripts/statd-callout.002.sh | 16 +++ ctdb/tests/eventscripts/statd-callout.003.sh | 18 +++ ctdb/tests/eventscripts/statd-callout.004.sh | 19 +++ ctdb/tests/eventscripts/statd-callout.005.sh | 27 ++++ ctdb/tests/eventscripts/statd-callout.006.sh | 29 ++++ ctdb/tests/eventscripts/statd-callout.007.sh | 16 +++ ctdb/tests/eventscripts/stubs/ctdb | 129 +++++++++++++++--- ctdb/tests/eventscripts/stubs/id | 3 + .../stubs/ssh => eventscripts/stubs/smnotify} | 1 + ctdb/tests/scripts/common.sh | 4 + ctdb/wscript | 6 +- 19 files changed, 480 insertions(+), 224 deletions(-) delete mode 100755 ctdb/tests/INSTALL mode change 100755 => 120000 ctdb/tests/eventscripts/etc-ctdb/statd-callout create mode 100755 ctdb/tests/eventscripts/statd-callout.001.sh create mode 100755 ctdb/tests/eventscripts/statd-callout.002.sh create mode 100755 ctdb/tests/eventscripts/statd-callout.003.sh create mode 100755 ctdb/tests/eventscripts/statd-callout.004.sh create mode 100755 ctdb/tests/eventscripts/statd-callout.005.sh create mode 100755 ctdb/tests/eventscripts/statd-callout.006.sh create mode 100755 ctdb/tests/eventscripts/statd-callout.007.sh create mode 100755 ctdb/tests/eventscripts/stubs/id copy ctdb/tests/{onnode/stubs/ssh => eventscripts/stubs/smnotify} (62%) Changeset truncated at 500 lines: diff --git a/ctdb/config/events.d/60.ganesha b/ctdb/config/events.d/60.ganesha index 150be1f..fc17098 100755 --- a/ctdb/config/events.d/60.ganesha +++ b/ctdb/config/events.d/60.ganesha @@ -221,6 +221,7 @@ case "$1" in } || exit $? update_tickles 2049 + nfs_update_lock_info # check that statd responds to rpc requests # if statd is not running we try to restart it diff --git a/ctdb/config/events.d/60.nfs b/ctdb/config/events.d/60.nfs index c4e798e..d570cd7 100755 --- a/ctdb/config/events.d/60.nfs +++ b/ctdb/config/events.d/60.nfs @@ -91,6 +91,7 @@ case "$1" in } || exit $? update_tickles 2049 + nfs_update_lock_info nfs_check_rpc_services diff --git a/ctdb/config/functions b/ctdb/config/functions index 8c5e472f1..e6fe43f 100755 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -690,6 +690,16 @@ get_tcp_connections_for_ip () {print $4" "$5}' } +################################################################## +# use statd-callout to update NFS lock info +################################################################## +nfs_update_lock_info () +{ + if [ -x "$CTDB_BASE/statd-callout" ] ; then + "$CTDB_BASE/statd-callout" update + fi +} + ######################################################## # start/stop the Ganesha nfs service ######################################################## @@ -832,23 +842,6 @@ startstop_nfslock() { esac } -# Periodically update the statd database -nfs_statd_update () -{ - _update_period="$1" - - _statd_update_trigger="$service_state_dir/update-trigger" - [ -f "$_statd_update_trigger" ] || touch "$_statd_update_trigger" - - _last_update=$(stat --printf="%Y" "$_statd_update_trigger") - _current_time=$(date +"%s") - if [ $(( $_current_time - $_last_update)) -ge $_update_period ] ; then - touch "$_statd_update_trigger" - $CTDB_BASE/statd-callout updatelocal & - $CTDB_BASE/statd-callout updateremote & - fi -} - ######################################################## add_ip_to_iface () diff --git a/ctdb/config/statd-callout b/ctdb/config/statd-callout index e2a955e..4a331ac 100755 --- a/ctdb/config/statd-callout +++ b/ctdb/config/statd-callout @@ -30,7 +30,19 @@ loadconfig nfs nl=" " +ctdb_setup_service_state_dir "statd-callout" + +cd "$service_state_dir" || \ + die "Failed to change directory to \"${service_state_dir}\"" + case "$1" in + # Keep a single file to keep track of the last "add-client" or + # "del-client'. These get pushed to ctdb.tdb during "update", + # which will generally be run once each "monitor" cycle. In this + # way we avoid scalability problems with flood of persistent + # transactions after a "notify" when all the clients re-take their + # locks. + add-client) # statd does not tell us to which IP the client connected so # we must add it to all the IPs that we serve @@ -38,42 +50,47 @@ case "$1" in pnn=$(ctdb xpnn | sed -e 's/.*://') date=$(date '+%s') ctdb ip -X | - tail -n +2 | { - # This all needs to be in the end of the pipe so it - # doesn't get lost - items="" - while IFS="|" read x sip node x ; do - [ "$node" = "$pnn" ] || continue # not us - key="statd-state@${sip}@${cip}" - item="\"${key}\" \"${date}\"" - items="${items}${items:+${nl}}${item}" - done - if ! echo "$items" | ctdb ptrans "ctdb.tdb" ; then - die "Failed to add clients" - fi - } + tail -n +2 | + while IFS="|" read x sip node x ; do + [ "$node" = "$pnn" ] || continue # not us + key="statd-state@${sip}@${cip}" + echo "\"${key}\" \"${date}\"" >"$key" + done ;; - del-client) + + del-client) # statd does not tell us from which IP the client disconnected # so we must add it to all the IPs that we serve cip="$2" pnn=$(ctdb xpnn | sed -e 's/.*://') ctdb ip -X | - tail -n +2 | { - # This all needs to be in the end of the pipe so it - # doesn't get lost - items="" - while IFS="|" read x sip node x ; do - [ "$node" = "$pnn" ] || continue # not us - key="statd-state@${sip}@${cip}" - item="\"${key}\" \"\"" - items="${items}${items:+${nl}}${item}" - done - if ! echo "$items" | ctdb ptrans "ctdb.tdb" ; then - die "Failed to delete clients" - fi - } + tail -n +2 | + while IFS="|" read x sip node x ; do + [ "$node" = "$pnn" ] || continue # not us + key="statd-state@${sip}@${cip}" + echo "\"${key}\" \"\"" >"$key" + done ;; + + update) + files=$(echo statd-state@*) + if [ "$files" = "statd-state@*" ] ; then + # No files! + exit 0 + fi + # Filter out lines for any IP addresses that are not currently + # hosted public IP addresses. + pnn=$(ctdb xpnn | sed -e 's/.*://') + ctdb_ips=$(ctdb ip | tail -n +2) + sed_expr=$(echo "$ctdb_ips" | + awk -v pnn=$pnn 'pnn == $2 { \ + ip = $1; gsub(/\./, "\\.", ip); \ + printf "/statd-state@%s@/p\n", ip }') + if cat $files | sed -n "$sed_expr" | ctdb ptrans "ctdb.tdb" ; then + rm $files + fi + ;; + notify) # we must restart the lockmanager (on all nodes) so that we get # a clusterwide grace period (so other clients dont take out @@ -144,42 +161,51 @@ case "$1" in # Construct a sed expression to take catdb output and produce pairs of: # server-IP client-IP # but only for the server-IPs that are hosted on this node. - sed_expr=$(ctdb ip | tail -n +2 | + ctdb_all_ips=$(ctdb ip -n all | tail -n +2) + sed_expr=$(echo "$ctdb_all_ips" | awk -v pnn=$pnn 'pnn == $2 { \ - ip = $1; gsub(/\./, "\\\\.", ip); \ + ip = $1; gsub(/\./, "\\.", ip); \ printf "s/^key.*=.*statd-state@\\(%s\\)@\\([^\"]*\\).*/\\1 \\2/p\n", ip }') statd_state=$(ctdb catdb ctdb.tdb | sed -n "$sed_expr" | sort) [ -n "$statd_state" ] || exit 0 - # The following is dangerous if this script times out before - # all of the smnotify commands are run. Revert to individual - # pdelete commands for now and consider optimising smnotify to - # read all the data from stdin and then run it in the - # background. - # - # Delete all the items from the TDB - #if ! echo "$statd_state" | \ - # awk '{ printf "\"statd-state@%s@%s\" \"\"\n", $1, $2 }') | \ - # ctdb ptrans ctdb.tdb ; then + prev="" + echo "$statd_state" | { + # This all needs to be in the same command group at the + # end of the pipe so it doesn't get lost when the loop + # completes. + items="" + while read sip cip ; do + # Collect item to delete from the DB + key="statd-state@${sip}@${cip}" + item="\"${key}\" \"\"" + items="${items}${items:+${nl}}${item}" - # die "Yikes!" - #fi + # NOTE: Consider optimising smnotify to read all the + # data from stdin and then run it in the background. + + # Reset stateval for each serverip + [ "$sip" = "$prev" ] || stateval="$state_even" + # Send notifies for server shutdown + smnotify --client=$cip --ip=$sip --server=$sip --stateval=$stateval + smnotify --client=$cip --ip=$sip --server=$NFS_HOSTNAME --stateval=$stateval + # Send notifies for server startup + stateval=$(($stateval + 1)) + smnotify --client=$cip --ip=$sip --server=$sip --stateval=$stateval + smnotify --client=$cip --ip=$sip --server=$NFS_HOSTNAME --stateval=$stateval + done - prev="" - echo "$statd_state" | - while read sip cip ; do - # Delete the entry from the DB - ctdb pdelete ctdb.tdb "statd-state@${sip}@${cip}" - # Reset stateval for each serverip - [ "$sip" = "$prev" ] || stateval="$state_even" - # Send notifies for server shutdown - smnotify --client=$cip --ip=$sip --server=$sip --stateval=$stateval - smnotify --client=$cip --ip=$sip --server=$NFS_HOSTNAME --stateval=$stateval - # Send notifies for server startup - stateval=$(($stateval + 1)) - smnotify --client=$cip --ip=$sip --server=$sip --stateval=$stateval - smnotify --client=$cip --ip=$sip --server=$NFS_HOSTNAME --stateval=$stateval - done + echo "$items" | ctdb ptrans "ctdb.tdb" + } + + # Remove any stale touch files (i.e. for IPs not currently + # hosted on this node and created since the last "update"). + # There's nothing else we can do with them at this stage. + echo "$ctdb_all_ips" | + awk -v pnn=$pnn 'pnn != $2 { print $1 }' | + while read sip ; do + rm -f "statd-state@${sip}@"* + done ;; esac diff --git a/ctdb/tests/INSTALL b/ctdb/tests/INSTALL deleted file mode 100755 index 23dcdaf..0000000 --- a/ctdb/tests/INSTALL +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/sh - -# Stop on 1st error -set -e - -# Script to install the CTDB testsuite on a machine. - -usage () -{ - if [ -n "$1" ] ; then - echo "$1" - echo - fi - - cat <<EOF - $0 --destdir=<DIR1> \\ - --datarootdir=<DIR2> \\ - --libdir=<DIR3> \\ - --bindir=<DIR4> \\ - --etcdir=<DIR5> -EOF - exit 1 -} - -parse_options () -{ - temp=$(getopt -n "$prog" -o "h" -l help,destdir:,datarootdir:,libdir:,bindir:,etcdir: -- "$@") - - [ $? != 0 ] && usage - - eval set -- "$temp" - - destdir="" - datarootdir="" - libdir="" - bindir="" - etcdir="" - - while true ; do - case "$1" in - --destdir) destdir="$2" ; shift 2 ;; - --datarootdir) datarootdir="$2" ; shift 2 ;; - --libdir) libdir="$2" ; shift 2 ;; - --bindir) bindir="$2" ; shift 2 ;; - --etcdir) etcdir="$2" ; shift 2 ;; - --) shift ; break ;; - -h|--help|*) usage ;; # Shouldn't happen, so this is reasonable. - esac - done - - [ $# -gt 0 ] && usage - - [ -n "$destdir" ] || usage "No option --destdir specified" - [ -n "$datarootdir" ] || usage "No option --datarootdir specified" - [ -n "$libdir" ] || usage "No option --libdir specified" - [ -n "$bindir" ] || usage "No option --bindir specified" - [ -n "$etcdir" ] || usage "No option --etcdir specified" -} - -parse_options "$@" - -# Make things neater! -if [ "$destdir" = "/" ] ; then - destdir="" -fi - -data_subdirs="complex events.d eventscripts onnode scripts simple takeover tool" - -ctdb_datadir="${destdir}${datarootdir}/ctdb-tests" -echo "Installing test data files into ${ctdb_datadir}..." -for d in $data_subdirs ; do - mkdir -p "${ctdb_datadir}/${d}" - cp -pr "tests/${d}" "${ctdb_datadir}" -done -# Some of the unit tests have relative symlinks back to in-tree bits -# and pieces. These links will be broken! -link_dir="${ctdb_datadir}/eventscripts/etc-ctdb/" -broken_links=$(find "$link_dir" -type l | sed -e "s@^${link_dir}@@") -for i in $broken_links ; do - ln -sf "${etcdir}/ctdb/${i}" "${ctdb_datadir}/eventscripts/etc-ctdb/${i}" -done -# test_wrap needs to set TEST_BIN_DIR -sed -i -e "s@^TEST_SCRIPTS_DIR=.*@&\nexport TEST_BIN_DIR=\"${libdir}/ctdb-tests\"@" "${ctdb_datadir}/scripts/test_wrap" - -ctdb_libdir="${destdir}${libdir}/ctdb-tests" -mkdir -p "${destdir}${libdir}" -echo "Installing test binary files into ${ctdb_libdir}..." -cp -pr "tests/bin/" "${ctdb_libdir}" - -ctdb_bindir="${destdir}${bindir}" -echo "Installing wrapper scripts into ${ctdb_bindir}..." -mkdir -p "${ctdb_bindir}" -out="${ctdb_bindir}/ctdb_run_tests" -sed -e "s@^test_dir=.*@test_dir=${datarootdir}/ctdb-tests\nexport TEST_BIN_DIR=\"${libdir}/ctdb-tests\"@" -e 's@^\(export CTDB_TESTS_ARE_INSTALLED\)=false@\1=true@' "tests/run_tests.sh" >"$out" -chmod 755 "$out" -ln -s "ctdb_run_tests" "${ctdb_bindir}/ctdb_run_cluster_tests" diff --git a/ctdb/tests/eventscripts/etc-ctdb/statd-callout b/ctdb/tests/eventscripts/etc-ctdb/statd-callout deleted file mode 100755 index 51779bd..0000000 --- a/ctdb/tests/eventscripts/etc-ctdb/statd-callout +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -# For now, always succeed. - -exit 0 diff --git a/ctdb/tests/eventscripts/etc-ctdb/statd-callout b/ctdb/tests/eventscripts/etc-ctdb/statd-callout new file mode 120000 index 0000000..dbd3c98 --- /dev/null +++ b/ctdb/tests/eventscripts/etc-ctdb/statd-callout @@ -0,0 +1 @@ +../../../config/statd-callout \ No newline at end of file diff --git a/ctdb/tests/eventscripts/scripts/local.sh b/ctdb/tests/eventscripts/scripts/local.sh index f044ef8..fe4ae1e 100644 --- a/ctdb/tests/eventscripts/scripts/local.sh +++ b/ctdb/tests/eventscripts/scripts/local.sh @@ -9,6 +9,10 @@ EVENTSCRIPTS_PATH="" if [ -d "${TEST_SUBDIR}/stubs" ] ; then EVENTSCRIPTS_PATH="${TEST_SUBDIR}/stubs" + case "$EVENTSCRIPTS_PATH" in + /*) : ;; + *) EVENTSCRIPTS_PATH="${PWD}/${EVENTSCRIPTS_PATH}" ;; + esac fi export EVENTSCRIPTS_PATH @@ -272,6 +276,33 @@ ctdb_set_output () eventscripts_test_add_cleanup "rm -f $_out $_rc" } +# For now this creates the same public addresses each time. However, +# it could be made more flexible. +setup_public_addresses () +{ + if [ -f "$CTDB_PUBLIC_ADDRESSES" -a \ + "${CTDB_PUBLIC_ADDRESSES%/*}" = "$EVENTSCRIPTS_TESTS_VAR_DIR" ] ; then + rm "$CTDB_PUBLIC_ADDRESSES" + fi + + export CTDB_PUBLIC_ADDRESSES=$(mktemp \ + --tmpdir="$EVENTSCRIPTS_TESTS_VAR_DIR" \ + "public-addresses-XXXXXXXX") + + echo "Setting up CTDB_PUBLIC_ADDRESSES=${CTDB_PUBLIC_ADDRESSES}" + cat >"$CTDB_PUBLIC_ADDRESSES" <<EOF +10.0.0.1/24 dev123 +10.0.0.2/24 dev123 +10.0.0.3/24 dev123 +10.0.0.4/24 dev123 +10.0.0.5/24 dev123 +10.0.0.6/24 dev123 +10.0.1.1/24 dev456 +10.0.1.2/24 dev456 +10.0.1.3/24 dev456 +EOF +} + setup_ctdb () { setup_generic @@ -282,17 +313,7 @@ setup_ctdb () export FAKE_CTDB_PNN="${2:-0}" echo "Setting up CTDB with PNN ${FAKE_CTDB_PNN}" - export CTDB_PUBLIC_ADDRESSES="${CTDB_BASE}/public_addresses" - if [ -n "$3" ] ; then - echo "Setting up CTDB_PUBLIC_ADDRESSES: $3" - CTDB_PUBLIC_ADDRESSES=$(mktemp) - for _i in $3 ; do - _ip="${_i%@*}" - _ifaces="${_i#*@}" - echo "${_ip} ${_ifaces}" >>"$CTDB_PUBLIC_ADDRESSES" - done - eventscripts_test_add_cleanup "rm -f $CTDB_PUBLIC_ADDRESSES" - fi + setup_public_addresses export FAKE_CTDB_STATE="$EVENTSCRIPTS_TESTS_VAR_DIR/fake-ctdb" @@ -517,6 +538,65 @@ EOF ###################################################################### +ctdb_catdb_format_pairs () +{ + _count=0 + + while read _k _v ; do + _kn=$(echo -n "$_k" | wc -c) + _vn=$(echo -n "$_v" | wc -c) + cat <<EOF +key(${_kn}) = "${_k}" +dmaster: 0 +rsn: 1 +data(${_vn}) = "${_v}" + +EOF + _count=$(($_count + 1)) + done + + echo "Dumped ${_count} records" +} + +check_ctdb_tdb_statd_state () +{ + ctdb_get_my_public_addresses | + while read _x _sip _x ; do + for _cip ; do + echo "statd-state@${_sip}@${_cip}" "$FAKE_DATE_OUTPUT" + done + done | + ctdb_catdb_format_pairs | { + ok + simple_test_command ctdb catdb ctdb.tdb + } +} + +check_statd_callout_smnotify () +{ + _state_even=$(( $(date '+%s') / 2 * 2)) + _state_odd=$(($_state_even + 1)) + + nfs_load_config + + ctdb_get_my_public_addresses | + while read _x _sip _x ; do + for _cip ; do + cat <<EOF +--client=${_cip} --ip=${_sip} --server=${_sip} --stateval=${_state_even} +--client=${_cip} --ip=${_sip} --server=${NFS_HOSTNAME} --stateval=${_state_even} +--client=${_cip} --ip=${_sip} --server=${_sip} --stateval=${_state_odd} +--client=${_cip} --ip=${_sip} --server=${NFS_HOSTNAME} --stateval=${_state_odd} +EOF + done + done | { + ok + simple_test_event "notify" + } +} -- Samba Shared Repository