1 # Hey Emacs, this is a -*- shell-script -*- !!! :-)
9 ######################################################################
15 teststarttime=$(date '+%s')
18 echo "--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--"
19 echo "Running test $name ($(date '+%T'))"
20 echo "--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--"
25 local name="$1" ; shift
26 local status="$1" ; shift
27 # "$@" is command-line
29 local interp="SKIPPED"
30 local statstr=" (reason $*)"
31 if [ -n "$status" ] ; then
32 if [ $status -eq 0 ] ; then
38 statstr=" (status $status)"
39 testfailures=$(($testfailures+1))
43 testduration=$(($(date +%s)-$teststarttime))
45 echo "=========================================================================="
46 echo "TEST ${interp}: ${name}${statstr} (duration: ${testduration}s)"
47 echo "=========================================================================="
53 exit $(($testfailures+0))
56 ctdb_check_time_logs ()
65 out=$(onnode all tail -n 20 /var/log/ctdb.test.time.log 2>&1)
67 if [ $? -eq 0 ] ; then
72 node="${line#>> NODE: }"
79 if [ -n "$ds_prev" ] && \
80 [ $(($ds_curr - $ds_prev)) -ge $threshold ] ; then
81 echo "Node $node had time jump of $(($ds_curr - $ds_prev))ds between $(date +'%T' -d @${ds_prev%?}) and $(date +'%T' -d @${ds_curr%?})"
90 echo Error getting time logs
93 echo "Check time sync (test client first):"
96 echo "Information from test client:"
99 echo "Information from cluster nodes:"
100 onnode all "top -b -n 1 ; echo '/proc/slabinfo' ; cat /proc/slabinfo"
110 [ $(($testfailures+0)) -eq 0 -a $status -ne 0 ] && testfailures=$status
111 status=$(($testfailures+0))
113 # Avoid making a test fail from this point onwards. The test is
117 echo "*** TEST COMPLETED (RC=$status) AT $(date '+%F %T'), CLEANING UP..."
119 if [ -n "$CTDB_TEST_REAL_CLUSTER" -a $status -ne 0 ] ; then
123 eval "$ctdb_test_exit_hook" || true
124 unset ctdb_test_exit_hook
126 if $ctdb_test_restart_scheduled || ! cluster_is_healthy ; then
130 # This could be made unconditional but then we might get
131 # duplication from the recovery in restart_ctdb. We want to
132 # leave the recovery in restart_ctdb so that future tests that
133 # might do a manual restart mid-test will benefit.
134 echo "Forcing a recovery..."
135 onnode 0 $CTDB recover
141 ctdb_test_exit_hook_add ()
143 ctdb_test_exit_hook="${ctdb_test_exit_hook}${ctdb_test_exit_hook:+ ; }$*"
148 local name="$1" ; shift
150 [ -n "$1" ] || set -- "$name"
152 ctdb_test_begin "$name"
157 ctdb_test_end "$name" "$status" "$*"
170 -h, --help show this screen.
171 -v, --version show test case version.
172 --category show the test category (ACL, CTDB, Samba ...).
173 -d, --description show test case description.
174 --summary show short test case summary.
175 -x trace test using set -x
183 [ -n "$CTDB_DIR" ] || fail "Can not determine version."
185 (cd "$CTDB_DIR" && git describe)
188 ctdb_test_cmd_options()
190 [ -n "$1" ] || return 0
193 -h|--help) ctdb_test_usage 0 ;;
194 -v|--version) ctdb_test_version ;;
195 --category) echo "CTDB" ;;
196 -d|--description) test_info ;;
197 -x) set -x ; return 0 ;;
199 echo "Error: Unknown parameter = $1"
210 scriptname=$(basename "$0")
212 ctdb_test_restart_scheduled=false
214 ctdb_test_cmd_options $@
216 trap "ctdb_test_exit" 0
219 ctdb_test_check_real_cluster ()
221 [ -n "$CTDB_TEST_REAL_CLUSTER" ] && return 0
223 echo "ERROR: This test must be run on a real/virtual cluster, not local daemons."
227 ########################################
230 try_command_on_node ()
232 local nodespec="$1" ; shift
237 while [ "${nodespec#-}" != "$nodespec" ] ; do
238 if [ "$nodespec" = "-v" ] ; then
241 onnode_opts="$nodespec"
243 nodespec="$1" ; shift
248 out=$(onnode -q $onnode_opts "$nodespec" "$cmd" 2>&1) || {
250 echo "Failed to execute \"$cmd\" on node(s) \"$nodespec\""
256 echo "Output of \"$cmd\":"
261 sanity_check_output ()
264 local regexp="$2" # Should be anchored as necessary.
269 local num_lines=$(echo "$output" | wc -l)
270 echo "There are $num_lines lines of output"
271 if [ $num_lines -lt $min_lines ] ; then
272 echo "BAD: that's less than the required number (${min_lines})"
277 local unexpected # local doesn't pass through status of command on RHS.
278 unexpected=$(echo "$output" | egrep -v "$regexp") || status=$?
280 # Note that this is reversed.
281 if [ $status -eq 0 ] ; then
282 echo "BAD: unexpected lines in output:"
283 echo "$unexpected" | cat -A
286 echo "Output lines look OK"
294 local ips="$1" # list of "ip node" lines
296 echo "Sanity checking IPs..."
300 while read x ipp ; do
301 [ "$ipp" = "-1" ] && break
302 if [ -n "$prev" -a "$ipp" != "$prev" ] ; then
309 echo "BAD: a node was -1 or IPs are only assigned to one node"
310 echo "Are you running an old version of CTDB?"
314 # This returns a list of "ip node" lines in $out
318 try_command_on_node $node "$CTDB ip -Y -n all | cut -d ':' -f1-3 | sed -e '1d' -e 's@^:@@' -e 's@:@ @g'"
321 select_test_node_and_ips ()
325 # When selecting test_node we just want a node that has public
326 # IPs. This will work and is economically semi-random. :-)
328 read x test_node <<<"$out"
332 while read ip pnn ; do
333 if [ "$pnn" = "$test_node" ] ; then
334 test_node_ips="${test_node_ips}${test_node_ips:+ }${ip}"
336 done <<<"$out" # bashism to avoid problem setting variable in pipeline.
338 echo "Selected node ${test_node} with IPs: ${test_node_ips}."
339 test_ip="${test_node_ips%% *}"
342 #######################################
344 # Wait until either timeout expires or command succeeds. The command
345 # will be tried once per second.
348 local timeout="$1" ; shift # "$@" is the command...
351 if [ "$1" = "!" ] ; then
356 echo -n "<${timeout}|"
358 while [ $t -gt 0 ] ; do
361 if { ! $negate && [ $rc -eq 0 ] ; } || \
362 { $negate && [ $rc -ne 0 ] ; } ; then
363 echo "|$(($timeout - $t))|"
380 for i in $(seq 1 $1) ; do
387 _cluster_is_healthy ()
389 local out x count line
391 out=$($CTDB -Y status 2>/dev/null) || return 1
397 # We need to see valid lines if we're going to be healthy.
398 [ "${line#:[0-9]}" != "$line" ] && count=$(($count + 1))
399 # A line indicating a node is unhealthy causes failure.
400 [ "${line##:*:*:*1:}" != "$line" ] && return 1
402 [ $count -gt 0 ] && return $?
403 } <<<"$out" # Yay bash!
406 cluster_is_healthy ()
408 if onnode 0 $CTDB_TEST_WRAPPER _cluster_is_healthy ; then
409 echo "Cluster is HEALTHY"
412 echo "Cluster is UNHEALTHY"
413 if ! ${ctdb_test_restart_scheduled:-false} ; then
414 echo "DEBUG AT $(date '+%F %T'):"
416 for i in "onnode -q 0 $CTDB status" "onnode -q 0 onnode all $CTDB scriptstatus" ; do
425 wait_until_healthy ()
427 local timeout="${1:-120}"
429 echo "Waiting for cluster to become healthy..."
431 wait_until 120 _cluster_is_healthy
434 # This function is becoming nicely overloaded. Soon it will collapse! :-)
442 (unhealthy) bits="?:?:?:1:*" ;;
443 (healthy) bits="?:?:?:0:*" ;;
444 (disconnected) bits="1:*" ;;
445 (connected) bits="0:*" ;;
446 (banned) bits="?:1:*" ;;
447 (unbanned) bits="?:0:*" ;;
448 (disabled) bits="?:?:1:*" ;;
449 (enabled) bits="?:?:0:*" ;;
450 (stopped) bits="?:?:?:?:1:*" ;;
451 (notstopped) bits="?:?:?:?:0:*" ;;
452 (frozen) fpat='^[[:space:]]+frozen[[:space:]]+1$' ;;
453 (unfrozen) fpat='^[[:space:]]+frozen[[:space:]]+0$' ;;
454 (monon) mpat='^Monitoring mode:ACTIVE \(0\)$' ;;
455 (monoff) mpat='^Monitoring mode:DISABLED \(1\)$' ;;
457 echo "node_has_status: unknown status \"$status\""
461 if [ -n "$bits" ] ; then
464 out=$($CTDB -Y status 2>&1) || return 1
469 # This needs to be done in 2 steps to avoid false matches.
470 local line_bits="${line#:${pnn}:*:}"
471 [ "$line_bits" = "$line" ] && continue
472 [ "${line_bits#${bits}}" != "$line_bits" ] && return 0
475 } <<<"$out" # Yay bash!
476 elif [ -n "$fpat" ] ; then
477 $CTDB statistics -n "$pnn" | egrep -q "$fpat"
478 elif [ -n "$mpat" ] ; then
479 $CTDB getmonmode -n "$pnn" | egrep -q "$mpat"
481 echo 'node_has_status: unknown mode, neither $bits nor $fpat is set'
486 wait_until_node_has_status ()
490 local timeout="${3:-30}"
492 echo "Waiting until node $pnn has status \"$status\"..."
494 if ! wait_until $timeout onnode any $CTDB_TEST_WRAPPER node_has_status "$pnn" "$status" ; then
495 for i in "onnode -q any $CTDB status" "onnode -q any onnode all $CTDB scriptstatus" ; do
505 # Useful for superficially testing IP failover.
506 # IPs must be on nodes matching nodeglob.
507 ips_are_on_nodeglob ()
509 local nodeglob="$1" ; shift
516 while read ip pnn ; do
517 for check in $ips ; do
518 if [ "$check" = "$ip" ] ; then
523 ips="${ips/${ip}}" # Remove from list
526 done <<<"$out" # bashism to avoid problem setting variable in pipeline.
528 ips="${ips// }" # Remove any spaces.
532 wait_until_ips_are_on_nodeglob ()
534 echo "Waiting for IPs to fail over..."
536 wait_until 60 ips_are_on_nodeglob "$@"
547 while read ip pnn ; do
548 if [ "$node" = "$pnn" ] ; then
551 done <<<"$out" # bashism to avoid problem setting variable in pipeline.
556 wait_until_node_has_some_ips ()
558 echo "Waiting for node to have some IPs..."
560 wait_until 60 node_has_some_ips "$@"
566 local dst_socket="$2"
570 local pat="^${proto}[[:space:]]+[[:digit:]]+[[:space:]]+[[:digit:]]+[[:space:]]+[^[:space:]]+[[:space:]]+${dst_socket//./\\.}[[:space:]]+ESTABLISHED[[:space:]]+${pid}/${prog}[[:space:]]*\$"
571 out=$(netstat -tanp |
578 wait_until_get_src_socket ()
581 local dst_socket="$2"
585 echo "Waiting for ${prog} to establish connection to ${dst_socket}..."
587 wait_until 5 get_src_socket "$@"
590 #######################################
592 # filename will be in $tcpdump_filename, pid in $tcpdump_pid
595 tcpdump_filter="$1" # global
597 echo "Running tcpdump..."
598 tcpdump_filename=$(mktemp)
599 ctdb_test_exit_hook_add "rm -f $tcpdump_filename"
601 # The only way of being sure that tcpdump is listening is to send
602 # some packets that it will see. So we use dummy pings - the -U
603 # option to tcpdump ensures that packets are flushed to the file
604 # as they are captured.
605 local dummy_addr="127.3.2.1"
606 local dummy="icmp and dst host ${dummy_addr} and icmp[icmptype] == icmp-echo"
607 tcpdump -n -p -s 0 -e -U -w $tcpdump_filename -i any "($tcpdump_filter) or ($dummy)" &
608 ctdb_test_exit_hook_add "kill $! >/dev/null 2>&1"
610 echo "Waiting for tcpdump output file to be ready..."
611 ping -q "$dummy_addr" >/dev/null 2>&1 &
612 ctdb_test_exit_hook_add "kill $! >/dev/null 2>&1"
614 tcpdump_listen_for_dummy ()
616 tcpdump -n -r $tcpdump_filename -c 1 "$dummy" >/dev/null 2>&1
619 wait_until 10 tcpdump_listen_for_dummy
622 # By default, wait for 1 matching packet.
625 local count="${1:-1}"
626 local filter="${2:-${tcpdump_filter}}"
630 local found=$(tcpdump -n -r $tcpdump_filename "$filter" 2>/dev/null | wc -l)
631 [ $found -ge $count ]
634 echo "Waiting for tcpdump to capture some packets..."
635 if ! wait_until 30 tcpdump_check ; then
636 echo "DEBUG AT $(date '+%F %T'):"
638 for i in "onnode -q 0 $CTDB status" "netstat -tanp" "tcpdump -n -e -r $tcpdump_filename" ; do
648 local filter="${1:-${tcpdump_filter}}"
650 tcpdump -n -r $tcpdump_filename "$filter" 2>/dev/null
653 tcptickle_sniff_start ()
658 local in="src host ${dst%:*} and tcp src port ${dst##*:} and dst host ${src%:*} and tcp dst port ${src##*:}"
659 local out="src host ${src%:*} and tcp src port ${src##*:} and dst host ${dst%:*} and tcp dst port ${dst##*:}"
660 local tickle_ack="${in} and (tcp[tcpflags] & tcp-ack != 0) and (tcp[14] == 4) and (tcp[15] == 210)" # win == 1234
661 local ack_ack="${out} and (tcp[tcpflags] & tcp-ack != 0)"
662 tcptickle_reset="${in} and tcp[tcpflags] & tcp-rst != 0"
663 local filter="(${tickle_ack}) or (${ack_ack}) or (${tcptickle_reset})"
665 tcpdump_start "$filter"
668 tcptickle_sniff_wait_show ()
670 tcpdump_wait 1 "$tcptickle_reset"
672 echo "GOOD: here are some TCP tickle packets:"
676 gratarp_sniff_start ()
678 tcpdump_start "arp host ${test_ip}"
681 gratarp_sniff_wait_show ()
685 echo "GOOD: this should be the some gratuitous ARPs:"
690 #######################################
694 echo "Attempting to politely shutdown daemons..."
695 onnode 1 $CTDB shutdown -n all || true
697 echo "Sleeping for a while..."
700 if pgrep -f $CTDB_DIR/bin/ctdbd >/dev/null ; then
701 echo "Killing remaining daemons..."
702 pkill -f $CTDB_DIR/bin/ctdbd
704 if pgrep -f $CTDB_DIR/bin/ctdbd >/dev/null ; then
705 echo "Once more with feeling.."
706 pkill -9 $CTDB_DIR/bin/ctdbd
710 local var_dir=$CTDB_DIR/tests/var
711 rm -rf $var_dir/test.db
716 local num_nodes="${CTDB_TEST_NUM_DAEMONS:-2}" # default is 2 nodes
718 local var_dir=$CTDB_DIR/tests/var
720 mkdir -p $var_dir/test.db/persistent
722 local nodes=$var_dir/nodes.txt
723 local public_addresses=$var_dir/public_addresses.txt
724 local no_public_addresses=$var_dir/no_public_addresses.txt
725 rm -f $nodes $public_addresses $no_public_addresses
727 # If there are (strictly) greater than 2 nodes then we'll randomly
728 # choose a node to have no public addresses.
729 local no_public_ips=-1
730 [ $num_nodes -gt 2 ] && no_public_ips=$(($RANDOM % $num_nodes))
731 echo "$no_public_ips" >$no_public_addresses
734 for i in $(seq 1 $num_nodes) ; do
735 if [ "${CTDB_USE_IPV6}x" != "x" ]; then
737 ip addr add ::$i/128 dev lo
739 echo 127.0.0.$i >> $nodes
740 # 2 public addresses on most nodes, just to make things interesting.
741 if [ $(($i - 1)) -ne $no_public_ips ] ; then
742 echo "192.0.2.$i/24 lo" >> $public_addresses
743 echo "192.0.2.$(($i + $num_nodes))/24 lo" >> $public_addresses
752 shift # "$@" gets passed to ctdbd
754 local var_dir=$CTDB_DIR/tests/var
756 local nodes=$var_dir/nodes.txt
757 local public_addresses=$var_dir/public_addresses.txt
758 local no_public_addresses=$var_dir/no_public_addresses.txt
760 local no_public_ips=-1
761 [ -r $no_public_addresses ] && read no_public_ips <$no_public_addresses
763 if [ "$no_public_ips" = $pnn ] ; then
764 echo "Node $no_public_ips will have no public IPs."
767 local ctdb_options="--reclock=$var_dir/rec.lock --nlist $nodes --nopublicipcheck --event-script-dir=$CTDB_DIR/tests/events.d --logfile=$var_dir/daemons.log -d 0 --dbdir=$var_dir/test.db --dbdir-persistent=$var_dir/test.db/persistent --dbdir-state=$var_dir/test.db/state"
769 if [ $(id -u) -eq 0 ]; then
770 ctdb_options="$ctdb_options --public-interface=lo"
773 if [ $pnn -eq $no_public_ips ] ; then
774 ctdb_options="$ctdb_options --public-addresses=/dev/null"
776 ctdb_options="$ctdb_options --public-addresses=$public_addresses"
779 # Need full path so we can use "pkill -f" to kill the daemons.
780 $VALGRIND $CTDB_DIR/bin/ctdbd --socket=$var_dir/sock.$pnn $ctdb_options "$@" ||return 1
785 # "$@" gets passed to ctdbd
787 local num_nodes="${CTDB_TEST_NUM_DAEMONS:-2}" # default is 2 nodes
789 echo "Starting $num_nodes ctdb daemons..."
791 for i in $(seq 0 $(($num_nodes - 1))) ; do
792 daemons_start_1 $i "$@"
795 local var_dir=$CTDB_DIR/tests/var
797 if [ -L /tmp/ctdb.socket -o ! -S /tmp/ctdb.socket ] ; then
798 ln -sf $var_dir/sock.0 /tmp/ctdb.socket || return 1
802 #######################################
804 _ctdb_hack_options ()
806 local ctdb_options="$*"
808 # We really just want to pass CTDB_OPTIONS but on RH
809 # /etc/sysconfig/ctdb can, and frequently does, set that variable.
810 # So instead, we hack badly. We'll add these as we use them.
811 # Note that these may still be overridden by the above file... but
812 # we tend to use the exotic options here... so that is unlikely.
814 case "$ctdb_options" in
815 *--start-as-stopped*)
816 export CTDB_START_AS_STOPPED="yes"
822 _ctdb_hack_options "$@"
824 if [ -e /etc/redhat-release ] ; then
827 /etc/init.d/ctdb restart
833 _ctdb_hack_options "$@"
835 /etc/init.d/ctdb start
840 if [ -n "$CTDB_NODES_SOCKETS" ] ; then
845 # Common things to do after starting one or more nodes.
848 onnode -q 1 $CTDB_TEST_WRAPPER wait_until_healthy || return 1
850 echo "Setting RerecoveryTimeout to 1"
851 onnode -pq all "$CTDB setvar RerecoveryTimeout 1"
853 # In recent versions of CTDB, forcing a recovery like this blocks
854 # until the recovery is complete. Hopefully this will help the
855 # cluster to stabilise before a subsequent test.
856 echo "Forcing a recovery..."
857 onnode -q 0 $CTDB recover
859 echo "Forcing a recovery..."
860 onnode -q 0 $CTDB recover
865 # This assumes that ctdbd is not running on the given node.
869 shift # "$@" is passed to ctdbd start.
871 echo -n "Starting CTDB on node ${pnn}..."
873 if [ -n "$CTDB_NODES_SOCKETS" ] ; then
874 daemons_start_1 $pnn "$@"
876 onnode $pnn $CTDB_TEST_WRAPPER _ctdb_start "$@"
879 # If we're starting only 1 node then we're doing something weird.
880 ctdb_restart_when_done
885 # "$@" is passed to ctdbd start.
887 echo -n "Restarting CTDB"
888 if $ctdb_test_restart_scheduled ; then
889 echo -n " (scheduled)"
895 if [ -n "$CTDB_NODES_SOCKETS" ] ; then
899 onnode -p all $CTDB_TEST_WRAPPER _restart_ctdb "$@"
903 [ $i -lt 5 ] || break
905 echo "That didn't seem to work - sleeping for a while..."
909 onnode -q 1 $CTDB_TEST_WRAPPER wait_until_healthy || return 1
911 local debug_out=$(onnode -p all ctdb status -Y 2>&1; onnode -p all ctdb scriptstatus 2>&1)
913 echo "Setting RerecoveryTimeout to 1"
914 onnode -pq all "$CTDB setvar RerecoveryTimeout 1"
916 # In recent versions of CTDB, forcing a recovery like this blocks
917 # until the recovery is complete. Hopefully this will help the
918 # cluster to stabilise before a subsequent test.
919 echo "Forcing a recovery..."
920 onnode -q 0 $CTDB recover
922 echo "Forcing a recovery..."
923 onnode -q 0 $CTDB recover
927 if ! onnode 0 $CTDB_TEST_WRAPPER _cluster_is_healthy ; then
928 echo "OUCH! Cluster is UNHEALTHY again..."
930 # Try to make the calling test fail
935 ctdb_restart_when_done ()
937 ctdb_test_restart_scheduled=true
940 #######################################
942 install_eventscript ()
944 local script_name="$1"
945 local script_contents="$2"
947 if [ -n "$CTDB_TEST_REAL_CLUSTER" ] ; then
948 # The quoting here is *very* fragile. However, we do
949 # experience the joy of installing a short script using
950 # onnode, and without needing to know the IP addresses of the
952 onnode all "f=\"\${CTDB_BASE:-/etc/ctdb}/events.d/${script_name}\" ; echo \"Installing \$f\" ; echo '${script_contents}' > \"\$f\" ; chmod 755 \"\$f\""
954 f="${CTDB_DIR}/tests/events.d/${script_name}"
955 echo "$script_contents" >"$f"
960 uninstall_eventscript ()
962 local script_name="$1"
964 if [ -n "$CTDB_TEST_REAL_CLUSTER" ] ; then
965 onnode all "rm -vf \"\${CTDB_BASE:-/etc/ctdb}/events.d/${script_name}\""
967 rm -vf "${CTDB_DIR}/tests/events.d/${script_name}"
971 #######################################
973 # This section deals with the 99.ctdb_test eventscript.
975 # Metafunctions: Handle a ctdb-test file on a node.
977 ctdb_test_eventscript_file_create ()
982 try_command_on_node $pnn touch "/tmp/ctdb-test-${type}.${pnn}"
985 ctdb_test_eventscript_file_remove ()
990 try_command_on_node $pnn rm -f "/tmp/ctdb-test-${type}.${pnn}"
993 ctdb_test_eventscript_file_exists ()
998 try_command_on_node $pnn test -f "/tmp/ctdb-test-${type}.${pnn}" >/dev/null 2>&1
1002 # Handle a flag file on a node that is removed by 99.ctdb_test on the
1004 ctdb_test_eventscript_flag ()
1010 ctdb_test_eventscript_file_${cmd} "$pnn" "flag-${event}"
1014 # Handle a trigger that causes 99.ctdb_test to fail it's monitor
1016 ctdb_test_eventscript_unhealthy_trigger ()
1021 ctdb_test_eventscript_file_${cmd} "$pnn" "unhealthy-trigger"
1024 # Handle the file that 99.ctdb_test created to show that it has marked
1025 # a node unhealthy because it detected the above trigger.
1026 ctdb_test_eventscript_unhealthy_detected ()
1031 ctdb_test_eventscript_file_${cmd} "$pnn" "unhealthy-detected"
1034 # Handle a trigger that causes 99.ctdb_test to timeout it's monitor
1035 # event. This should cause the node to be banned.
1036 ctdb_test_eventscript_timeout_trigger ()
1042 ctdb_test_eventscript_file_${cmd} "$pnn" "${event}-timeout"
1045 # Note that the eventscript can't use the above functions!
1046 ctdb_test_eventscript_install ()
1049 local script='#!/bin/sh
1053 rm -vf "/tmp/ctdb-test-flag-${1}.${pnn}"
1055 trigger="/tmp/ctdb-test-unhealthy-trigger.${pnn}"
1056 detected="/tmp/ctdb-test-unhealthy-detected.${pnn}"
1057 timeout_trigger="/tmp/ctdb-test-${1}-timeout.${pnn}"
1060 if [ -e "$trigger" ] ; then
1061 echo "${0}: Unhealthy because \"$trigger\" detected"
1064 elif [ -e "$detected" -a ! -e "$trigger" ] ; then
1065 echo "${0}: Healthy again, \"$trigger\" no longer detected"
1071 if [ -e "$timeout_trigger" ] ; then
1072 echo "${0}: Sleeping for a long time because \"$timeout_trigger\" detected"
1082 install_eventscript "99.ctdb_test" "$script"
1085 ctdb_test_eventscript_uninstall ()
1087 uninstall_eventscript "99.ctdb_test"
1090 # Note that this only works if you know all other monitor events will
1091 # succeed. You also need to install the eventscript before using it.
1092 wait_for_monitor_event ()
1096 echo "Waiting for a monitor event on node ${pnn}..."
1097 ctdb_test_eventscript_flag create $pnn "monitor"
1099 wait_until 120 ! ctdb_test_eventscript_flag exists $pnn "monitor"
1103 # Make sure that $CTDB is set.