From 455d931a16815f3b8ee47e2b1d5aeb13e76568b2 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Fri, 6 Dec 2019 16:11:45 +1100 Subject: [PATCH] ctdb-tests: Dump logs on shutdown failure Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- .../scripts/integration_local_daemons.bash | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/ctdb/tests/scripts/integration_local_daemons.bash b/ctdb/tests/scripts/integration_local_daemons.bash index a2b4e2aee67..643fc5ef846 100644 --- a/ctdb/tests/scripts/integration_local_daemons.bash +++ b/ctdb/tests/scripts/integration_local_daemons.bash @@ -56,7 +56,17 @@ ctdb_nodes_stop () { local nodespec="${1:-all}" - $ctdb_local_daemons stop "$nodespec" + if $ctdb_local_daemons stop "$nodespec" ; then + return 0 + fi + + # Failed, dump logs? + if $CTDB_TEST_PRINT_LOGS_ON_ERROR ; then + _print_logs + fi + + # Next level up can log the error... + return 1 } onnode () @@ -64,6 +74,15 @@ onnode () $ctdb_local_daemons onnode "$@" } + + +_print_logs () +{ + echo "*** LOG START --------------------" + $ctdb_local_daemons print-log all | tail -n 500 + echo "*** LOG END --------------------" +} + _print_logs_on_test_failure () { # This is called from ctdb_test_exit() where $status is available @@ -72,7 +91,5 @@ _print_logs_on_test_failure () return fi - echo "*** LOG START --------------------" - $ctdb_local_daemons print-log all | tail -n 500 - echo "*** LOG END --------------------" + _print_logs } -- 2.47.2