diff options
| author | Martin Schwenke <martin@meltin.net> | 2014-06-26 15:16:12 +1000 |
|---|---|---|
| committer | Amitay Isaacs <amitay@samba.org> | 2014-07-03 08:19:22 +0200 |
| commit | a7c55007659ab768293f15c5f5fc00c5d9e5c814 (patch) | |
| tree | 97aca7f6a1aa8be46221d7cb6217f9038a79d270 | |
| parent | b0c191e5de15e54646b02925e37458d6a56db015 (diff) | |
| download | samba-a7c55007659ab768293f15c5f5fc00c5d9e5c814.tar.gz samba-a7c55007659ab768293f15c5f5fc00c5d9e5c814.tar.xz samba-a7c55007659ab768293f15c5f5fc00c5d9e5c814.zip | |
ctdb-tests: Fix racy test for debugging hung scripts
Debugging can still be running when a monitor event times out and
scriptstatus output changes.
When debugging a hung script to a log file, write to a temporary file
and move the temporary file over the log file when done. The test
then waits for the log file to appear.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Thu Jul 3 08:19:23 CEST 2014 on sn-devel-104
| -rwxr-xr-x | ctdb/config/debug-hung-script.sh | 7 | ||||
| -rwxr-xr-x | ctdb/tests/complex/90_debug_hung_script.sh | 4 |
2 files changed, 10 insertions, 1 deletions
diff --git a/ctdb/config/debug-hung-script.sh b/ctdb/config/debug-hung-script.sh index f353b7d4bc..34e957c3cf 100755 --- a/ctdb/config/debug-hung-script.sh +++ b/ctdb/config/debug-hung-script.sh @@ -9,7 +9,8 @@ loadconfig ctdb # Testing hook if [ -n "$CTDB_DEBUG_HUNG_SCRIPT_LOGFILE" ] ; then - exec >>"$CTDB_DEBUG_HUNG_SCRIPT_LOGFILE" 2>&1 + tmp="${CTDB_DEBUG_HUNG_SCRIPT_LOGFILE}.part" + exec >>"$tmp" 2>&1 fi ( @@ -48,4 +49,8 @@ fi echo "===== End of hung script debug for PID=\"$1\", event=\"$2\" =====" + if [ -n "$CTDB_DEBUG_HUNG_SCRIPT_LOGFILE" ] ; then + mv "$tmp" "$CTDB_DEBUG_HUNG_SCRIPT_LOGFILE" + fi + ) 9>"${CTDB_VARDIR}/debug-hung-script.lock" diff --git a/ctdb/tests/complex/90_debug_hung_script.sh b/ctdb/tests/complex/90_debug_hung_script.sh index ef6216cf94..543844970b 100755 --- a/ctdb/tests/complex/90_debug_hung_script.sh +++ b/ctdb/tests/complex/90_debug_hung_script.sh @@ -66,6 +66,10 @@ try_command_on_node $test_node chmod +x "$rc_local_f" wait_for_monitor_event $test_node +echo "Waiting for debugging output to appear..." +# Use test -s because the file is created above using mktemp +wait_until 60 onnode $test_node test -s "$debug_output" + echo "Checking output of hung script debugging..." try_command_on_node -v $test_node cat "$debug_output" |
