The branch, master has been updated via 0e8b781 ctdb-tests: Process-exists unit tests should wait until PID is registered via 6fad421 ctdb-tests: Wait for fake_ctdbd to start, fail if it doesn't via 274fef9 ctdb-tests: Skip starting fake_ctdbd when current node is disconnected via dcbaebc ctdb-tests: Wait for ctdb_eventd to start, fail if it doesn't via d698992 ctdb-tests: Allow wait_until() to be used in unit tests from 16389be s3:vfs_glusterfs: Fix a double free in vfs_gluster_getwd()
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 0e8b781e0740310d251bf1fa7db7a467d4f7f9b5 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Oct 25 12:15:23 2017 +1100 ctdb-tests: Process-exists unit tests should wait until PID is registered Otherwise the client registration can race with the check in the test. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13097 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> Autobuild-User(master): Amitay Isaacs <ami...@samba.org> Autobuild-Date(master): Thu Oct 26 13:32:24 CEST 2017 on sn-devel-144 commit 6fad42103c0c812d5b5f4b42854fd7fd68846487 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Oct 25 17:52:04 2017 +1100 ctdb-tests: Wait for fake_ctdbd to start, fail if it doesn't BUG: https://bugzilla.samba.org/show_bug.cgi?id=13097 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 274fef9b843aa1726c9d331a876504bc0a96a322 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Oct 25 21:43:56 2017 +1100 ctdb-tests: Skip starting fake_ctdbd when current node is disconnected BUG: https://bugzilla.samba.org/show_bug.cgi?id=13097 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit dcbaebc232b49e6a64228f1bb7ce7cfc5d2120e2 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Oct 25 18:52:10 2017 +1100 ctdb-tests: Wait for ctdb_eventd to start, fail if it doesn't BUG: https://bugzilla.samba.org/show_bug.cgi?id=13097 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit d69899238bfe468cd3e915f6d66e279811301d66 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Oct 25 12:04:49 2017 +1100 ctdb-tests: Allow wait_until() to be used in unit tests BUG: https://bugzilla.samba.org/show_bug.cgi?id=13097 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> ----------------------------------------------------------------------- Summary of changes: ctdb/tests/eventd/scripts/local.sh | 7 ++--- ctdb/tests/scripts/common.sh | 44 +++++++++++++++++++++++++++++ ctdb/tests/scripts/integration.bash | 44 ----------------------------- ctdb/tests/tool/ctdb.getcapabilities.003.sh | 13 +++++---- ctdb/tests/tool/ctdb.lvs.008.sh | 13 +++++---- ctdb/tests/tool/ctdb.process-exists.001.sh | 2 ++ ctdb/tests/tool/ctdb.process-exists.002.sh | 2 ++ ctdb/tests/tool/ctdb.process-exists.003.sh | 2 ++ ctdb/tests/tool/scripts/local.sh | 6 +++- 9 files changed, 72 insertions(+), 61 deletions(-) Changeset truncated at 500 lines: diff --git a/ctdb/tests/eventd/scripts/local.sh b/ctdb/tests/eventd/scripts/local.sh index 343205e..c8f7775 100644 --- a/ctdb/tests/eventd/scripts/local.sh +++ b/ctdb/tests/eventd/scripts/local.sh @@ -42,7 +42,7 @@ cleanup_eventd () setup_eventd () { - debug "Setting up eventd" + echo "Setting up eventd" if [ -n "$1" ]; then extra_args="-D $1" @@ -53,9 +53,8 @@ setup_eventd () -e "$eventd_scriptdir" \ -l "file:" -d "DEBUG" $extra_args 2>&1 | tee "$eventd_logfile" & # Wait till eventd is running - while [ ! -S "$eventd_socket" ] ; do - sleep 1 - done + wait_until 10 test -S "$eventd_socket" || \ + die "ctdb_eventd failed to start" test_cleanup cleanup_eventd } diff --git a/ctdb/tests/scripts/common.sh b/ctdb/tests/scripts/common.sh index 93db417..099eee1 100644 --- a/ctdb/tests/scripts/common.sh +++ b/ctdb/tests/scripts/common.sh @@ -47,3 +47,47 @@ esac if [ -d "$_test_bin_dir" ] ; then PATH="${_test_bin_dir}:$PATH" fi + +# Wait until either timeout expires or command succeeds. The command +# will be tried once per second, unless timeout has format T/I, where +# I is the recheck interval. +wait_until () +{ + local timeout="$1" ; shift # "$@" is the command... + + local interval=1 + case "$timeout" in + */*) + interval="${timeout#*/}" + timeout="${timeout%/*}" + esac + + local negate=false + if [ "$1" = "!" ] ; then + negate=true + shift + fi + + echo -n "<${timeout}|" + local t=$timeout + while [ $t -gt 0 ] ; do + local rc=0 + "$@" || rc=$? + if { ! $negate && [ $rc -eq 0 ] ; } || \ + { $negate && [ $rc -ne 0 ] ; } ; then + echo "|$(($timeout - $t))|" + echo "OK" + return 0 + fi + local i + for i in $(seq 1 $interval) ; do + echo -n . + done + t=$(($t - $interval)) + sleep $interval + done + + echo "*TIMEOUT*" + + return 1 +} diff --git a/ctdb/tests/scripts/integration.bash b/ctdb/tests/scripts/integration.bash index ea8a280..b627c3e 100644 --- a/ctdb/tests/scripts/integration.bash +++ b/ctdb/tests/scripts/integration.bash @@ -259,50 +259,6 @@ delete_ip_from_all_nodes () ####################################### -# Wait until either timeout expires or command succeeds. The command -# will be tried once per second, unless timeout has format T/I, where -# I is the recheck interval. -wait_until () -{ - local timeout="$1" ; shift # "$@" is the command... - - local interval=1 - case "$timeout" in - */*) - interval="${timeout#*/}" - timeout="${timeout%/*}" - esac - - local negate=false - if [ "$1" = "!" ] ; then - negate=true - shift - fi - - echo -n "<${timeout}|" - local t=$timeout - while [ $t -gt 0 ] ; do - local rc=0 - "$@" || rc=$? - if { ! $negate && [ $rc -eq 0 ] ; } || \ - { $negate && [ $rc -ne 0 ] ; } ; then - echo "|$(($timeout - $t))|" - echo "OK" - return 0 - fi - local i - for i in $(seq 1 $interval) ; do - echo -n . - done - t=$(($t - $interval)) - sleep $interval - done - - echo "*TIMEOUT*" - - return 1 -} - sleep_for () { echo -n "=${1}|" diff --git a/ctdb/tests/tool/ctdb.getcapabilities.003.sh b/ctdb/tests/tool/ctdb.getcapabilities.003.sh index 91d38b8..74702d5 100755 --- a/ctdb/tests/tool/ctdb.getcapabilities.003.sh +++ b/ctdb/tests/tool/ctdb.getcapabilities.003.sh @@ -10,12 +10,13 @@ setup_nodes <<EOF 192.168.20.43 EOF -setup_ctdbd <<EOF -NODEMAP -0 192.168.20.41 0x1 CURRENT RECMASTER -1 192.168.20.42 0x0 -2 192.168.20.43 0x0 -EOF +# Don't setup ctdbd - disconnected on current node +#setup_ctdbd <<EOF +#NODEMAP +#0 192.168.20.41 0x1 CURRENT RECMASTER +#1 192.168.20.42 0x0 +#2 192.168.20.43 0x0 +#EOF required_result 1 <<EOF connect() failed, errno=2 diff --git a/ctdb/tests/tool/ctdb.lvs.008.sh b/ctdb/tests/tool/ctdb.lvs.008.sh index a0e24b1..6cdd702 100755 --- a/ctdb/tests/tool/ctdb.lvs.008.sh +++ b/ctdb/tests/tool/ctdb.lvs.008.sh @@ -13,12 +13,13 @@ EOF setup_lvs <<EOF EOF -setup_ctdbd <<EOF -NODEMAP -0 192.168.20.41 0x1 CURRENT RECMASTER -1 192.168.20.42 0x0 -2 192.168.20.43 0x0 -EOF +# Don't setup ctdbd - disconnected on current node +#setup_ctdbd <<EOF +#NODEMAP +#0 192.168.20.41 0x1 CURRENT RECMASTER +#1 192.168.20.42 0x0 +#2 192.168.20.43 0x0 +#EOF ##### diff --git a/ctdb/tests/tool/ctdb.process-exists.001.sh b/ctdb/tests/tool/ctdb.process-exists.001.sh index 2339344..1b6d213 100755 --- a/ctdb/tests/tool/ctdb.process-exists.001.sh +++ b/ctdb/tests/tool/ctdb.process-exists.001.sh @@ -14,6 +14,8 @@ EOF dummy_client -s $ctdbd_socket & pid=$! +wait_until 10 $CTDB process-exists "$pid" + ok "PID $pid exists" simple_test "$pid" diff --git a/ctdb/tests/tool/ctdb.process-exists.002.sh b/ctdb/tests/tool/ctdb.process-exists.002.sh index fe3dfd4..ace7749 100755 --- a/ctdb/tests/tool/ctdb.process-exists.002.sh +++ b/ctdb/tests/tool/ctdb.process-exists.002.sh @@ -16,6 +16,8 @@ srvid="0xaebbccdd12345678" dummy_client -d INFO -s "$ctdbd_socket" -S "$srvid" & pid=$! +wait_until 10 $CTDB process-exists "$pid" + srvid2="0x1234567812345678" required_result 1 "PID $pid with SRVID $srvid2 does not exist" simple_test "$pid" "$srvid2" diff --git a/ctdb/tests/tool/ctdb.process-exists.003.sh b/ctdb/tests/tool/ctdb.process-exists.003.sh index bb1ef9a..29c42a1 100755 --- a/ctdb/tests/tool/ctdb.process-exists.003.sh +++ b/ctdb/tests/tool/ctdb.process-exists.003.sh @@ -16,6 +16,8 @@ srvid="0xaebbccdd12345678" dummy_client -d INFO -s "$ctdbd_socket" -n 10 -S "$srvid" & pid=$! +wait_until 10 $CTDB process-exists "$pid" + srvid2="0x1234567812345678" required_result 1 "PID $pid with SRVID $srvid2 does not exist" simple_test "$pid" "$srvid2" diff --git a/ctdb/tests/tool/scripts/local.sh b/ctdb/tests/tool/scripts/local.sh index 2c9be2d..7cee84a 100644 --- a/ctdb/tests/tool/scripts/local.sh +++ b/ctdb/tests/tool/scripts/local.sh @@ -48,10 +48,14 @@ cleanup_ctdbd () setup_ctdbd () { - debug "Setting up fake ctdbd" + echo "Setting up fake ctdbd" $VALGRIND fake_ctdbd -d "$FAKE_CTDBD_DEBUGLEVEL" \ -s "$ctdbd_socket" -p "$ctdbd_pidfile" + # Wait till fake_ctdbd is running + wait_until 10 test -S "$ctdbd_socket" || \ + die "fake_ctdbd failed to start" + test_cleanup cleanup_ctdbd } -- Samba Shared Repository